From 7545f9b4a91eff8e057133d099cf5aeb489adf7d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 21 Nov 2025 09:36:38 +0000 Subject: [PATCH 01/12] feat(api): add WALLET_RECOMMENDATION_REASONS attribute for tokenization rules feat(api): provide a unified model for AuthRule fix(api): make certain payoff fields nullable fix(api): fix examples in spec that were not fully valid --- .stats.yml | 6 +- README.md | 16 + .../kotlin/com/lithic/api/models/AuthRule.kt | 2395 ++++++++++++++-- .../lithic/api/models/AuthRuleV2ListPage.kt | 9 +- .../api/models/AuthRuleV2ListPageAsync.kt | 10 +- .../api/models/AuthRuleV2ListPageResponse.kt | 26 +- .../com/lithic/api/models/CardProgram.kt | 106 +- .../lithic/api/models/ConditionalOperation.kt | 18 + ...ConditionalTokenizationActionParameters.kt | 27 + .../kotlin/com/lithic/api/models/Statement.kt | 77 +- .../models/TokenizationSimulateResponse.kt | 178 -- ...okenizationUpdateDigitalCardArtResponse.kt | 161 -- .../com/lithic/api/models/V2CreateResponse.kt | 2547 ----------------- .../com/lithic/api/models/V2DraftResponse.kt | 2546 ---------------- .../com/lithic/api/models/V2ListResponse.kt | 2546 ---------------- .../lithic/api/models/V2PromoteResponse.kt | 2547 ----------------- .../lithic/api/models/V2RetrieveResponse.kt | 2547 ----------------- .../com/lithic/api/models/V2UpdateResponse.kt | 2547 ----------------- .../async/TokenizationServiceAsync.kt | 40 +- .../async/TokenizationServiceAsyncImpl.kt | 18 +- .../async/authRules/V2ServiceAsync.kt | 121 +- .../async/authRules/V2ServiceAsyncImpl.kt | 46 +- .../services/blocking/TokenizationService.kt | 43 +- .../blocking/TokenizationServiceImpl.kt | 18 +- .../services/blocking/authRules/V2Service.kt | 112 +- .../blocking/authRules/V2ServiceImpl.kt | 55 +- .../models/AccountHolderCreateParamsTest.kt | 22 +- .../models/AccountHolderUpdateParamsTest.kt | 258 ++ .../AccountHolderUploadDocumentParamsTest.kt | 8 +- .../api/models/AccountListPageResponseTest.kt | 6 +- .../com/lithic/api/models/AccountTest.kt | 6 +- .../com/lithic/api/models/AuthRuleTest.kt | 160 +- .../models/AuthRuleV2ListPageResponseTest.kt | 36 +- .../lithic/api/models/CardCreateParamsTest.kt | 24 +- .../api/models/CardListPageResponseTest.kt | 6 +- .../models/CardProgramListPageResponseTest.kt | 6 +- .../com/lithic/api/models/CardProgramTest.kt | 6 +- .../kotlin/com/lithic/api/models/CardTest.kt | 6 +- .../lithic/api/models/CardUpdateParamsTest.kt | 12 +- .../ExternalBankAccountCreateParamsTest.kt | 6 +- .../com/lithic/api/models/NonPciCardTest.kt | 6 +- ...rtSettlementListDetailsPageResponseTest.kt | 12 +- .../lithic/api/models/SettlementDetailTest.kt | 12 +- .../lithic/api/models/SettlementReportTest.kt | 12 +- .../TokenizationSimulateResponseTest.kt | 178 -- ...enizationUpdateDigitalCardArtParamsTest.kt | 6 +- ...izationUpdateDigitalCardArtResponseTest.kt | 178 -- .../lithic/api/models/V2CreateResponseTest.kt | 173 -- .../lithic/api/models/V2DraftResponseTest.kt | 172 -- .../lithic/api/models/V2ListResponseTest.kt | 171 -- .../api/models/V2PromoteResponseTest.kt | 173 -- .../api/models/V2RetrieveResponseTest.kt | 173 -- .../lithic/api/models/V2UpdateResponseTest.kt | 173 -- .../lithic/api/services/ErrorHandlingTest.kt | 136 +- .../lithic/api/services/ServiceParamsTest.kt | 8 +- .../async/AccountHolderServiceAsyncTest.kt | 99 +- .../services/async/CardServiceAsyncTest.kt | 12 +- .../ExternalBankAccountServiceAsyncTest.kt | 2 +- .../async/TokenizationServiceAsyncTest.kt | 14 +- .../async/authRules/V2ServiceAsyncTest.kt | 30 +- .../blocking/AccountHolderServiceTest.kt | 99 +- .../api/services/blocking/CardServiceTest.kt | 12 +- .../ExternalBankAccountServiceTest.kt | 2 +- .../blocking/TokenizationServiceTest.kt | 10 +- .../blocking/authRules/V2ServiceTest.kt | 20 +- 65 files changed, 3286 insertions(+), 17921 deletions(-) delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateResponse.kt delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponse.kt delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationSimulateResponseTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponseTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/V2CreateResponseTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/V2DraftResponseTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResponseTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/V2PromoteResponseTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/V2RetrieveResponseTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/V2UpdateResponseTest.kt diff --git a/.stats.yml b/.stats.yml index d8bf6f020..ac9c2797c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 172 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-9791980619fc7ce8afb01f77dfe3c660a540975327378287cb666136ae4b0a99.yml -openapi_spec_hash: 0752074b2a7b0534329a1e3176c94a62 -config_hash: aab05d0cf41f1f6b9f4d5677273c1600 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-a9de2732e7a28b7fc5b8b7b171781d617337b6223d82ef7d6a554d0bd2b33bab.yml +openapi_spec_hash: fc6111d286c7002cd854af23841d137e +config_hash: f6f5c7f37033e89a3cf91a48371a718a diff --git a/README.md b/README.md index 9e88223b2..ba333d9e5 100644 --- a/README.md +++ b/README.md @@ -546,6 +546,22 @@ CardCreateParams params = CardCreateParams.builder() These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. +To set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class: + +```java +import com.lithic.api.core.JsonValue; +import com.lithic.api.models.CardCreateParams; +import com.lithic.api.models.ShippingAddress; + +CardCreateParams params = CardCreateParams.builder() + .shippingAddress(ShippingAddress.builder() + .putAdditionalProperty("secretProperty", JsonValue.from("42")) + .build()) + .build(); +``` + +These properties can be accessed on the nested built object later using the `_additionalProperties()` method. + To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](lithic-java-core/src/main/kotlin/com/lithic/api/core/Values.kt) object to its setter: ```java diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt index 8c222be14..ecd866aa2 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt @@ -6,13 +6,24 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer import com.lithic.api.core.Enum import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue +import com.lithic.api.core.allMaxBy import com.lithic.api.core.checkKnown import com.lithic.api.core.checkRequired +import com.lithic.api.core.getOrThrow import com.lithic.api.core.toImmutable import com.lithic.api.errors.LithicInvalidDataException import java.util.Collections @@ -24,57 +35,73 @@ class AuthRule @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, - private val state: JsonField, private val accountTokens: JsonField>, - private val allowedCountries: JsonField>, - private val allowedMcc: JsonField>, - private val blockedCountries: JsonField>, - private val blockedMcc: JsonField>, + private val businessAccountTokens: JsonField>, private val cardTokens: JsonField>, + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val eventStream: JsonField, + private val lithicManaged: JsonField, + private val name: JsonField, private val programLevel: JsonField, + private val state: JsonField, + private val type: JsonField, + private val excludedCardTokens: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), @JsonProperty("account_tokens") @ExcludeMissing accountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("allowed_countries") + @JsonProperty("business_account_tokens") @ExcludeMissing - allowedCountries: JsonField> = JsonMissing.of(), - @JsonProperty("allowed_mcc") + businessAccountTokens: JsonField> = JsonMissing.of(), + @JsonProperty("card_tokens") @ExcludeMissing - allowedMcc: JsonField> = JsonMissing.of(), - @JsonProperty("blocked_countries") + cardTokens: JsonField> = JsonMissing.of(), + @JsonProperty("current_version") @ExcludeMissing - blockedCountries: JsonField> = JsonMissing.of(), - @JsonProperty("blocked_mcc") + currentVersion: JsonField = JsonMissing.of(), + @JsonProperty("draft_version") @ExcludeMissing - blockedMcc: JsonField> = JsonMissing.of(), - @JsonProperty("card_tokens") + draftVersion: JsonField = JsonMissing.of(), + @JsonProperty("event_stream") @ExcludeMissing - cardTokens: JsonField> = JsonMissing.of(), + eventStream: JsonField = JsonMissing.of(), + @JsonProperty("lithic_managed") + @ExcludeMissing + lithicManaged: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("program_level") @ExcludeMissing programLevel: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("excluded_card_tokens") + @ExcludeMissing + excludedCardTokens: JsonField> = JsonMissing.of(), ) : this( token, - state, accountTokens, - allowedCountries, - allowedMcc, - blockedCountries, - blockedMcc, + businessAccountTokens, cardTokens, + currentVersion, + draftVersion, + eventStream, + lithicManaged, + name, programLevel, + state, + type, + excludedCardTokens, mutableMapOf(), ) /** - * Globally unique identifier. + * Auth Rule Token * * @throws LithicInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -82,74 +109,106 @@ private constructor( fun token(): String = token.getRequired("token") /** - * Indicates whether the Auth Rule is ACTIVE or INACTIVE + * Account tokens to which the Auth Rule applies. * * @throws LithicInvalidDataException if 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") + fun accountTokens(): List = accountTokens.getRequired("account_tokens") /** - * Array of account_token(s) identifying the accounts that the Auth Rule applies to. Note that - * only this field or `card_tokens` can be provided for a given Auth Rule. + * Business Account tokens to which the Auth Rule applies. * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun accountTokens(): Optional> = accountTokens.getOptional("account_tokens") + fun businessAccountTokens(): List = + businessAccountTokens.getRequired("business_account_tokens") /** - * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list of - * countries in which all transactions are blocked; "allowing" those countries in an Auth Rule - * does not override the Lithic-wide restrictions. + * Card tokens to which the Auth Rule applies. * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun allowedCountries(): Optional> = - allowedCountries.getOptional("allowed_countries") + fun currentVersion(): Optional = currentVersion.getOptional("current_version") /** - * Merchant category codes for which the Auth Rule permits transactions. - * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun allowedMcc(): Optional> = allowedMcc.getOptional("allowed_mcc") + fun draftVersion(): Optional = draftVersion.getOptional("draft_version") /** - * Countries in which the Auth Rule automatically declines transactions. + * The event stream during which the rule will be evaluated. * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun blockedCountries(): Optional> = - blockedCountries.getOptional("blocked_countries") + fun eventStream(): EventStream = eventStream.getRequired("event_stream") /** - * Merchant category codes for which the Auth Rule automatically declines transactions. + * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be modified + * or deleted by the user * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun blockedMcc(): Optional> = blockedMcc.getOptional("blocked_mcc") + fun lithicManaged(): Boolean = lithicManaged.getRequired("lithic_managed") /** - * Array of card_token(s) identifying the cards that the Auth Rule applies to. Note that only - * this field or `account_tokens` can be provided for a given Auth Rule. + * Auth Rule Name * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cardTokens(): Optional> = cardTokens.getOptional("card_tokens") + fun name(): Optional = name.getOptional("name") + + /** + * Whether the Auth Rule applies to all authorizations on the card program. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun programLevel(): Boolean = programLevel.getRequired("program_level") /** - * Boolean indicating whether the Auth Rule is applied at the program level. + * The state of the Auth Rule + * + * @throws LithicInvalidDataException if 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(): AuthRuleState = state.getRequired("state") + + /** + * The type of Auth Rule. For certain rule types, this determines the event stream during which + * it will be evaluated. For rules that can be applied to one of several event streams, the + * effective one is defined by the separate `event_stream` field. + * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. + * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. + * - `MERCHANT_LOCK`: AUTHORIZATION event stream. + * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, + * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. + * + * @throws LithicInvalidDataException if 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(): AuthRuleType = type.getRequired("type") + + /** + * Card tokens to which the Auth Rule does not apply. * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun programLevel(): Optional = programLevel.getOptional("program_level") + fun excludedCardTokens(): Optional> = + excludedCardTokens.getOptional("excluded_card_tokens") /** * Returns the raw JSON value of [token]. @@ -158,13 +217,6 @@ private constructor( */ @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - /** - * 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 [accountTokens]. * @@ -175,51 +227,66 @@ private constructor( fun _accountTokens(): JsonField> = accountTokens /** - * Returns the raw JSON value of [allowedCountries]. + * Returns the raw JSON value of [businessAccountTokens]. * - * Unlike [allowedCountries], this method doesn't throw if the JSON field has an unexpected + * Unlike [businessAccountTokens], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("allowed_countries") + @JsonProperty("business_account_tokens") @ExcludeMissing - fun _allowedCountries(): JsonField> = allowedCountries + fun _businessAccountTokens(): JsonField> = businessAccountTokens /** - * Returns the raw JSON value of [allowedMcc]. + * Returns the raw JSON value of [cardTokens]. * - * Unlike [allowedMcc], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("allowed_mcc") + @JsonProperty("card_tokens") @ExcludeMissing - fun _allowedMcc(): JsonField> = allowedMcc + fun _cardTokens(): JsonField> = cardTokens /** - * Returns the raw JSON value of [blockedCountries]. + * Returns the raw JSON value of [currentVersion]. * - * Unlike [blockedCountries], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [currentVersion], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("blocked_countries") + @JsonProperty("current_version") @ExcludeMissing - fun _blockedCountries(): JsonField> = blockedCountries + fun _currentVersion(): JsonField = currentVersion /** - * Returns the raw JSON value of [blockedMcc]. + * Returns the raw JSON value of [draftVersion]. * - * Unlike [blockedMcc], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [draftVersion], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("blocked_mcc") + @JsonProperty("draft_version") @ExcludeMissing - fun _blockedMcc(): JsonField> = blockedMcc + fun _draftVersion(): JsonField = draftVersion /** - * Returns the raw JSON value of [cardTokens]. + * Returns the raw JSON value of [eventStream]. * - * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("card_tokens") + @JsonProperty("event_stream") @ExcludeMissing - fun _cardTokens(): JsonField> = cardTokens + fun _eventStream(): JsonField = eventStream + + /** + * Returns the raw JSON value of [lithicManaged]. + * + * Unlike [lithicManaged], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lithic_managed") + @ExcludeMissing + fun _lithicManaged(): JsonField = lithicManaged + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Returns the raw JSON value of [programLevel]. @@ -230,6 +297,30 @@ private constructor( @ExcludeMissing fun _programLevel(): JsonField = programLevel + /** + * 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 + + /** + * Returns the raw JSON value of [excludedCardTokens]. + * + * Unlike [excludedCardTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("excluded_card_tokens") + @ExcludeMissing + fun _excludedCardTokens(): JsonField> = excludedCardTokens + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -250,7 +341,17 @@ private constructor( * The following fields are required: * ```java * .token() + * .accountTokens() + * .businessAccountTokens() + * .cardTokens() + * .currentVersion() + * .draftVersion() + * .eventStream() + * .lithicManaged() + * .name() + * .programLevel() * .state() + * .type() * ``` */ @JvmStatic fun builder() = Builder() @@ -260,31 +361,39 @@ private constructor( class Builder internal constructor() { private var token: JsonField? = null - private var state: JsonField? = null private var accountTokens: JsonField>? = null - private var allowedCountries: JsonField>? = null - private var allowedMcc: JsonField>? = null - private var blockedCountries: JsonField>? = null - private var blockedMcc: JsonField>? = null + private var businessAccountTokens: JsonField>? = null private var cardTokens: JsonField>? = null - private var programLevel: JsonField = JsonMissing.of() + private var currentVersion: JsonField? = null + private var draftVersion: JsonField? = null + private var eventStream: JsonField? = null + private var lithicManaged: JsonField? = null + private var name: JsonField? = null + private var programLevel: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var excludedCardTokens: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(authRule: AuthRule) = apply { token = authRule.token - state = authRule.state accountTokens = authRule.accountTokens.map { it.toMutableList() } - allowedCountries = authRule.allowedCountries.map { it.toMutableList() } - allowedMcc = authRule.allowedMcc.map { it.toMutableList() } - blockedCountries = authRule.blockedCountries.map { it.toMutableList() } - blockedMcc = authRule.blockedMcc.map { it.toMutableList() } + businessAccountTokens = authRule.businessAccountTokens.map { it.toMutableList() } cardTokens = authRule.cardTokens.map { it.toMutableList() } + currentVersion = authRule.currentVersion + draftVersion = authRule.draftVersion + eventStream = authRule.eventStream + lithicManaged = authRule.lithicManaged + name = authRule.name programLevel = authRule.programLevel + state = authRule.state + type = authRule.type + excludedCardTokens = authRule.excludedCardTokens.map { it.toMutableList() } additionalProperties = authRule.additionalProperties.toMutableMap() } - /** Globally unique identifier. */ + /** Auth Rule Token */ fun token(token: String) = token(JsonField.of(token)) /** @@ -295,21 +404,7 @@ private constructor( */ fun token(token: JsonField) = apply { this.token = token } - /** Indicates whether the Auth Rule is ACTIVE or INACTIVE */ - 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 } - - /** - * Array of account_token(s) identifying the accounts that the Auth Rule applies to. Note - * that only this field or `card_tokens` can be provided for a given Auth Rule. - */ + /** Account tokens to which the Auth Rule applies. */ fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) /** @@ -335,146 +430,141 @@ private constructor( } } - /** - * Countries in which the Auth Rule permits transactions. Note that Lithic maintains a list - * of countries in which all transactions are blocked; "allowing" those countries in an Auth - * Rule does not override the Lithic-wide restrictions. - */ - fun allowedCountries(allowedCountries: List) = - allowedCountries(JsonField.of(allowedCountries)) + /** Business Account tokens to which the Auth Rule applies. */ + fun businessAccountTokens(businessAccountTokens: List) = + businessAccountTokens(JsonField.of(businessAccountTokens)) /** - * Sets [Builder.allowedCountries] to an arbitrary JSON value. + * Sets [Builder.businessAccountTokens] to an arbitrary JSON value. * - * You should usually call [Builder.allowedCountries] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.businessAccountTokens] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun allowedCountries(allowedCountries: JsonField>) = apply { - this.allowedCountries = allowedCountries.map { it.toMutableList() } + fun businessAccountTokens(businessAccountTokens: JsonField>) = apply { + this.businessAccountTokens = businessAccountTokens.map { it.toMutableList() } } /** - * Adds a single [String] to [allowedCountries]. + * Adds a single [String] to [businessAccountTokens]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addAllowedCountry(allowedCountry: String) = apply { - allowedCountries = - (allowedCountries ?: JsonField.of(mutableListOf())).also { - checkKnown("allowedCountries", it).add(allowedCountry) + fun addBusinessAccountToken(businessAccountToken: String) = apply { + businessAccountTokens = + (businessAccountTokens ?: JsonField.of(mutableListOf())).also { + checkKnown("businessAccountTokens", it).add(businessAccountToken) } } - /** Merchant category codes for which the Auth Rule permits transactions. */ - fun allowedMcc(allowedMcc: List) = allowedMcc(JsonField.of(allowedMcc)) + /** Card tokens to which the Auth Rule applies. */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) /** - * Sets [Builder.allowedMcc] to an arbitrary JSON value. + * Sets [Builder.cardTokens] to an arbitrary JSON value. * - * You should usually call [Builder.allowedMcc] with a well-typed `List` value + * You should usually call [Builder.cardTokens] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun allowedMcc(allowedMcc: JsonField>) = apply { - this.allowedMcc = allowedMcc.map { it.toMutableList() } + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } } /** - * Adds a single [String] to [Builder.allowedMcc]. + * Adds a single [String] to [cardTokens]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addAllowedMcc(allowedMcc: String) = apply { - this.allowedMcc = - (this.allowedMcc ?: JsonField.of(mutableListOf())).also { - checkKnown("allowedMcc", it).add(allowedMcc) + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).also { + checkKnown("cardTokens", it).add(cardToken) } } - /** Countries in which the Auth Rule automatically declines transactions. */ - fun blockedCountries(blockedCountries: List) = - blockedCountries(JsonField.of(blockedCountries)) + fun currentVersion(currentVersion: CurrentVersion?) = + currentVersion(JsonField.ofNullable(currentVersion)) + + /** Alias for calling [Builder.currentVersion] with `currentVersion.orElse(null)`. */ + fun currentVersion(currentVersion: Optional) = + currentVersion(currentVersion.getOrNull()) /** - * Sets [Builder.blockedCountries] to an arbitrary JSON value. + * Sets [Builder.currentVersion] to an arbitrary JSON value. * - * You should usually call [Builder.blockedCountries] with a well-typed `List` value + * You should usually call [Builder.currentVersion] with a well-typed [CurrentVersion] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun blockedCountries(blockedCountries: JsonField>) = apply { - this.blockedCountries = blockedCountries.map { it.toMutableList() } + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion } - /** - * Adds a single [String] to [blockedCountries]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBlockedCountry(blockedCountry: String) = apply { - blockedCountries = - (blockedCountries ?: JsonField.of(mutableListOf())).also { - checkKnown("blockedCountries", it).add(blockedCountry) - } - } + fun draftVersion(draftVersion: DraftVersion?) = + draftVersion(JsonField.ofNullable(draftVersion)) - /** Merchant category codes for which the Auth Rule automatically declines transactions. */ - fun blockedMcc(blockedMcc: List) = blockedMcc(JsonField.of(blockedMcc)) + /** Alias for calling [Builder.draftVersion] with `draftVersion.orElse(null)`. */ + fun draftVersion(draftVersion: Optional) = + draftVersion(draftVersion.getOrNull()) /** - * Sets [Builder.blockedMcc] to an arbitrary JSON value. + * Sets [Builder.draftVersion] to an arbitrary JSON value. * - * You should usually call [Builder.blockedMcc] with a well-typed `List` value + * You should usually call [Builder.draftVersion] with a well-typed [DraftVersion] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun blockedMcc(blockedMcc: JsonField>) = apply { - this.blockedMcc = blockedMcc.map { it.toMutableList() } + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion } + /** The event stream during which the rule will be evaluated. */ + fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) + /** - * Adds a single [String] to [Builder.blockedMcc]. + * Sets [Builder.eventStream] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.eventStream] with a well-typed [EventStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun addBlockedMcc(blockedMcc: String) = apply { - this.blockedMcc = - (this.blockedMcc ?: JsonField.of(mutableListOf())).also { - checkKnown("blockedMcc", it).add(blockedMcc) - } + fun eventStream(eventStream: JsonField) = apply { + this.eventStream = eventStream } /** - * Array of card_token(s) identifying the cards that the Auth Rule applies to. Note that - * only this field or `account_tokens` can be provided for a given Auth Rule. + * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be + * modified or deleted by the user */ - fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + fun lithicManaged(lithicManaged: Boolean) = lithicManaged(JsonField.of(lithicManaged)) /** - * Sets [Builder.cardTokens] to an arbitrary JSON value. + * Sets [Builder.lithicManaged] to an arbitrary JSON value. * - * You should usually call [Builder.cardTokens] with a well-typed `List` value + * You should usually call [Builder.lithicManaged] with a well-typed [Boolean] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun cardTokens(cardTokens: JsonField>) = apply { - this.cardTokens = cardTokens.map { it.toMutableList() } + fun lithicManaged(lithicManaged: JsonField) = apply { + this.lithicManaged = lithicManaged } + /** Auth Rule Name */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + /** - * Adds a single [String] to [cardTokens]. + * Sets [Builder.name] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun addCardToken(cardToken: String) = apply { - cardTokens = - (cardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("cardTokens", it).add(cardToken) - } - } + fun name(name: JsonField) = apply { this.name = name } - /** Boolean indicating whether the Auth Rule is applied at the program level. */ + /** Whether the Auth Rule applies to all authorizations on the card program. */ fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) /** @@ -488,6 +578,66 @@ private constructor( this.programLevel = programLevel } + /** The state of the Auth Rule */ + fun state(state: AuthRuleState) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [AuthRuleState] 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 } + + /** + * The type of Auth Rule. For certain rule types, this determines the event stream during + * which it will be evaluated. For rules that can be applied to one of several event + * streams, the effective one is defined by the separate `event_stream` field. + * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. + * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. + * - `MERCHANT_LOCK`: AUTHORIZATION event stream. + * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, + * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. + */ + fun type(type: AuthRuleType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [AuthRuleType] 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 } + + /** Card tokens to which the Auth Rule does not apply. */ + fun excludedCardTokens(excludedCardTokens: List) = + excludedCardTokens(JsonField.of(excludedCardTokens)) + + /** + * Sets [Builder.excludedCardTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.excludedCardTokens] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { + this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [excludedCardTokens]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExcludedCardToken(excludedCardToken: String) = apply { + excludedCardTokens = + (excludedCardTokens ?: JsonField.of(mutableListOf())).also { + checkKnown("excludedCardTokens", it).add(excludedCardToken) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -515,7 +665,17 @@ private constructor( * The following fields are required: * ```java * .token() + * .accountTokens() + * .businessAccountTokens() + * .cardTokens() + * .currentVersion() + * .draftVersion() + * .eventStream() + * .lithicManaged() + * .name() + * .programLevel() * .state() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. @@ -523,14 +683,20 @@ private constructor( fun build(): AuthRule = AuthRule( checkRequired("token", token), + checkRequired("accountTokens", accountTokens).map { it.toImmutable() }, + checkRequired("businessAccountTokens", businessAccountTokens).map { + it.toImmutable() + }, + checkRequired("cardTokens", cardTokens).map { it.toImmutable() }, + checkRequired("currentVersion", currentVersion), + checkRequired("draftVersion", draftVersion), + checkRequired("eventStream", eventStream), + checkRequired("lithicManaged", lithicManaged), + checkRequired("name", name), + checkRequired("programLevel", programLevel), checkRequired("state", state), - (accountTokens ?: JsonMissing.of()).map { it.toImmutable() }, - (allowedCountries ?: JsonMissing.of()).map { it.toImmutable() }, - (allowedMcc ?: JsonMissing.of()).map { it.toImmutable() }, - (blockedCountries ?: JsonMissing.of()).map { it.toImmutable() }, - (blockedMcc ?: JsonMissing.of()).map { it.toImmutable() }, - (cardTokens ?: JsonMissing.of()).map { it.toImmutable() }, - programLevel, + checkRequired("type", type), + (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -543,14 +709,18 @@ private constructor( } token() - state().validate() accountTokens() - allowedCountries() - allowedMcc() - blockedCountries() - blockedMcc() + businessAccountTokens() cardTokens() + currentVersion().ifPresent { it.validate() } + draftVersion().ifPresent { it.validate() } + eventStream().validate() + lithicManaged() + name() programLevel() + state().validate() + type().validate() + excludedCardTokens() validated = true } @@ -570,124 +740,1747 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (token.asKnown().isPresent) 1 else 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + (accountTokens.asKnown().getOrNull()?.size ?: 0) + - (allowedCountries.asKnown().getOrNull()?.size ?: 0) + - (allowedMcc.asKnown().getOrNull()?.size ?: 0) + - (blockedCountries.asKnown().getOrNull()?.size ?: 0) + - (blockedMcc.asKnown().getOrNull()?.size ?: 0) + + (businessAccountTokens.asKnown().getOrNull()?.size ?: 0) + (cardTokens.asKnown().getOrNull()?.size ?: 0) + - (if (programLevel.asKnown().isPresent) 1 else 0) + (currentVersion.asKnown().getOrNull()?.validity() ?: 0) + + (draftVersion.asKnown().getOrNull()?.validity() ?: 0) + + (eventStream.asKnown().getOrNull()?.validity() ?: 0) + + (if (lithicManaged.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (programLevel.asKnown().isPresent) 1 else 0) + + (state.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (excludedCardTokens.asKnown().getOrNull()?.size ?: 0) - /** Indicates whether the Auth Rule is ACTIVE or INACTIVE */ - class State @JsonCreator private constructor(private val value: JsonField) : Enum { + class CurrentVersion + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("parameters") + @ExcludeMissing + parameters: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + ) : this(parameters, version, mutableMapOf()) /** - * Returns this class instance's raw value. + * Parameters for the Auth Rule * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTIVE = of("ACTIVE") - - @JvmField val INACTIVE = of("INACTIVE") - - @JvmStatic fun of(value: String) = State(JsonField.of(value)) - } - - /** An enum containing [State]'s known values. */ - enum class Known { - ACTIVE, - INACTIVE, - } + fun parameters(): Parameters = parameters.getRequired("parameters") /** - * An enum containing [State]'s known values, as well as an [_UNKNOWN] member. + * The version of the rule, this is incremented whenever the rule's parameters change. * - * 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. + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - enum class Value { - ACTIVE, - INACTIVE, - /** An enum member indicating that [State] was instantiated with an unknown value. */ - _UNKNOWN, - } + fun version(): Long = version.getRequired("version") /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. + * Returns the raw JSON value of [parameters]. * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. + * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. */ - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - INACTIVE -> Value.INACTIVE - else -> Value._UNKNOWN - } + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters /** - * Returns an enum member corresponding to this class instance's value. + * Returns the raw JSON value of [version]. * - * 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. + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. */ - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - INACTIVE -> Known.INACTIVE - else -> throw LithicInvalidDataException("Unknown State: $value") - } + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - /** - * 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") } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun validate(): State = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - known() - validated = true + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CurrentVersion]. + * + * The following fields are required: + * ```java + * .parameters() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false + /** A builder for [CurrentVersion]. */ + class Builder internal constructor() { + + private var parameters: JsonField? = null + private var version: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(currentVersion: CurrentVersion) = apply { + parameters = currentVersion.parameters + version = currentVersion.version + additionalProperties = currentVersion.additionalProperties.toMutableMap() } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * + /** Parameters for the Auth Rule */ + fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) + + /** + * Sets [Builder.parameters] to an arbitrary JSON value. + * + * You should usually call [Builder.parameters] with a well-typed [Parameters] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalBlock(conditionalBlock)`. + */ + fun parameters(conditionalBlock: ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlock(conditionalBlock)) + + /** + * Alias for calling [parameters] with + * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. + */ + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + + /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ + fun parameters(merchantLock: MerchantLockParameters) = + parameters(Parameters.ofMerchantLock(merchantLock)) + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditional3dsAction(conditional3dsAction)`. + */ + fun parameters(conditional3dsAction: Conditional3dsActionParameters) = + parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. + */ + fun parameters( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ) = + parameters( + Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) + ) + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchAction(conditionalAchAction)`. + */ + fun parameters(conditionalAchAction: ConditionalAchActionParameters) = + parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. + */ + fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = + parameters( + Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) + ) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + 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 [CurrentVersion]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .parameters() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CurrentVersion = + CurrentVersion( + checkRequired("parameters", parameters), + checkRequired("version", version), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CurrentVersion = apply { + if (validated) { + return@apply + } + + parameters().validate() + version() + 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 = + (parameters.asKnown().getOrNull()?.validity() ?: 0) + + (if (version.asKnown().isPresent) 1 else 0) + + /** Parameters for the Auth Rule */ + @JsonDeserialize(using = Parameters.Deserializer::class) + @JsonSerialize(using = Parameters.Serializer::class) + class Parameters + private constructor( + private val conditionalBlock: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val merchantLock: MerchantLockParameters? = null, + private val conditional3dsAction: Conditional3dsActionParameters? = null, + private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = + null, + private val conditionalAchAction: ConditionalAchActionParameters? = null, + private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = + null, + private val _json: JsonValue? = null, + ) { + + fun conditionalBlock(): Optional = + Optional.ofNullable(conditionalBlock) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun merchantLock(): Optional = Optional.ofNullable(merchantLock) + + fun conditional3dsAction(): Optional = + Optional.ofNullable(conditional3dsAction) + + fun conditionalAuthorizationAction(): + Optional = + Optional.ofNullable(conditionalAuthorizationAction) + + fun conditionalAchAction(): Optional = + Optional.ofNullable(conditionalAchAction) + + fun conditionalTokenizationAction(): Optional = + Optional.ofNullable(conditionalTokenizationAction) + + fun isConditionalBlock(): Boolean = conditionalBlock != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun isMerchantLock(): Boolean = merchantLock != null + + fun isConditional3dsAction(): Boolean = conditional3dsAction != null + + fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null + + fun isConditionalAchAction(): Boolean = conditionalAchAction != null + + fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null + + fun asConditionalBlock(): ConditionalBlockParameters = + conditionalBlock.getOrThrow("conditionalBlock") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") + + fun asConditional3dsAction(): Conditional3dsActionParameters = + conditional3dsAction.getOrThrow("conditional3dsAction") + + fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = + conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") + + fun asConditionalAchAction(): ConditionalAchActionParameters = + conditionalAchAction.getOrThrow("conditionalAchAction") + + fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = + conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + merchantLock != null -> visitor.visitMerchantLock(merchantLock) + conditional3dsAction != null -> + visitor.visitConditional3dsAction(conditional3dsAction) + conditionalAuthorizationAction != null -> + visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) + conditionalAchAction != null -> + visitor.visitConditionalAchAction(conditionalAchAction) + conditionalTokenizationAction != null -> + visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Parameters = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitConditionalBlock( + conditionalBlock: ConditionalBlockParameters + ) { + conditionalBlock.validate() + } + + override fun visitVelocityLimitParams( + velocityLimitParams: VelocityLimitParams + ) { + velocityLimitParams.validate() + } + + override fun visitMerchantLock(merchantLock: MerchantLockParameters) { + merchantLock.validate() + } + + override fun visitConditional3dsAction( + conditional3dsAction: Conditional3dsActionParameters + ) { + conditional3dsAction.validate() + } + + override fun visitConditionalAuthorizationAction( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ) { + conditionalAuthorizationAction.validate() + } + + override fun visitConditionalAchAction( + conditionalAchAction: ConditionalAchActionParameters + ) { + conditionalAchAction.validate() + } + + override fun visitConditionalTokenizationAction( + conditionalTokenizationAction: ConditionalTokenizationActionParameters + ) { + conditionalTokenizationAction.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitConditionalBlock( + conditionalBlock: ConditionalBlockParameters + ) = conditionalBlock.validity() + + override fun visitVelocityLimitParams( + velocityLimitParams: VelocityLimitParams + ) = velocityLimitParams.validity() + + override fun visitMerchantLock(merchantLock: MerchantLockParameters) = + merchantLock.validity() + + override fun visitConditional3dsAction( + conditional3dsAction: Conditional3dsActionParameters + ) = conditional3dsAction.validity() + + override fun visitConditionalAuthorizationAction( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ) = conditionalAuthorizationAction.validity() + + override fun visitConditionalAchAction( + conditionalAchAction: ConditionalAchActionParameters + ) = conditionalAchAction.validity() + + override fun visitConditionalTokenizationAction( + conditionalTokenizationAction: ConditionalTokenizationActionParameters + ) = conditionalTokenizationAction.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Parameters && + conditionalBlock == other.conditionalBlock && + velocityLimitParams == other.velocityLimitParams && + merchantLock == other.merchantLock && + conditional3dsAction == other.conditional3dsAction && + conditionalAuthorizationAction == other.conditionalAuthorizationAction && + conditionalAchAction == other.conditionalAchAction && + conditionalTokenizationAction == other.conditionalTokenizationAction + } + + override fun hashCode(): Int = + Objects.hash( + conditionalBlock, + velocityLimitParams, + merchantLock, + conditional3dsAction, + conditionalAuthorizationAction, + conditionalAchAction, + conditionalTokenizationAction, + ) + + override fun toString(): String = + when { + conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" + velocityLimitParams != null -> + "Parameters{velocityLimitParams=$velocityLimitParams}" + merchantLock != null -> "Parameters{merchantLock=$merchantLock}" + conditional3dsAction != null -> + "Parameters{conditional3dsAction=$conditional3dsAction}" + conditionalAuthorizationAction != null -> + "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" + conditionalAchAction != null -> + "Parameters{conditionalAchAction=$conditionalAchAction}" + conditionalTokenizationAction != null -> + "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" + _json != null -> "Parameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Parameters") + } + + companion object { + + @JvmStatic + fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = + Parameters(conditionalBlock = conditionalBlock) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + Parameters(velocityLimitParams = velocityLimitParams) + + @JvmStatic + fun ofMerchantLock(merchantLock: MerchantLockParameters) = + Parameters(merchantLock = merchantLock) + + @JvmStatic + fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = + Parameters(conditional3dsAction = conditional3dsAction) + + @JvmStatic + fun ofConditionalAuthorizationAction( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) + + @JvmStatic + fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = + Parameters(conditionalAchAction = conditionalAchAction) + + @JvmStatic + fun ofConditionalTokenizationAction( + conditionalTokenizationAction: ConditionalTokenizationActionParameters + ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) + } + + /** + * An interface that defines how to map each variant of [Parameters] to a value of type + * [T]. + */ + interface Visitor { + + fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun visitMerchantLock(merchantLock: MerchantLockParameters): T + + fun visitConditional3dsAction( + conditional3dsAction: Conditional3dsActionParameters + ): T + + fun visitConditionalAuthorizationAction( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ): T + + fun visitConditionalAchAction( + conditionalAchAction: ConditionalAchActionParameters + ): T + + fun visitConditionalTokenizationAction( + conditionalTokenizationAction: ConditionalTokenizationActionParameters + ): T + + /** + * Maps an unknown variant of [Parameters] to a value of type [T]. + * + * An instance of [Parameters] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Parameters: $json") + } + } + + internal class Deserializer : BaseDeserializer(Parameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Parameters { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Parameters(conditionalBlock = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Parameters(velocityLimitParams = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Parameters(merchantLock = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Parameters(conditional3dsAction = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Parameters( + conditionalAuthorizationAction = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Parameters(conditionalAchAction = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Parameters(conditionalTokenizationAction = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> Parameters(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Parameters::class) { + + override fun serialize( + value: Parameters, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.conditionalBlock != null -> + generator.writeObject(value.conditionalBlock) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value.merchantLock != null -> generator.writeObject(value.merchantLock) + value.conditional3dsAction != null -> + generator.writeObject(value.conditional3dsAction) + value.conditionalAuthorizationAction != null -> + generator.writeObject(value.conditionalAuthorizationAction) + value.conditionalAchAction != null -> + generator.writeObject(value.conditionalAchAction) + value.conditionalTokenizationAction != null -> + generator.writeObject(value.conditionalTokenizationAction) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Parameters") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CurrentVersion && + parameters == other.parameters && + version == other.version && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(parameters, version, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + } + + class DraftVersion + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val parameters: JsonField, + private val version: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("parameters") + @ExcludeMissing + parameters: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + ) : this(parameters, version, mutableMapOf()) + + /** + * Parameters for the Auth Rule + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun parameters(): Parameters = parameters.getRequired("parameters") + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * Returns the raw JSON value of [parameters]. + * + * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parameters") + @ExcludeMissing + fun _parameters(): JsonField = parameters + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + @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 [DraftVersion]. + * + * The following fields are required: + * ```java + * .parameters() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DraftVersion]. */ + class Builder internal constructor() { + + private var parameters: JsonField? = null + private var version: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(draftVersion: DraftVersion) = apply { + parameters = draftVersion.parameters + version = draftVersion.version + additionalProperties = draftVersion.additionalProperties.toMutableMap() + } + + /** Parameters for the Auth Rule */ + fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) + + /** + * Sets [Builder.parameters] to an arbitrary JSON value. + * + * You should usually call [Builder.parameters] with a well-typed [Parameters] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parameters(parameters: JsonField) = apply { + this.parameters = parameters + } + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalBlock(conditionalBlock)`. + */ + fun parameters(conditionalBlock: ConditionalBlockParameters) = + parameters(Parameters.ofConditionalBlock(conditionalBlock)) + + /** + * Alias for calling [parameters] with + * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. + */ + fun parameters(velocityLimitParams: VelocityLimitParams) = + parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) + + /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ + fun parameters(merchantLock: MerchantLockParameters) = + parameters(Parameters.ofMerchantLock(merchantLock)) + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditional3dsAction(conditional3dsAction)`. + */ + fun parameters(conditional3dsAction: Conditional3dsActionParameters) = + parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. + */ + fun parameters( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ) = + parameters( + Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) + ) + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchAction(conditionalAchAction)`. + */ + fun parameters(conditionalAchAction: ConditionalAchActionParameters) = + parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) + + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. + */ + fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = + parameters( + Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) + ) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + 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 [DraftVersion]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .parameters() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DraftVersion = + DraftVersion( + checkRequired("parameters", parameters), + checkRequired("version", version), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DraftVersion = apply { + if (validated) { + return@apply + } + + parameters().validate() + version() + 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 = + (parameters.asKnown().getOrNull()?.validity() ?: 0) + + (if (version.asKnown().isPresent) 1 else 0) + + /** Parameters for the Auth Rule */ + @JsonDeserialize(using = Parameters.Deserializer::class) + @JsonSerialize(using = Parameters.Serializer::class) + class Parameters + private constructor( + private val conditionalBlock: ConditionalBlockParameters? = null, + private val velocityLimitParams: VelocityLimitParams? = null, + private val merchantLock: MerchantLockParameters? = null, + private val conditional3dsAction: Conditional3dsActionParameters? = null, + private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = + null, + private val conditionalAchAction: ConditionalAchActionParameters? = null, + private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = + null, + private val _json: JsonValue? = null, + ) { + + fun conditionalBlock(): Optional = + Optional.ofNullable(conditionalBlock) + + fun velocityLimitParams(): Optional = + Optional.ofNullable(velocityLimitParams) + + fun merchantLock(): Optional = Optional.ofNullable(merchantLock) + + fun conditional3dsAction(): Optional = + Optional.ofNullable(conditional3dsAction) + + fun conditionalAuthorizationAction(): + Optional = + Optional.ofNullable(conditionalAuthorizationAction) + + fun conditionalAchAction(): Optional = + Optional.ofNullable(conditionalAchAction) + + fun conditionalTokenizationAction(): Optional = + Optional.ofNullable(conditionalTokenizationAction) + + fun isConditionalBlock(): Boolean = conditionalBlock != null + + fun isVelocityLimitParams(): Boolean = velocityLimitParams != null + + fun isMerchantLock(): Boolean = merchantLock != null + + fun isConditional3dsAction(): Boolean = conditional3dsAction != null + + fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null + + fun isConditionalAchAction(): Boolean = conditionalAchAction != null + + fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null + + fun asConditionalBlock(): ConditionalBlockParameters = + conditionalBlock.getOrThrow("conditionalBlock") + + fun asVelocityLimitParams(): VelocityLimitParams = + velocityLimitParams.getOrThrow("velocityLimitParams") + + fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") + + fun asConditional3dsAction(): Conditional3dsActionParameters = + conditional3dsAction.getOrThrow("conditional3dsAction") + + fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = + conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") + + fun asConditionalAchAction(): ConditionalAchActionParameters = + conditionalAchAction.getOrThrow("conditionalAchAction") + + fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = + conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) + velocityLimitParams != null -> + visitor.visitVelocityLimitParams(velocityLimitParams) + merchantLock != null -> visitor.visitMerchantLock(merchantLock) + conditional3dsAction != null -> + visitor.visitConditional3dsAction(conditional3dsAction) + conditionalAuthorizationAction != null -> + visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) + conditionalAchAction != null -> + visitor.visitConditionalAchAction(conditionalAchAction) + conditionalTokenizationAction != null -> + visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Parameters = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitConditionalBlock( + conditionalBlock: ConditionalBlockParameters + ) { + conditionalBlock.validate() + } + + override fun visitVelocityLimitParams( + velocityLimitParams: VelocityLimitParams + ) { + velocityLimitParams.validate() + } + + override fun visitMerchantLock(merchantLock: MerchantLockParameters) { + merchantLock.validate() + } + + override fun visitConditional3dsAction( + conditional3dsAction: Conditional3dsActionParameters + ) { + conditional3dsAction.validate() + } + + override fun visitConditionalAuthorizationAction( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ) { + conditionalAuthorizationAction.validate() + } + + override fun visitConditionalAchAction( + conditionalAchAction: ConditionalAchActionParameters + ) { + conditionalAchAction.validate() + } + + override fun visitConditionalTokenizationAction( + conditionalTokenizationAction: ConditionalTokenizationActionParameters + ) { + conditionalTokenizationAction.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitConditionalBlock( + conditionalBlock: ConditionalBlockParameters + ) = conditionalBlock.validity() + + override fun visitVelocityLimitParams( + velocityLimitParams: VelocityLimitParams + ) = velocityLimitParams.validity() + + override fun visitMerchantLock(merchantLock: MerchantLockParameters) = + merchantLock.validity() + + override fun visitConditional3dsAction( + conditional3dsAction: Conditional3dsActionParameters + ) = conditional3dsAction.validity() + + override fun visitConditionalAuthorizationAction( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ) = conditionalAuthorizationAction.validity() + + override fun visitConditionalAchAction( + conditionalAchAction: ConditionalAchActionParameters + ) = conditionalAchAction.validity() + + override fun visitConditionalTokenizationAction( + conditionalTokenizationAction: ConditionalTokenizationActionParameters + ) = conditionalTokenizationAction.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Parameters && + conditionalBlock == other.conditionalBlock && + velocityLimitParams == other.velocityLimitParams && + merchantLock == other.merchantLock && + conditional3dsAction == other.conditional3dsAction && + conditionalAuthorizationAction == other.conditionalAuthorizationAction && + conditionalAchAction == other.conditionalAchAction && + conditionalTokenizationAction == other.conditionalTokenizationAction + } + + override fun hashCode(): Int = + Objects.hash( + conditionalBlock, + velocityLimitParams, + merchantLock, + conditional3dsAction, + conditionalAuthorizationAction, + conditionalAchAction, + conditionalTokenizationAction, + ) + + override fun toString(): String = + when { + conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" + velocityLimitParams != null -> + "Parameters{velocityLimitParams=$velocityLimitParams}" + merchantLock != null -> "Parameters{merchantLock=$merchantLock}" + conditional3dsAction != null -> + "Parameters{conditional3dsAction=$conditional3dsAction}" + conditionalAuthorizationAction != null -> + "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" + conditionalAchAction != null -> + "Parameters{conditionalAchAction=$conditionalAchAction}" + conditionalTokenizationAction != null -> + "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" + _json != null -> "Parameters{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Parameters") + } + + companion object { + + @JvmStatic + fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = + Parameters(conditionalBlock = conditionalBlock) + + @JvmStatic + fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = + Parameters(velocityLimitParams = velocityLimitParams) + + @JvmStatic + fun ofMerchantLock(merchantLock: MerchantLockParameters) = + Parameters(merchantLock = merchantLock) + + @JvmStatic + fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = + Parameters(conditional3dsAction = conditional3dsAction) + + @JvmStatic + fun ofConditionalAuthorizationAction( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) + + @JvmStatic + fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = + Parameters(conditionalAchAction = conditionalAchAction) + + @JvmStatic + fun ofConditionalTokenizationAction( + conditionalTokenizationAction: ConditionalTokenizationActionParameters + ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) + } + + /** + * An interface that defines how to map each variant of [Parameters] to a value of type + * [T]. + */ + interface Visitor { + + fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T + + fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T + + fun visitMerchantLock(merchantLock: MerchantLockParameters): T + + fun visitConditional3dsAction( + conditional3dsAction: Conditional3dsActionParameters + ): T + + fun visitConditionalAuthorizationAction( + conditionalAuthorizationAction: ConditionalAuthorizationActionParameters + ): T + + fun visitConditionalAchAction( + conditionalAchAction: ConditionalAchActionParameters + ): T + + fun visitConditionalTokenizationAction( + conditionalTokenizationAction: ConditionalTokenizationActionParameters + ): T + + /** + * Maps an unknown variant of [Parameters] to a value of type [T]. + * + * An instance of [Parameters] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown Parameters: $json") + } + } + + internal class Deserializer : BaseDeserializer(Parameters::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Parameters { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Parameters(conditionalBlock = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Parameters(velocityLimitParams = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Parameters(merchantLock = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Parameters(conditional3dsAction = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Parameters( + conditionalAuthorizationAction = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { Parameters(conditionalAchAction = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Parameters(conditionalTokenizationAction = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> Parameters(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Parameters::class) { + + override fun serialize( + value: Parameters, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.conditionalBlock != null -> + generator.writeObject(value.conditionalBlock) + value.velocityLimitParams != null -> + generator.writeObject(value.velocityLimitParams) + value.merchantLock != null -> generator.writeObject(value.merchantLock) + value.conditional3dsAction != null -> + generator.writeObject(value.conditional3dsAction) + value.conditionalAuthorizationAction != null -> + generator.writeObject(value.conditionalAuthorizationAction) + value.conditionalAchAction != null -> + generator.writeObject(value.conditionalAchAction) + value.conditionalTokenizationAction != null -> + generator.writeObject(value.conditionalTokenizationAction) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Parameters") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftVersion && + parameters == other.parameters && + version == other.version && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(parameters, version, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" + } + + /** The event stream during which the rule will be evaluated. */ + class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") + + @JvmField val TOKENIZATION = of("TOKENIZATION") + + @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") + + @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") + + @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) + } + + /** An enum containing [EventStream]'s known values. */ + enum class Known { + AUTHORIZATION, + THREE_DS_AUTHENTICATION, + TOKENIZATION, + ACH_CREDIT_RECEIPT, + ACH_DEBIT_RECEIPT, + } + + /** + * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventStream] 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, + THREE_DS_AUTHENTICATION, + TOKENIZATION, + ACH_CREDIT_RECEIPT, + ACH_DEBIT_RECEIPT, + /** + * An enum member indicating that [EventStream] 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 + THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION + TOKENIZATION -> Value.TOKENIZATION + ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT + ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT + 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 + THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION + TOKENIZATION -> Known.TOKENIZATION + ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT + ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT + else -> throw LithicInvalidDataException("Unknown EventStream: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): EventStream = 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 EventStream && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The state of the Auth Rule */ + class AuthRuleState @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 ACTIVE = of("ACTIVE") + + @JvmField val INACTIVE = of("INACTIVE") + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + /** An enum containing [AuthRuleState]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthRuleState] 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 { + ACTIVE, + INACTIVE, + /** + * An enum member indicating that [AuthRuleState] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): AuthRuleState = 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 AuthRuleState && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The type of Auth Rule. For certain rule types, this determines the event stream during which + * it will be evaluated. For rules that can be applied to one of several event streams, the + * effective one is defined by the separate `event_stream` field. + * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. + * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. + * - `MERCHANT_LOCK`: AUTHORIZATION event stream. + * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, + * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. + */ + class AuthRuleType @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 CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK") + + @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT") + + @JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK") + + @JvmField val CONDITIONAL_ACTION = of("CONDITIONAL_ACTION") + + @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) + } + + /** An enum containing [AuthRuleType]'s known values. */ + enum class Known { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + MERCHANT_LOCK, + CONDITIONAL_ACTION, + } + + /** + * An enum containing [AuthRuleType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthRuleType] 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 { + CONDITIONAL_BLOCK, + VELOCITY_LIMIT, + MERCHANT_LOCK, + CONDITIONAL_ACTION, + /** + * An enum member indicating that [AuthRuleType] 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) { + CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Value.VELOCITY_LIMIT + MERCHANT_LOCK -> Value.MERCHANT_LOCK + CONDITIONAL_ACTION -> Value.CONDITIONAL_ACTION + 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) { + CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK + VELOCITY_LIMIT -> Known.VELOCITY_LIMIT + MERCHANT_LOCK -> Known.MERCHANT_LOCK + CONDITIONAL_ACTION -> Known.CONDITIONAL_ACTION + else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): AuthRuleType = 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 @@ -697,7 +2490,7 @@ private constructor( return true } - return other is State && value == other.value + return other is AuthRuleType && value == other.value } override fun hashCode() = value.hashCode() @@ -712,28 +2505,36 @@ private constructor( return other is AuthRule && token == other.token && - state == other.state && accountTokens == other.accountTokens && - allowedCountries == other.allowedCountries && - allowedMcc == other.allowedMcc && - blockedCountries == other.blockedCountries && - blockedMcc == other.blockedMcc && + businessAccountTokens == other.businessAccountTokens && cardTokens == other.cardTokens && + currentVersion == other.currentVersion && + draftVersion == other.draftVersion && + eventStream == other.eventStream && + lithicManaged == other.lithicManaged && + name == other.name && programLevel == other.programLevel && + state == other.state && + type == other.type && + excludedCardTokens == other.excludedCardTokens && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( token, - state, accountTokens, - allowedCountries, - allowedMcc, - blockedCountries, - blockedMcc, + businessAccountTokens, cardTokens, + currentVersion, + draftVersion, + eventStream, + lithicManaged, + name, programLevel, + state, + type, + excludedCardTokens, additionalProperties, ) } @@ -741,5 +2542,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AuthRule{token=$token, state=$state, accountTokens=$accountTokens, allowedCountries=$allowedCountries, allowedMcc=$allowedMcc, blockedCountries=$blockedCountries, blockedMcc=$blockedMcc, cardTokens=$cardTokens, programLevel=$programLevel, additionalProperties=$additionalProperties}" + "AuthRule{token=$token, accountTokens=$accountTokens, businessAccountTokens=$businessAccountTokens, cardTokens=$cardTokens, currentVersion=$currentVersion, draftVersion=$draftVersion, eventStream=$eventStream, lithicManaged=$lithicManaged, name=$name, programLevel=$programLevel, state=$state, type=$type, excludedCardTokens=$excludedCardTokens, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPage.kt index 9a66b12e3..fb7959ca8 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPage.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPage.kt @@ -16,15 +16,14 @@ private constructor( private val service: V2Service, private val params: AuthRuleV2ListParams, private val response: AuthRuleV2ListPageResponse, -) : Page { +) : Page { /** * Delegates to [AuthRuleV2ListPageResponse], but gracefully handles missing data. * * @see AuthRuleV2ListPageResponse.data */ - fun data(): List = - response._data().getOptional("data").getOrNull() ?: emptyList() + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** * Delegates to [AuthRuleV2ListPageResponse], but gracefully handles missing data. @@ -33,7 +32,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = items().isNotEmpty() @@ -46,7 +45,7 @@ private constructor( override fun nextPage(): AuthRuleV2ListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): AuthRuleV2ListParams = params diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageAsync.kt index 763193a75..def2b1bfc 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageAsync.kt @@ -19,15 +19,14 @@ private constructor( private val streamHandlerExecutor: Executor, private val params: AuthRuleV2ListParams, private val response: AuthRuleV2ListPageResponse, -) : PageAsync { +) : PageAsync { /** * Delegates to [AuthRuleV2ListPageResponse], but gracefully handles missing data. * * @see AuthRuleV2ListPageResponse.data */ - fun data(): List = - response._data().getOptional("data").getOrNull() ?: emptyList() + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** * Delegates to [AuthRuleV2ListPageResponse], but gracefully handles missing data. @@ -36,7 +35,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = items().isNotEmpty() @@ -50,8 +49,7 @@ private constructor( override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPagerAsync = - AutoPagerAsync.from(this, streamHandlerExecutor) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): AuthRuleV2ListParams = params diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponse.kt index bd4cd48ac..e9f95f3c1 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponse.kt @@ -21,16 +21,14 @@ import kotlin.jvm.optionals.getOrNull class AuthRuleV2ListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val data: JsonField>, + private val data: JsonField>, private val hasMore: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("data") - @ExcludeMissing - data: JsonField> = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), ) : this(data, hasMore, mutableMapOf()) @@ -38,7 +36,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 data(): List = data.getRequired("data") + fun data(): List = data.getRequired("data") /** * Indicates whether there are more Auth Rules to be retrieved by paging through the results. @@ -53,7 +51,7 @@ private constructor( * * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data /** * Returns the raw JSON value of [hasMore]. @@ -91,7 +89,7 @@ private constructor( /** A builder for [AuthRuleV2ListPageResponse]. */ class Builder internal constructor() { - private var data: JsonField>? = null + private var data: JsonField>? = null private var hasMore: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -102,25 +100,25 @@ private constructor( additionalProperties = authRuleV2ListPageResponse.additionalProperties.toMutableMap() } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) /** * Sets [Builder.data] to an arbitrary JSON value. * - * You should usually call [Builder.data] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.data] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } /** - * Adds a single [V2ListResponse] to [Builder.data]. + * Adds a single [AuthRule] to [Builder.data]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addData(data: V2ListResponse) = apply { + fun addData(data: AuthRule) = apply { this.data = (this.data ?: JsonField.of(mutableListOf())).also { checkKnown("data", it).add(data) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt index aea124353..485b9f183 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardProgram.kt @@ -24,11 +24,11 @@ class CardProgram @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, + private val accountLevelManagementEnabled: JsonField, private val created: JsonField, private val name: JsonField, private val panRangeEnd: JsonField, private val panRangeStart: JsonField, - private val accountLevelManagementEnabled: JsonField, private val cardholderCurrency: JsonField, private val settlementCurrencies: JsonField>, private val additionalProperties: MutableMap, @@ -37,6 +37,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_level_management_enabled") + @ExcludeMissing + accountLevelManagementEnabled: JsonField = JsonMissing.of(), @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), @@ -47,9 +50,6 @@ private constructor( @JsonProperty("pan_range_start") @ExcludeMissing panRangeStart: JsonField = JsonMissing.of(), - @JsonProperty("account_level_management_enabled") - @ExcludeMissing - accountLevelManagementEnabled: JsonField = JsonMissing.of(), @JsonProperty("cardholder_currency") @ExcludeMissing cardholderCurrency: JsonField = JsonMissing.of(), @@ -58,11 +58,11 @@ private constructor( settlementCurrencies: JsonField> = JsonMissing.of(), ) : this( token, + accountLevelManagementEnabled, created, name, panRangeEnd, panRangeStart, - accountLevelManagementEnabled, cardholderCurrency, settlementCurrencies, mutableMapOf(), @@ -76,6 +76,16 @@ private constructor( */ fun token(): String = token.getRequired("token") + /** + * Whether the card program is participating in Account Level Management. Currently applicable + * to Visa card programs only. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountLevelManagementEnabled(): Boolean = + accountLevelManagementEnabled.getRequired("account_level_management_enabled") + /** * Timestamp of when the card program was created. * @@ -108,16 +118,6 @@ private constructor( */ fun panRangeStart(): String = panRangeStart.getRequired("pan_range_start") - /** - * Whether the card program is participating in Account Level Management. Currently applicable - * to Visa card programs only. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun accountLevelManagementEnabled(): Optional = - accountLevelManagementEnabled.getOptional("account_level_management_enabled") - /** * 3-character alphabetic ISO 4217 code for the currency of the cardholder. * @@ -144,6 +144,16 @@ private constructor( */ @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + /** + * Returns the raw JSON value of [accountLevelManagementEnabled]. + * + * Unlike [accountLevelManagementEnabled], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("account_level_management_enabled") + @ExcludeMissing + fun _accountLevelManagementEnabled(): JsonField = accountLevelManagementEnabled + /** * Returns the raw JSON value of [created]. * @@ -176,16 +186,6 @@ private constructor( @ExcludeMissing fun _panRangeStart(): JsonField = panRangeStart - /** - * Returns the raw JSON value of [accountLevelManagementEnabled]. - * - * Unlike [accountLevelManagementEnabled], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("account_level_management_enabled") - @ExcludeMissing - fun _accountLevelManagementEnabled(): JsonField = accountLevelManagementEnabled - /** * Returns the raw JSON value of [cardholderCurrency]. * @@ -226,6 +226,7 @@ private constructor( * The following fields are required: * ```java * .token() + * .accountLevelManagementEnabled() * .created() * .name() * .panRangeEnd() @@ -239,11 +240,11 @@ private constructor( class Builder internal constructor() { private var token: JsonField? = null + private var accountLevelManagementEnabled: JsonField? = null private var created: JsonField? = null private var name: JsonField? = null private var panRangeEnd: JsonField? = null private var panRangeStart: JsonField? = null - private var accountLevelManagementEnabled: JsonField = JsonMissing.of() private var cardholderCurrency: JsonField = JsonMissing.of() private var settlementCurrencies: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -251,11 +252,11 @@ private constructor( @JvmSynthetic internal fun from(cardProgram: CardProgram) = apply { token = cardProgram.token + accountLevelManagementEnabled = cardProgram.accountLevelManagementEnabled created = cardProgram.created name = cardProgram.name panRangeEnd = cardProgram.panRangeEnd panRangeStart = cardProgram.panRangeStart - accountLevelManagementEnabled = cardProgram.accountLevelManagementEnabled cardholderCurrency = cardProgram.cardholderCurrency settlementCurrencies = cardProgram.settlementCurrencies.map { it.toMutableList() } additionalProperties = cardProgram.additionalProperties.toMutableMap() @@ -272,6 +273,25 @@ private constructor( */ fun token(token: JsonField) = apply { this.token = token } + /** + * Whether the card program is participating in Account Level Management. Currently + * applicable to Visa card programs only. + */ + fun accountLevelManagementEnabled(accountLevelManagementEnabled: Boolean) = + accountLevelManagementEnabled(JsonField.of(accountLevelManagementEnabled)) + + /** + * Sets [Builder.accountLevelManagementEnabled] to an arbitrary JSON value. + * + * You should usually call [Builder.accountLevelManagementEnabled] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accountLevelManagementEnabled(accountLevelManagementEnabled: JsonField) = + apply { + this.accountLevelManagementEnabled = accountLevelManagementEnabled + } + /** Timestamp of when the card program was created. */ fun created(created: OffsetDateTime) = created(JsonField.of(created)) @@ -321,25 +341,6 @@ private constructor( this.panRangeStart = panRangeStart } - /** - * Whether the card program is participating in Account Level Management. Currently - * applicable to Visa card programs only. - */ - fun accountLevelManagementEnabled(accountLevelManagementEnabled: Boolean) = - accountLevelManagementEnabled(JsonField.of(accountLevelManagementEnabled)) - - /** - * Sets [Builder.accountLevelManagementEnabled] to an arbitrary JSON value. - * - * You should usually call [Builder.accountLevelManagementEnabled] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accountLevelManagementEnabled(accountLevelManagementEnabled: JsonField) = - apply { - this.accountLevelManagementEnabled = accountLevelManagementEnabled - } - /** 3-character alphabetic ISO 4217 code for the currency of the cardholder. */ fun cardholderCurrency(cardholderCurrency: String) = cardholderCurrency(JsonField.of(cardholderCurrency)) @@ -412,6 +413,7 @@ private constructor( * The following fields are required: * ```java * .token() + * .accountLevelManagementEnabled() * .created() * .name() * .panRangeEnd() @@ -423,11 +425,11 @@ private constructor( fun build(): CardProgram = CardProgram( checkRequired("token", token), + checkRequired("accountLevelManagementEnabled", accountLevelManagementEnabled), checkRequired("created", created), checkRequired("name", name), checkRequired("panRangeEnd", panRangeEnd), checkRequired("panRangeStart", panRangeStart), - accountLevelManagementEnabled, cardholderCurrency, (settlementCurrencies ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), @@ -442,11 +444,11 @@ private constructor( } token() + accountLevelManagementEnabled() created() name() panRangeEnd() panRangeStart() - accountLevelManagementEnabled() cardholderCurrency() settlementCurrencies() validated = true @@ -468,11 +470,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (token.asKnown().isPresent) 1 else 0) + + (if (accountLevelManagementEnabled.asKnown().isPresent) 1 else 0) + (if (created.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (panRangeEnd.asKnown().isPresent) 1 else 0) + (if (panRangeStart.asKnown().isPresent) 1 else 0) + - (if (accountLevelManagementEnabled.asKnown().isPresent) 1 else 0) + (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + (settlementCurrencies.asKnown().getOrNull()?.size ?: 0) @@ -483,11 +485,11 @@ private constructor( return other is CardProgram && token == other.token && + accountLevelManagementEnabled == other.accountLevelManagementEnabled && created == other.created && name == other.name && panRangeEnd == other.panRangeEnd && panRangeStart == other.panRangeStart && - accountLevelManagementEnabled == other.accountLevelManagementEnabled && cardholderCurrency == other.cardholderCurrency && settlementCurrencies == other.settlementCurrencies && additionalProperties == other.additionalProperties @@ -496,11 +498,11 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( token, + accountLevelManagementEnabled, created, name, panRangeEnd, panRangeStart, - accountLevelManagementEnabled, cardholderCurrency, settlementCurrencies, additionalProperties, @@ -510,5 +512,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CardProgram{token=$token, created=$created, name=$name, panRangeEnd=$panRangeEnd, panRangeStart=$panRangeStart, accountLevelManagementEnabled=$accountLevelManagementEnabled, cardholderCurrency=$cardholderCurrency, settlementCurrencies=$settlementCurrencies, additionalProperties=$additionalProperties}" + "CardProgram{token=$token, accountLevelManagementEnabled=$accountLevelManagementEnabled, created=$created, name=$name, panRangeEnd=$panRangeEnd, panRangeStart=$panRangeStart, cardholderCurrency=$cardholderCurrency, settlementCurrencies=$settlementCurrencies, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalOperation.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalOperation.kt index 9f9139f14..0bfde670d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalOperation.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalOperation.kt @@ -42,6 +42,12 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J @JvmField val IS_LESS_THAN_OR_EQUAL_TO = of("IS_LESS_THAN_OR_EQUAL_TO") + @JvmField val CONTAINS_ANY = of("CONTAINS_ANY") + + @JvmField val CONTAINS_ALL = of("CONTAINS_ALL") + + @JvmField val CONTAINS_NONE = of("CONTAINS_NONE") + @JvmStatic fun of(value: String) = ConditionalOperation(JsonField.of(value)) } @@ -57,6 +63,9 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J IS_GREATER_THAN_OR_EQUAL_TO, IS_LESS_THAN, IS_LESS_THAN_OR_EQUAL_TO, + CONTAINS_ANY, + CONTAINS_ALL, + CONTAINS_NONE, } /** @@ -79,6 +88,9 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J IS_GREATER_THAN_OR_EQUAL_TO, IS_LESS_THAN, IS_LESS_THAN_OR_EQUAL_TO, + CONTAINS_ANY, + CONTAINS_ALL, + CONTAINS_NONE, /** * An enum member indicating that [ConditionalOperation] was instantiated with an unknown * value. @@ -105,6 +117,9 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J IS_GREATER_THAN_OR_EQUAL_TO -> Value.IS_GREATER_THAN_OR_EQUAL_TO IS_LESS_THAN -> Value.IS_LESS_THAN IS_LESS_THAN_OR_EQUAL_TO -> Value.IS_LESS_THAN_OR_EQUAL_TO + CONTAINS_ANY -> Value.CONTAINS_ANY + CONTAINS_ALL -> Value.CONTAINS_ALL + CONTAINS_NONE -> Value.CONTAINS_NONE else -> Value._UNKNOWN } @@ -128,6 +143,9 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J IS_GREATER_THAN_OR_EQUAL_TO -> Known.IS_GREATER_THAN_OR_EQUAL_TO IS_LESS_THAN -> Known.IS_LESS_THAN IS_LESS_THAN_OR_EQUAL_TO -> Known.IS_LESS_THAN_OR_EQUAL_TO + CONTAINS_ANY -> Known.CONTAINS_ANY + CONTAINS_ALL -> Known.CONTAINS_ALL + CONTAINS_NONE -> Known.CONTAINS_NONE else -> throw LithicInvalidDataException("Unknown ConditionalOperation: $value") } 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 b8d764a66..f0f1bdc5a 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 @@ -1512,6 +1512,13 @@ private constructor( * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). * * `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 + * provider for the recommended decision. Valid values are `ACCOUNT_CARD_TOO_NEW`, + * `ACCOUNT_RECENTLY_CHANGED`, `ACCOUNT_TOO_NEW`, `ACCOUNT_TOO_NEW_SINCE_LAUNCH`, + * `DEVICE_RECENTLY_LOST`, `HAS_SUSPENDED_TOKENS`, `HIGH_RISK`, `INACTIVE_ACCOUNT`, + * `LOW_ACCOUNT_SCORE`, `LOW_DEVICE_SCORE`, `OUTSIDE_HOME_TERRITORY`, + * `SUSPICIOUS_ACTIVITY`, `TOO_MANY_DIFFERENT_CARDHOLDERS`, `TOO_MANY_RECENT_ATTEMPTS`, + * `TOO_MANY_RECENT_TOKENS`, `UNABLE_TO_ASSESS`. * * `TOKEN_REQUESTOR_ID`: Unique identifier for the entity requesting the token. * * `WALLET_TOKEN_STATUS`: The current status of the wallet token. * @@ -1625,6 +1632,13 @@ private constructor( * risk). * * `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 + * provider for the recommended decision. Valid values are `ACCOUNT_CARD_TOO_NEW`, + * `ACCOUNT_RECENTLY_CHANGED`, `ACCOUNT_TOO_NEW`, `ACCOUNT_TOO_NEW_SINCE_LAUNCH`, + * `DEVICE_RECENTLY_LOST`, `HAS_SUSPENDED_TOKENS`, `HIGH_RISK`, `INACTIVE_ACCOUNT`, + * `LOW_ACCOUNT_SCORE`, `LOW_DEVICE_SCORE`, `OUTSIDE_HOME_TERRITORY`, + * `SUSPICIOUS_ACTIVITY`, `TOO_MANY_DIFFERENT_CARDHOLDERS`, + * `TOO_MANY_RECENT_ATTEMPTS`, `TOO_MANY_RECENT_TOKENS`, `UNABLE_TO_ASSESS`. * * `TOKEN_REQUESTOR_ID`: Unique identifier for the entity requesting the token. * * `WALLET_TOKEN_STATUS`: The current status of the wallet token. */ @@ -1768,6 +1782,13 @@ private constructor( * where lower numbers indicate higher risk (e.g., 1 = high risk, 2 = medium risk). * * `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 + * provider for the recommended decision. Valid values are `ACCOUNT_CARD_TOO_NEW`, + * `ACCOUNT_RECENTLY_CHANGED`, `ACCOUNT_TOO_NEW`, `ACCOUNT_TOO_NEW_SINCE_LAUNCH`, + * `DEVICE_RECENTLY_LOST`, `HAS_SUSPENDED_TOKENS`, `HIGH_RISK`, `INACTIVE_ACCOUNT`, + * `LOW_ACCOUNT_SCORE`, `LOW_DEVICE_SCORE`, `OUTSIDE_HOME_TERRITORY`, + * `SUSPICIOUS_ACTIVITY`, `TOO_MANY_DIFFERENT_CARDHOLDERS`, `TOO_MANY_RECENT_ATTEMPTS`, + * `TOO_MANY_RECENT_TOKENS`, `UNABLE_TO_ASSESS`. * * `TOKEN_REQUESTOR_ID`: Unique identifier for the entity requesting the token. * * `WALLET_TOKEN_STATUS`: The current status of the wallet token. */ @@ -1800,6 +1821,8 @@ private constructor( @JvmField val WALLET_RECOMMENDED_DECISION = of("WALLET_RECOMMENDED_DECISION") + @JvmField val WALLET_RECOMMENDATION_REASONS = of("WALLET_RECOMMENDATION_REASONS") + @JvmField val TOKEN_REQUESTOR_ID = of("TOKEN_REQUESTOR_ID") @JvmField val WALLET_TOKEN_STATUS = of("WALLET_TOKEN_STATUS") @@ -1816,6 +1839,7 @@ private constructor( WALLET_ACCOUNT_SCORE, WALLET_DEVICE_SCORE, WALLET_RECOMMENDED_DECISION, + WALLET_RECOMMENDATION_REASONS, TOKEN_REQUESTOR_ID, WALLET_TOKEN_STATUS, } @@ -1837,6 +1861,7 @@ private constructor( WALLET_ACCOUNT_SCORE, WALLET_DEVICE_SCORE, WALLET_RECOMMENDED_DECISION, + WALLET_RECOMMENDATION_REASONS, TOKEN_REQUESTOR_ID, WALLET_TOKEN_STATUS, /** @@ -1862,6 +1887,7 @@ private constructor( WALLET_ACCOUNT_SCORE -> Value.WALLET_ACCOUNT_SCORE WALLET_DEVICE_SCORE -> Value.WALLET_DEVICE_SCORE WALLET_RECOMMENDED_DECISION -> Value.WALLET_RECOMMENDED_DECISION + WALLET_RECOMMENDATION_REASONS -> Value.WALLET_RECOMMENDATION_REASONS TOKEN_REQUESTOR_ID -> Value.TOKEN_REQUESTOR_ID WALLET_TOKEN_STATUS -> Value.WALLET_TOKEN_STATUS else -> Value._UNKNOWN @@ -1885,6 +1911,7 @@ private constructor( WALLET_ACCOUNT_SCORE -> Known.WALLET_ACCOUNT_SCORE WALLET_DEVICE_SCORE -> Known.WALLET_DEVICE_SCORE WALLET_RECOMMENDED_DECISION -> Known.WALLET_RECOMMENDED_DECISION + WALLET_RECOMMENDATION_REASONS -> Known.WALLET_RECOMMENDATION_REASONS TOKEN_REQUESTOR_ID -> Known.TOKEN_REQUESTOR_ID WALLET_TOKEN_STATUS -> Known.WALLET_TOKEN_STATUS else -> throw LithicInvalidDataException("Unknown Attribute: $value") diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Statement.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Statement.kt index 1e695745c..de6ca12a0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Statement.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Statement.kt @@ -3233,31 +3233,31 @@ private constructor( /** * Number of months to full pay off * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun payoffPeriodLengthMonths(): Long = - payoffPeriodLengthMonths.getRequired("payoff_period_length_months") + fun payoffPeriodLengthMonths(): Optional = + payoffPeriodLengthMonths.getOptional("payoff_period_length_months") /** * The amount needed to be paid, in cents, each month in order to pay off current balance in * the payoff period * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun payoffPeriodMonthlyPaymentAmount(): Long = - payoffPeriodMonthlyPaymentAmount.getRequired("payoff_period_monthly_payment_amount") + fun payoffPeriodMonthlyPaymentAmount(): Optional = + payoffPeriodMonthlyPaymentAmount.getOptional("payoff_period_monthly_payment_amount") /** * The sum of all interest and principal paid, in cents, when paying off in the payoff * period * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun payoffPeriodPaymentTotal(): Long = - payoffPeriodPaymentTotal.getRequired("payoff_period_payment_total") + fun payoffPeriodPaymentTotal(): Optional = + payoffPeriodPaymentTotal.getOptional("payoff_period_payment_total") /** * Returns the raw JSON value of [minimumPaymentMonths]. @@ -3395,8 +3395,23 @@ private constructor( } /** Number of months to full pay off */ + fun payoffPeriodLengthMonths(payoffPeriodLengthMonths: Long?) = + payoffPeriodLengthMonths(JsonField.ofNullable(payoffPeriodLengthMonths)) + + /** + * Alias for [Builder.payoffPeriodLengthMonths]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun payoffPeriodLengthMonths(payoffPeriodLengthMonths: Long) = - payoffPeriodLengthMonths(JsonField.of(payoffPeriodLengthMonths)) + payoffPeriodLengthMonths(payoffPeriodLengthMonths as Long?) + + /** + * Alias for calling [Builder.payoffPeriodLengthMonths] with + * `payoffPeriodLengthMonths.orElse(null)`. + */ + fun payoffPeriodLengthMonths(payoffPeriodLengthMonths: Optional) = + payoffPeriodLengthMonths(payoffPeriodLengthMonths.getOrNull()) /** * Sets [Builder.payoffPeriodLengthMonths] to an arbitrary JSON value. @@ -3413,8 +3428,25 @@ private constructor( * The amount needed to be paid, in cents, each month in order to pay off current * balance in the payoff period */ + fun payoffPeriodMonthlyPaymentAmount(payoffPeriodMonthlyPaymentAmount: Long?) = + payoffPeriodMonthlyPaymentAmount( + JsonField.ofNullable(payoffPeriodMonthlyPaymentAmount) + ) + + /** + * Alias for [Builder.payoffPeriodMonthlyPaymentAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun payoffPeriodMonthlyPaymentAmount(payoffPeriodMonthlyPaymentAmount: Long) = - payoffPeriodMonthlyPaymentAmount(JsonField.of(payoffPeriodMonthlyPaymentAmount)) + payoffPeriodMonthlyPaymentAmount(payoffPeriodMonthlyPaymentAmount as Long?) + + /** + * Alias for calling [Builder.payoffPeriodMonthlyPaymentAmount] with + * `payoffPeriodMonthlyPaymentAmount.orElse(null)`. + */ + fun payoffPeriodMonthlyPaymentAmount(payoffPeriodMonthlyPaymentAmount: Optional) = + payoffPeriodMonthlyPaymentAmount(payoffPeriodMonthlyPaymentAmount.getOrNull()) /** * Sets [Builder.payoffPeriodMonthlyPaymentAmount] to an arbitrary JSON value. @@ -3431,8 +3463,23 @@ private constructor( * The sum of all interest and principal paid, in cents, when paying off in the payoff * period */ + fun payoffPeriodPaymentTotal(payoffPeriodPaymentTotal: Long?) = + payoffPeriodPaymentTotal(JsonField.ofNullable(payoffPeriodPaymentTotal)) + + /** + * Alias for [Builder.payoffPeriodPaymentTotal]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ fun payoffPeriodPaymentTotal(payoffPeriodPaymentTotal: Long) = - payoffPeriodPaymentTotal(JsonField.of(payoffPeriodPaymentTotal)) + payoffPeriodPaymentTotal(payoffPeriodPaymentTotal as Long?) + + /** + * Alias for calling [Builder.payoffPeriodPaymentTotal] with + * `payoffPeriodPaymentTotal.orElse(null)`. + */ + fun payoffPeriodPaymentTotal(payoffPeriodPaymentTotal: Optional) = + payoffPeriodPaymentTotal(payoffPeriodPaymentTotal.getOrNull()) /** * Sets [Builder.payoffPeriodPaymentTotal] to an arbitrary JSON value. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateResponse.kt deleted file mode 100644 index cc1eab0a4..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationSimulateResponse.kt +++ /dev/null @@ -1,178 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.lithic.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.lithic.api.core.ExcludeMissing -import com.lithic.api.core.JsonField -import com.lithic.api.core.JsonMissing -import com.lithic.api.core.JsonValue -import com.lithic.api.core.checkKnown -import com.lithic.api.core.toImmutable -import com.lithic.api.errors.LithicInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TokenizationSimulateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val data: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of() - ) : this(data, mutableMapOf()) - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional> = data.getOptional("data") - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data - - @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 [TokenizationSimulateResponse]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenizationSimulateResponse]. */ - class Builder internal constructor() { - - private var data: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tokenizationSimulateResponse: TokenizationSimulateResponse) = apply { - data = tokenizationSimulateResponse.data.map { it.toMutableList() } - additionalProperties = tokenizationSimulateResponse.additionalProperties.toMutableMap() - } - - fun data(data: List) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun data(data: JsonField>) = apply { - this.data = data.map { it.toMutableList() } - } - - /** - * Adds a single [Tokenization] to [Builder.data]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addData(data: Tokenization) = apply { - this.data = - (this.data ?: JsonField.of(mutableListOf())).also { - checkKnown("data", it).add(data) - } - } - - 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 [TokenizationSimulateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TokenizationSimulateResponse = - TokenizationSimulateResponse( - (data ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TokenizationSimulateResponse = apply { - if (validated) { - return@apply - } - - data().ifPresent { it.forEach { 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 = - (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenizationSimulateResponse && - data == other.data && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TokenizationSimulateResponse{data=$data, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponse.kt deleted file mode 100644 index 9e3ee81e4..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponse.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.lithic.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.lithic.api.core.ExcludeMissing -import com.lithic.api.core.JsonField -import com.lithic.api.core.JsonMissing -import com.lithic.api.core.JsonValue -import com.lithic.api.errors.LithicInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TokenizationUpdateDigitalCardArtResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val data: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of() - ) : this(data, mutableMapOf()) - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @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 - * [TokenizationUpdateDigitalCardArtResponse]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenizationUpdateDigitalCardArtResponse]. */ - class Builder internal constructor() { - - private var data: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - tokenizationUpdateDigitalCardArtResponse: TokenizationUpdateDigitalCardArtResponse - ) = apply { - data = tokenizationUpdateDigitalCardArtResponse.data - additionalProperties = - tokenizationUpdateDigitalCardArtResponse.additionalProperties.toMutableMap() - } - - fun data(data: Tokenization) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Tokenization] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun data(data: JsonField) = apply { this.data = data } - - 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 [TokenizationUpdateDigitalCardArtResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TokenizationUpdateDigitalCardArtResponse = - TokenizationUpdateDigitalCardArtResponse(data, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): TokenizationUpdateDigitalCardArtResponse = apply { - if (validated) { - return@apply - } - - data().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 = (data.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenizationUpdateDigitalCardArtResponse && - data == other.data && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TokenizationUpdateDigitalCardArtResponse{data=$data, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt deleted file mode 100644 index cecbac3ec..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2CreateResponse.kt +++ /dev/null @@ -1,2547 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.lithic.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.lithic.api.core.BaseDeserializer -import com.lithic.api.core.BaseSerializer -import com.lithic.api.core.Enum -import com.lithic.api.core.ExcludeMissing -import com.lithic.api.core.JsonField -import com.lithic.api.core.JsonMissing -import com.lithic.api.core.JsonValue -import com.lithic.api.core.allMaxBy -import com.lithic.api.core.checkKnown -import com.lithic.api.core.checkRequired -import com.lithic.api.core.getOrThrow -import com.lithic.api.core.toImmutable -import com.lithic.api.errors.LithicInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class V2CreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val accountTokens: JsonField>, - private val businessAccountTokens: JsonField>, - private val cardTokens: JsonField>, - private val currentVersion: JsonField, - private val draftVersion: JsonField, - private val eventStream: JsonField, - private val lithicManaged: JsonField, - private val name: JsonField, - private val programLevel: JsonField, - private val state: JsonField, - private val type: JsonField, - private val excludedCardTokens: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("account_tokens") - @ExcludeMissing - accountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("business_account_tokens") - @ExcludeMissing - businessAccountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("card_tokens") - @ExcludeMissing - cardTokens: JsonField> = JsonMissing.of(), - @JsonProperty("current_version") - @ExcludeMissing - currentVersion: JsonField = JsonMissing.of(), - @JsonProperty("draft_version") - @ExcludeMissing - draftVersion: JsonField = JsonMissing.of(), - @JsonProperty("event_stream") - @ExcludeMissing - eventStream: JsonField = JsonMissing.of(), - @JsonProperty("lithic_managed") - @ExcludeMissing - lithicManaged: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("program_level") - @ExcludeMissing - programLevel: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - excludedCardTokens: JsonField> = JsonMissing.of(), - ) : this( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - mutableMapOf(), - ) - - /** - * Auth Rule Token - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun token(): String = token.getRequired("token") - - /** - * Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accountTokens(): List = accountTokens.getRequired("account_tokens") - - /** - * Business Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun businessAccountTokens(): List = - businessAccountTokens.getRequired("business_account_tokens") - - /** - * Card tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cardTokens(): List = cardTokens.getRequired("card_tokens") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currentVersion(): Optional = currentVersion.getOptional("current_version") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun draftVersion(): Optional = draftVersion.getOptional("draft_version") - - /** - * The event stream during which the rule will be evaluated. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun eventStream(): EventStream = eventStream.getRequired("event_stream") - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be modified - * or deleted by the user - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lithicManaged(): Boolean = lithicManaged.getRequired("lithic_managed") - - /** - * Auth Rule Name - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Whether the Auth Rule applies to all authorizations on the card program. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun programLevel(): Boolean = programLevel.getRequired("program_level") - - /** - * The state of the Auth Rule - * - * @throws LithicInvalidDataException if 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(): AuthRuleState = state.getRequired("state") - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - * - * @throws LithicInvalidDataException if 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(): AuthRuleType = type.getRequired("type") - - /** - * Card tokens to which the Auth Rule does not apply. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun excludedCardTokens(): Optional> = - excludedCardTokens.getOptional("excluded_card_tokens") - - /** - * 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 [accountTokens]. - * - * Unlike [accountTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account_tokens") - @ExcludeMissing - fun _accountTokens(): JsonField> = accountTokens - - /** - * Returns the raw JSON value of [businessAccountTokens]. - * - * Unlike [businessAccountTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("business_account_tokens") - @ExcludeMissing - fun _businessAccountTokens(): JsonField> = businessAccountTokens - - /** - * Returns the raw JSON value of [cardTokens]. - * - * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("card_tokens") - @ExcludeMissing - fun _cardTokens(): JsonField> = cardTokens - - /** - * Returns the raw JSON value of [currentVersion]. - * - * Unlike [currentVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("current_version") - @ExcludeMissing - fun _currentVersion(): JsonField = currentVersion - - /** - * Returns the raw JSON value of [draftVersion]. - * - * Unlike [draftVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("draft_version") - @ExcludeMissing - fun _draftVersion(): JsonField = draftVersion - - /** - * Returns the raw JSON value of [eventStream]. - * - * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event_stream") - @ExcludeMissing - fun _eventStream(): JsonField = eventStream - - /** - * Returns the raw JSON value of [lithicManaged]. - * - * Unlike [lithicManaged], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lithic_managed") - @ExcludeMissing - fun _lithicManaged(): JsonField = lithicManaged - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [programLevel]. - * - * Unlike [programLevel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("program_level") - @ExcludeMissing - fun _programLevel(): JsonField = programLevel - - /** - * 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 - - /** - * Returns the raw JSON value of [excludedCardTokens]. - * - * Unlike [excludedCardTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - fun _excludedCardTokens(): JsonField> = excludedCardTokens - - @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 [V2CreateResponse]. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [V2CreateResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var accountTokens: JsonField>? = null - private var businessAccountTokens: JsonField>? = null - private var cardTokens: JsonField>? = null - private var currentVersion: JsonField? = null - private var draftVersion: JsonField? = null - private var eventStream: JsonField? = null - private var lithicManaged: JsonField? = null - private var name: JsonField? = null - private var programLevel: JsonField? = null - private var state: JsonField? = null - private var type: JsonField? = null - private var excludedCardTokens: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(v2CreateResponse: V2CreateResponse) = apply { - token = v2CreateResponse.token - accountTokens = v2CreateResponse.accountTokens.map { it.toMutableList() } - businessAccountTokens = - v2CreateResponse.businessAccountTokens.map { it.toMutableList() } - cardTokens = v2CreateResponse.cardTokens.map { it.toMutableList() } - currentVersion = v2CreateResponse.currentVersion - draftVersion = v2CreateResponse.draftVersion - eventStream = v2CreateResponse.eventStream - lithicManaged = v2CreateResponse.lithicManaged - name = v2CreateResponse.name - programLevel = v2CreateResponse.programLevel - state = v2CreateResponse.state - type = v2CreateResponse.type - excludedCardTokens = v2CreateResponse.excludedCardTokens.map { it.toMutableList() } - additionalProperties = v2CreateResponse.additionalProperties.toMutableMap() - } - - /** Auth Rule Token */ - 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 } - - /** Account tokens to which the Auth Rule applies. */ - fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) - - /** - * Sets [Builder.accountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.accountTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [accountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAccountToken(accountToken: String) = apply { - accountTokens = - (accountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("accountTokens", it).add(accountToken) - } - } - - /** Business Account tokens to which the Auth Rule applies. */ - fun businessAccountTokens(businessAccountTokens: List) = - businessAccountTokens(JsonField.of(businessAccountTokens)) - - /** - * Sets [Builder.businessAccountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.businessAccountTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun businessAccountTokens(businessAccountTokens: JsonField>) = apply { - this.businessAccountTokens = businessAccountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [businessAccountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBusinessAccountToken(businessAccountToken: String) = apply { - businessAccountTokens = - (businessAccountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("businessAccountTokens", it).add(businessAccountToken) - } - } - - /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) - - /** - * Sets [Builder.cardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.cardTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cardTokens(cardTokens: JsonField>) = apply { - this.cardTokens = cardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [cardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCardToken(cardToken: String) = apply { - cardTokens = - (cardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("cardTokens", it).add(cardToken) - } - } - - fun currentVersion(currentVersion: CurrentVersion?) = - currentVersion(JsonField.ofNullable(currentVersion)) - - /** Alias for calling [Builder.currentVersion] with `currentVersion.orElse(null)`. */ - fun currentVersion(currentVersion: Optional) = - currentVersion(currentVersion.getOrNull()) - - /** - * Sets [Builder.currentVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.currentVersion] with a well-typed [CurrentVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currentVersion(currentVersion: JsonField) = apply { - this.currentVersion = currentVersion - } - - fun draftVersion(draftVersion: DraftVersion?) = - draftVersion(JsonField.ofNullable(draftVersion)) - - /** Alias for calling [Builder.draftVersion] with `draftVersion.orElse(null)`. */ - fun draftVersion(draftVersion: Optional) = - draftVersion(draftVersion.getOrNull()) - - /** - * Sets [Builder.draftVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.draftVersion] with a well-typed [DraftVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun draftVersion(draftVersion: JsonField) = apply { - this.draftVersion = draftVersion - } - - /** The event stream during which the rule will be evaluated. */ - fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) - - /** - * Sets [Builder.eventStream] to an arbitrary JSON value. - * - * You should usually call [Builder.eventStream] with a well-typed [EventStream] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventStream(eventStream: JsonField) = apply { - this.eventStream = eventStream - } - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be - * modified or deleted by the user - */ - fun lithicManaged(lithicManaged: Boolean) = lithicManaged(JsonField.of(lithicManaged)) - - /** - * Sets [Builder.lithicManaged] to an arbitrary JSON value. - * - * You should usually call [Builder.lithicManaged] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lithicManaged(lithicManaged: JsonField) = apply { - this.lithicManaged = lithicManaged - } - - /** Auth Rule Name */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Whether the Auth Rule applies to all authorizations on the card program. */ - fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) - - /** - * Sets [Builder.programLevel] to an arbitrary JSON value. - * - * You should usually call [Builder.programLevel] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun programLevel(programLevel: JsonField) = apply { - this.programLevel = programLevel - } - - /** The state of the Auth Rule */ - fun state(state: AuthRuleState) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [AuthRuleState] 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 } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during - * which it will be evaluated. For rules that can be applied to one of several event - * streams, the effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - fun type(type: AuthRuleType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [AuthRuleType] 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 } - - /** Card tokens to which the Auth Rule does not apply. */ - fun excludedCardTokens(excludedCardTokens: List) = - excludedCardTokens(JsonField.of(excludedCardTokens)) - - /** - * Sets [Builder.excludedCardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.excludedCardTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [excludedCardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExcludedCardToken(excludedCardToken: String) = apply { - excludedCardTokens = - (excludedCardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("excludedCardTokens", it).add(excludedCardToken) - } - } - - 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 [V2CreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): V2CreateResponse = - V2CreateResponse( - checkRequired("token", token), - checkRequired("accountTokens", accountTokens).map { it.toImmutable() }, - checkRequired("businessAccountTokens", businessAccountTokens).map { - it.toImmutable() - }, - checkRequired("cardTokens", cardTokens).map { it.toImmutable() }, - checkRequired("currentVersion", currentVersion), - checkRequired("draftVersion", draftVersion), - checkRequired("eventStream", eventStream), - checkRequired("lithicManaged", lithicManaged), - checkRequired("name", name), - checkRequired("programLevel", programLevel), - checkRequired("state", state), - checkRequired("type", type), - (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): V2CreateResponse = apply { - if (validated) { - return@apply - } - - token() - accountTokens() - businessAccountTokens() - cardTokens() - currentVersion().ifPresent { it.validate() } - draftVersion().ifPresent { it.validate() } - eventStream().validate() - lithicManaged() - name() - programLevel() - state().validate() - type().validate() - excludedCardTokens() - 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) + - (accountTokens.asKnown().getOrNull()?.size ?: 0) + - (businessAccountTokens.asKnown().getOrNull()?.size ?: 0) + - (cardTokens.asKnown().getOrNull()?.size ?: 0) + - (currentVersion.asKnown().getOrNull()?.validity() ?: 0) + - (draftVersion.asKnown().getOrNull()?.validity() ?: 0) + - (eventStream.asKnown().getOrNull()?.validity() ?: 0) + - (if (lithicManaged.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (programLevel.asKnown().isPresent) 1 else 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (excludedCardTokens.asKnown().getOrNull()?.size ?: 0) - - class CurrentVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [CurrentVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CurrentVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(currentVersion: CurrentVersion) = apply { - parameters = currentVersion.parameters - version = currentVersion.version - additionalProperties = currentVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [CurrentVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CurrentVersion = - CurrentVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CurrentVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CurrentVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - class DraftVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [DraftVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draftVersion: DraftVersion) = apply { - parameters = draftVersion.parameters - version = draftVersion.version - additionalProperties = draftVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [DraftVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DraftVersion = - DraftVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DraftVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - /** The event stream during which the rule will be evaluated. */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The state of the Auth Rule */ - class AuthRuleState @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 ACTIVE = of("ACTIVE") - - @JvmField val INACTIVE = of("INACTIVE") - - @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) - } - - /** An enum containing [AuthRuleState]'s known values. */ - enum class Known { - ACTIVE, - INACTIVE, - } - - /** - * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleState] 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 { - ACTIVE, - INACTIVE, - /** - * An enum member indicating that [AuthRuleState] 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) { - ACTIVE -> Value.ACTIVE - INACTIVE -> Value.INACTIVE - 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) { - ACTIVE -> Known.ACTIVE - INACTIVE -> Known.INACTIVE - else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleState = 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 AuthRuleState && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - class AuthRuleType @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 CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK") - - @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT") - - @JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK") - - @JvmField val CONDITIONAL_ACTION = of("CONDITIONAL_ACTION") - - @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) - } - - /** An enum containing [AuthRuleType]'s known values. */ - enum class Known { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - } - - /** - * An enum containing [AuthRuleType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleType] 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 { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - /** - * An enum member indicating that [AuthRuleType] 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) { - CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Value.VELOCITY_LIMIT - MERCHANT_LOCK -> Value.MERCHANT_LOCK - CONDITIONAL_ACTION -> Value.CONDITIONAL_ACTION - 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) { - CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Known.VELOCITY_LIMIT - MERCHANT_LOCK -> Known.MERCHANT_LOCK - CONDITIONAL_ACTION -> Known.CONDITIONAL_ACTION - else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleType = 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 AuthRuleType && 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 V2CreateResponse && - token == other.token && - accountTokens == other.accountTokens && - businessAccountTokens == other.businessAccountTokens && - cardTokens == other.cardTokens && - currentVersion == other.currentVersion && - draftVersion == other.draftVersion && - eventStream == other.eventStream && - lithicManaged == other.lithicManaged && - name == other.name && - programLevel == other.programLevel && - state == other.state && - type == other.type && - excludedCardTokens == other.excludedCardTokens && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "V2CreateResponse{token=$token, accountTokens=$accountTokens, businessAccountTokens=$businessAccountTokens, cardTokens=$cardTokens, currentVersion=$currentVersion, draftVersion=$draftVersion, eventStream=$eventStream, lithicManaged=$lithicManaged, name=$name, programLevel=$programLevel, state=$state, type=$type, excludedCardTokens=$excludedCardTokens, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt deleted file mode 100644 index 990c9afef..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2DraftResponse.kt +++ /dev/null @@ -1,2546 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.lithic.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.lithic.api.core.BaseDeserializer -import com.lithic.api.core.BaseSerializer -import com.lithic.api.core.Enum -import com.lithic.api.core.ExcludeMissing -import com.lithic.api.core.JsonField -import com.lithic.api.core.JsonMissing -import com.lithic.api.core.JsonValue -import com.lithic.api.core.allMaxBy -import com.lithic.api.core.checkKnown -import com.lithic.api.core.checkRequired -import com.lithic.api.core.getOrThrow -import com.lithic.api.core.toImmutable -import com.lithic.api.errors.LithicInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class V2DraftResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val accountTokens: JsonField>, - private val businessAccountTokens: JsonField>, - private val cardTokens: JsonField>, - private val currentVersion: JsonField, - private val draftVersion: JsonField, - private val eventStream: JsonField, - private val lithicManaged: JsonField, - private val name: JsonField, - private val programLevel: JsonField, - private val state: JsonField, - private val type: JsonField, - private val excludedCardTokens: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("account_tokens") - @ExcludeMissing - accountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("business_account_tokens") - @ExcludeMissing - businessAccountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("card_tokens") - @ExcludeMissing - cardTokens: JsonField> = JsonMissing.of(), - @JsonProperty("current_version") - @ExcludeMissing - currentVersion: JsonField = JsonMissing.of(), - @JsonProperty("draft_version") - @ExcludeMissing - draftVersion: JsonField = JsonMissing.of(), - @JsonProperty("event_stream") - @ExcludeMissing - eventStream: JsonField = JsonMissing.of(), - @JsonProperty("lithic_managed") - @ExcludeMissing - lithicManaged: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("program_level") - @ExcludeMissing - programLevel: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - excludedCardTokens: JsonField> = JsonMissing.of(), - ) : this( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - mutableMapOf(), - ) - - /** - * Auth Rule Token - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun token(): String = token.getRequired("token") - - /** - * Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accountTokens(): List = accountTokens.getRequired("account_tokens") - - /** - * Business Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun businessAccountTokens(): List = - businessAccountTokens.getRequired("business_account_tokens") - - /** - * Card tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cardTokens(): List = cardTokens.getRequired("card_tokens") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currentVersion(): Optional = currentVersion.getOptional("current_version") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun draftVersion(): Optional = draftVersion.getOptional("draft_version") - - /** - * The event stream during which the rule will be evaluated. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun eventStream(): EventStream = eventStream.getRequired("event_stream") - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be modified - * or deleted by the user - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lithicManaged(): Boolean = lithicManaged.getRequired("lithic_managed") - - /** - * Auth Rule Name - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Whether the Auth Rule applies to all authorizations on the card program. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun programLevel(): Boolean = programLevel.getRequired("program_level") - - /** - * The state of the Auth Rule - * - * @throws LithicInvalidDataException if 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(): AuthRuleState = state.getRequired("state") - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - * - * @throws LithicInvalidDataException if 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(): AuthRuleType = type.getRequired("type") - - /** - * Card tokens to which the Auth Rule does not apply. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun excludedCardTokens(): Optional> = - excludedCardTokens.getOptional("excluded_card_tokens") - - /** - * 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 [accountTokens]. - * - * Unlike [accountTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account_tokens") - @ExcludeMissing - fun _accountTokens(): JsonField> = accountTokens - - /** - * Returns the raw JSON value of [businessAccountTokens]. - * - * Unlike [businessAccountTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("business_account_tokens") - @ExcludeMissing - fun _businessAccountTokens(): JsonField> = businessAccountTokens - - /** - * Returns the raw JSON value of [cardTokens]. - * - * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("card_tokens") - @ExcludeMissing - fun _cardTokens(): JsonField> = cardTokens - - /** - * Returns the raw JSON value of [currentVersion]. - * - * Unlike [currentVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("current_version") - @ExcludeMissing - fun _currentVersion(): JsonField = currentVersion - - /** - * Returns the raw JSON value of [draftVersion]. - * - * Unlike [draftVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("draft_version") - @ExcludeMissing - fun _draftVersion(): JsonField = draftVersion - - /** - * Returns the raw JSON value of [eventStream]. - * - * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event_stream") - @ExcludeMissing - fun _eventStream(): JsonField = eventStream - - /** - * Returns the raw JSON value of [lithicManaged]. - * - * Unlike [lithicManaged], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lithic_managed") - @ExcludeMissing - fun _lithicManaged(): JsonField = lithicManaged - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [programLevel]. - * - * Unlike [programLevel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("program_level") - @ExcludeMissing - fun _programLevel(): JsonField = programLevel - - /** - * 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 - - /** - * Returns the raw JSON value of [excludedCardTokens]. - * - * Unlike [excludedCardTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - fun _excludedCardTokens(): JsonField> = excludedCardTokens - - @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 [V2DraftResponse]. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [V2DraftResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var accountTokens: JsonField>? = null - private var businessAccountTokens: JsonField>? = null - private var cardTokens: JsonField>? = null - private var currentVersion: JsonField? = null - private var draftVersion: JsonField? = null - private var eventStream: JsonField? = null - private var lithicManaged: JsonField? = null - private var name: JsonField? = null - private var programLevel: JsonField? = null - private var state: JsonField? = null - private var type: JsonField? = null - private var excludedCardTokens: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(v2DraftResponse: V2DraftResponse) = apply { - token = v2DraftResponse.token - accountTokens = v2DraftResponse.accountTokens.map { it.toMutableList() } - businessAccountTokens = v2DraftResponse.businessAccountTokens.map { it.toMutableList() } - cardTokens = v2DraftResponse.cardTokens.map { it.toMutableList() } - currentVersion = v2DraftResponse.currentVersion - draftVersion = v2DraftResponse.draftVersion - eventStream = v2DraftResponse.eventStream - lithicManaged = v2DraftResponse.lithicManaged - name = v2DraftResponse.name - programLevel = v2DraftResponse.programLevel - state = v2DraftResponse.state - type = v2DraftResponse.type - excludedCardTokens = v2DraftResponse.excludedCardTokens.map { it.toMutableList() } - additionalProperties = v2DraftResponse.additionalProperties.toMutableMap() - } - - /** Auth Rule Token */ - 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 } - - /** Account tokens to which the Auth Rule applies. */ - fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) - - /** - * Sets [Builder.accountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.accountTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [accountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAccountToken(accountToken: String) = apply { - accountTokens = - (accountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("accountTokens", it).add(accountToken) - } - } - - /** Business Account tokens to which the Auth Rule applies. */ - fun businessAccountTokens(businessAccountTokens: List) = - businessAccountTokens(JsonField.of(businessAccountTokens)) - - /** - * Sets [Builder.businessAccountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.businessAccountTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun businessAccountTokens(businessAccountTokens: JsonField>) = apply { - this.businessAccountTokens = businessAccountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [businessAccountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBusinessAccountToken(businessAccountToken: String) = apply { - businessAccountTokens = - (businessAccountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("businessAccountTokens", it).add(businessAccountToken) - } - } - - /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) - - /** - * Sets [Builder.cardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.cardTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cardTokens(cardTokens: JsonField>) = apply { - this.cardTokens = cardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [cardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCardToken(cardToken: String) = apply { - cardTokens = - (cardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("cardTokens", it).add(cardToken) - } - } - - fun currentVersion(currentVersion: CurrentVersion?) = - currentVersion(JsonField.ofNullable(currentVersion)) - - /** Alias for calling [Builder.currentVersion] with `currentVersion.orElse(null)`. */ - fun currentVersion(currentVersion: Optional) = - currentVersion(currentVersion.getOrNull()) - - /** - * Sets [Builder.currentVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.currentVersion] with a well-typed [CurrentVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currentVersion(currentVersion: JsonField) = apply { - this.currentVersion = currentVersion - } - - fun draftVersion(draftVersion: DraftVersion?) = - draftVersion(JsonField.ofNullable(draftVersion)) - - /** Alias for calling [Builder.draftVersion] with `draftVersion.orElse(null)`. */ - fun draftVersion(draftVersion: Optional) = - draftVersion(draftVersion.getOrNull()) - - /** - * Sets [Builder.draftVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.draftVersion] with a well-typed [DraftVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun draftVersion(draftVersion: JsonField) = apply { - this.draftVersion = draftVersion - } - - /** The event stream during which the rule will be evaluated. */ - fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) - - /** - * Sets [Builder.eventStream] to an arbitrary JSON value. - * - * You should usually call [Builder.eventStream] with a well-typed [EventStream] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventStream(eventStream: JsonField) = apply { - this.eventStream = eventStream - } - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be - * modified or deleted by the user - */ - fun lithicManaged(lithicManaged: Boolean) = lithicManaged(JsonField.of(lithicManaged)) - - /** - * Sets [Builder.lithicManaged] to an arbitrary JSON value. - * - * You should usually call [Builder.lithicManaged] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lithicManaged(lithicManaged: JsonField) = apply { - this.lithicManaged = lithicManaged - } - - /** Auth Rule Name */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Whether the Auth Rule applies to all authorizations on the card program. */ - fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) - - /** - * Sets [Builder.programLevel] to an arbitrary JSON value. - * - * You should usually call [Builder.programLevel] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun programLevel(programLevel: JsonField) = apply { - this.programLevel = programLevel - } - - /** The state of the Auth Rule */ - fun state(state: AuthRuleState) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [AuthRuleState] 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 } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during - * which it will be evaluated. For rules that can be applied to one of several event - * streams, the effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - fun type(type: AuthRuleType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [AuthRuleType] 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 } - - /** Card tokens to which the Auth Rule does not apply. */ - fun excludedCardTokens(excludedCardTokens: List) = - excludedCardTokens(JsonField.of(excludedCardTokens)) - - /** - * Sets [Builder.excludedCardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.excludedCardTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [excludedCardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExcludedCardToken(excludedCardToken: String) = apply { - excludedCardTokens = - (excludedCardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("excludedCardTokens", it).add(excludedCardToken) - } - } - - 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 [V2DraftResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): V2DraftResponse = - V2DraftResponse( - checkRequired("token", token), - checkRequired("accountTokens", accountTokens).map { it.toImmutable() }, - checkRequired("businessAccountTokens", businessAccountTokens).map { - it.toImmutable() - }, - checkRequired("cardTokens", cardTokens).map { it.toImmutable() }, - checkRequired("currentVersion", currentVersion), - checkRequired("draftVersion", draftVersion), - checkRequired("eventStream", eventStream), - checkRequired("lithicManaged", lithicManaged), - checkRequired("name", name), - checkRequired("programLevel", programLevel), - checkRequired("state", state), - checkRequired("type", type), - (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): V2DraftResponse = apply { - if (validated) { - return@apply - } - - token() - accountTokens() - businessAccountTokens() - cardTokens() - currentVersion().ifPresent { it.validate() } - draftVersion().ifPresent { it.validate() } - eventStream().validate() - lithicManaged() - name() - programLevel() - state().validate() - type().validate() - excludedCardTokens() - 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) + - (accountTokens.asKnown().getOrNull()?.size ?: 0) + - (businessAccountTokens.asKnown().getOrNull()?.size ?: 0) + - (cardTokens.asKnown().getOrNull()?.size ?: 0) + - (currentVersion.asKnown().getOrNull()?.validity() ?: 0) + - (draftVersion.asKnown().getOrNull()?.validity() ?: 0) + - (eventStream.asKnown().getOrNull()?.validity() ?: 0) + - (if (lithicManaged.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (programLevel.asKnown().isPresent) 1 else 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (excludedCardTokens.asKnown().getOrNull()?.size ?: 0) - - class CurrentVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [CurrentVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CurrentVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(currentVersion: CurrentVersion) = apply { - parameters = currentVersion.parameters - version = currentVersion.version - additionalProperties = currentVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [CurrentVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CurrentVersion = - CurrentVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CurrentVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CurrentVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - class DraftVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [DraftVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draftVersion: DraftVersion) = apply { - parameters = draftVersion.parameters - version = draftVersion.version - additionalProperties = draftVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [DraftVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DraftVersion = - DraftVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DraftVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - /** The event stream during which the rule will be evaluated. */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The state of the Auth Rule */ - class AuthRuleState @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 ACTIVE = of("ACTIVE") - - @JvmField val INACTIVE = of("INACTIVE") - - @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) - } - - /** An enum containing [AuthRuleState]'s known values. */ - enum class Known { - ACTIVE, - INACTIVE, - } - - /** - * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleState] 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 { - ACTIVE, - INACTIVE, - /** - * An enum member indicating that [AuthRuleState] 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) { - ACTIVE -> Value.ACTIVE - INACTIVE -> Value.INACTIVE - 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) { - ACTIVE -> Known.ACTIVE - INACTIVE -> Known.INACTIVE - else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleState = 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 AuthRuleState && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - class AuthRuleType @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 CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK") - - @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT") - - @JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK") - - @JvmField val CONDITIONAL_ACTION = of("CONDITIONAL_ACTION") - - @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) - } - - /** An enum containing [AuthRuleType]'s known values. */ - enum class Known { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - } - - /** - * An enum containing [AuthRuleType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleType] 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 { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - /** - * An enum member indicating that [AuthRuleType] 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) { - CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Value.VELOCITY_LIMIT - MERCHANT_LOCK -> Value.MERCHANT_LOCK - CONDITIONAL_ACTION -> Value.CONDITIONAL_ACTION - 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) { - CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Known.VELOCITY_LIMIT - MERCHANT_LOCK -> Known.MERCHANT_LOCK - CONDITIONAL_ACTION -> Known.CONDITIONAL_ACTION - else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleType = 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 AuthRuleType && 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 V2DraftResponse && - token == other.token && - accountTokens == other.accountTokens && - businessAccountTokens == other.businessAccountTokens && - cardTokens == other.cardTokens && - currentVersion == other.currentVersion && - draftVersion == other.draftVersion && - eventStream == other.eventStream && - lithicManaged == other.lithicManaged && - name == other.name && - programLevel == other.programLevel && - state == other.state && - type == other.type && - excludedCardTokens == other.excludedCardTokens && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "V2DraftResponse{token=$token, accountTokens=$accountTokens, businessAccountTokens=$businessAccountTokens, cardTokens=$cardTokens, currentVersion=$currentVersion, draftVersion=$draftVersion, eventStream=$eventStream, lithicManaged=$lithicManaged, name=$name, programLevel=$programLevel, state=$state, type=$type, excludedCardTokens=$excludedCardTokens, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt deleted file mode 100644 index 5b695d862..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResponse.kt +++ /dev/null @@ -1,2546 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.lithic.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.lithic.api.core.BaseDeserializer -import com.lithic.api.core.BaseSerializer -import com.lithic.api.core.Enum -import com.lithic.api.core.ExcludeMissing -import com.lithic.api.core.JsonField -import com.lithic.api.core.JsonMissing -import com.lithic.api.core.JsonValue -import com.lithic.api.core.allMaxBy -import com.lithic.api.core.checkKnown -import com.lithic.api.core.checkRequired -import com.lithic.api.core.getOrThrow -import com.lithic.api.core.toImmutable -import com.lithic.api.errors.LithicInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class V2ListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val accountTokens: JsonField>, - private val businessAccountTokens: JsonField>, - private val cardTokens: JsonField>, - private val currentVersion: JsonField, - private val draftVersion: JsonField, - private val eventStream: JsonField, - private val lithicManaged: JsonField, - private val name: JsonField, - private val programLevel: JsonField, - private val state: JsonField, - private val type: JsonField, - private val excludedCardTokens: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("account_tokens") - @ExcludeMissing - accountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("business_account_tokens") - @ExcludeMissing - businessAccountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("card_tokens") - @ExcludeMissing - cardTokens: JsonField> = JsonMissing.of(), - @JsonProperty("current_version") - @ExcludeMissing - currentVersion: JsonField = JsonMissing.of(), - @JsonProperty("draft_version") - @ExcludeMissing - draftVersion: JsonField = JsonMissing.of(), - @JsonProperty("event_stream") - @ExcludeMissing - eventStream: JsonField = JsonMissing.of(), - @JsonProperty("lithic_managed") - @ExcludeMissing - lithicManaged: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("program_level") - @ExcludeMissing - programLevel: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - excludedCardTokens: JsonField> = JsonMissing.of(), - ) : this( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - mutableMapOf(), - ) - - /** - * Auth Rule Token - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun token(): String = token.getRequired("token") - - /** - * Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accountTokens(): List = accountTokens.getRequired("account_tokens") - - /** - * Business Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun businessAccountTokens(): List = - businessAccountTokens.getRequired("business_account_tokens") - - /** - * Card tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cardTokens(): List = cardTokens.getRequired("card_tokens") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currentVersion(): Optional = currentVersion.getOptional("current_version") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun draftVersion(): Optional = draftVersion.getOptional("draft_version") - - /** - * The event stream during which the rule will be evaluated. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun eventStream(): EventStream = eventStream.getRequired("event_stream") - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be modified - * or deleted by the user - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lithicManaged(): Boolean = lithicManaged.getRequired("lithic_managed") - - /** - * Auth Rule Name - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Whether the Auth Rule applies to all authorizations on the card program. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun programLevel(): Boolean = programLevel.getRequired("program_level") - - /** - * The state of the Auth Rule - * - * @throws LithicInvalidDataException if 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(): AuthRuleState = state.getRequired("state") - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - * - * @throws LithicInvalidDataException if 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(): AuthRuleType = type.getRequired("type") - - /** - * Card tokens to which the Auth Rule does not apply. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun excludedCardTokens(): Optional> = - excludedCardTokens.getOptional("excluded_card_tokens") - - /** - * 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 [accountTokens]. - * - * Unlike [accountTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account_tokens") - @ExcludeMissing - fun _accountTokens(): JsonField> = accountTokens - - /** - * Returns the raw JSON value of [businessAccountTokens]. - * - * Unlike [businessAccountTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("business_account_tokens") - @ExcludeMissing - fun _businessAccountTokens(): JsonField> = businessAccountTokens - - /** - * Returns the raw JSON value of [cardTokens]. - * - * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("card_tokens") - @ExcludeMissing - fun _cardTokens(): JsonField> = cardTokens - - /** - * Returns the raw JSON value of [currentVersion]. - * - * Unlike [currentVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("current_version") - @ExcludeMissing - fun _currentVersion(): JsonField = currentVersion - - /** - * Returns the raw JSON value of [draftVersion]. - * - * Unlike [draftVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("draft_version") - @ExcludeMissing - fun _draftVersion(): JsonField = draftVersion - - /** - * Returns the raw JSON value of [eventStream]. - * - * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event_stream") - @ExcludeMissing - fun _eventStream(): JsonField = eventStream - - /** - * Returns the raw JSON value of [lithicManaged]. - * - * Unlike [lithicManaged], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lithic_managed") - @ExcludeMissing - fun _lithicManaged(): JsonField = lithicManaged - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [programLevel]. - * - * Unlike [programLevel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("program_level") - @ExcludeMissing - fun _programLevel(): JsonField = programLevel - - /** - * 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 - - /** - * Returns the raw JSON value of [excludedCardTokens]. - * - * Unlike [excludedCardTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - fun _excludedCardTokens(): JsonField> = excludedCardTokens - - @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 [V2ListResponse]. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [V2ListResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var accountTokens: JsonField>? = null - private var businessAccountTokens: JsonField>? = null - private var cardTokens: JsonField>? = null - private var currentVersion: JsonField? = null - private var draftVersion: JsonField? = null - private var eventStream: JsonField? = null - private var lithicManaged: JsonField? = null - private var name: JsonField? = null - private var programLevel: JsonField? = null - private var state: JsonField? = null - private var type: JsonField? = null - private var excludedCardTokens: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(v2ListResponse: V2ListResponse) = apply { - token = v2ListResponse.token - accountTokens = v2ListResponse.accountTokens.map { it.toMutableList() } - businessAccountTokens = v2ListResponse.businessAccountTokens.map { it.toMutableList() } - cardTokens = v2ListResponse.cardTokens.map { it.toMutableList() } - currentVersion = v2ListResponse.currentVersion - draftVersion = v2ListResponse.draftVersion - eventStream = v2ListResponse.eventStream - lithicManaged = v2ListResponse.lithicManaged - name = v2ListResponse.name - programLevel = v2ListResponse.programLevel - state = v2ListResponse.state - type = v2ListResponse.type - excludedCardTokens = v2ListResponse.excludedCardTokens.map { it.toMutableList() } - additionalProperties = v2ListResponse.additionalProperties.toMutableMap() - } - - /** Auth Rule Token */ - 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 } - - /** Account tokens to which the Auth Rule applies. */ - fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) - - /** - * Sets [Builder.accountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.accountTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [accountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAccountToken(accountToken: String) = apply { - accountTokens = - (accountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("accountTokens", it).add(accountToken) - } - } - - /** Business Account tokens to which the Auth Rule applies. */ - fun businessAccountTokens(businessAccountTokens: List) = - businessAccountTokens(JsonField.of(businessAccountTokens)) - - /** - * Sets [Builder.businessAccountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.businessAccountTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun businessAccountTokens(businessAccountTokens: JsonField>) = apply { - this.businessAccountTokens = businessAccountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [businessAccountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBusinessAccountToken(businessAccountToken: String) = apply { - businessAccountTokens = - (businessAccountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("businessAccountTokens", it).add(businessAccountToken) - } - } - - /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) - - /** - * Sets [Builder.cardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.cardTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cardTokens(cardTokens: JsonField>) = apply { - this.cardTokens = cardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [cardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCardToken(cardToken: String) = apply { - cardTokens = - (cardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("cardTokens", it).add(cardToken) - } - } - - fun currentVersion(currentVersion: CurrentVersion?) = - currentVersion(JsonField.ofNullable(currentVersion)) - - /** Alias for calling [Builder.currentVersion] with `currentVersion.orElse(null)`. */ - fun currentVersion(currentVersion: Optional) = - currentVersion(currentVersion.getOrNull()) - - /** - * Sets [Builder.currentVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.currentVersion] with a well-typed [CurrentVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currentVersion(currentVersion: JsonField) = apply { - this.currentVersion = currentVersion - } - - fun draftVersion(draftVersion: DraftVersion?) = - draftVersion(JsonField.ofNullable(draftVersion)) - - /** Alias for calling [Builder.draftVersion] with `draftVersion.orElse(null)`. */ - fun draftVersion(draftVersion: Optional) = - draftVersion(draftVersion.getOrNull()) - - /** - * Sets [Builder.draftVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.draftVersion] with a well-typed [DraftVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun draftVersion(draftVersion: JsonField) = apply { - this.draftVersion = draftVersion - } - - /** The event stream during which the rule will be evaluated. */ - fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) - - /** - * Sets [Builder.eventStream] to an arbitrary JSON value. - * - * You should usually call [Builder.eventStream] with a well-typed [EventStream] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventStream(eventStream: JsonField) = apply { - this.eventStream = eventStream - } - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be - * modified or deleted by the user - */ - fun lithicManaged(lithicManaged: Boolean) = lithicManaged(JsonField.of(lithicManaged)) - - /** - * Sets [Builder.lithicManaged] to an arbitrary JSON value. - * - * You should usually call [Builder.lithicManaged] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lithicManaged(lithicManaged: JsonField) = apply { - this.lithicManaged = lithicManaged - } - - /** Auth Rule Name */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Whether the Auth Rule applies to all authorizations on the card program. */ - fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) - - /** - * Sets [Builder.programLevel] to an arbitrary JSON value. - * - * You should usually call [Builder.programLevel] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun programLevel(programLevel: JsonField) = apply { - this.programLevel = programLevel - } - - /** The state of the Auth Rule */ - fun state(state: AuthRuleState) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [AuthRuleState] 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 } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during - * which it will be evaluated. For rules that can be applied to one of several event - * streams, the effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - fun type(type: AuthRuleType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [AuthRuleType] 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 } - - /** Card tokens to which the Auth Rule does not apply. */ - fun excludedCardTokens(excludedCardTokens: List) = - excludedCardTokens(JsonField.of(excludedCardTokens)) - - /** - * Sets [Builder.excludedCardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.excludedCardTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [excludedCardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExcludedCardToken(excludedCardToken: String) = apply { - excludedCardTokens = - (excludedCardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("excludedCardTokens", it).add(excludedCardToken) - } - } - - 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 [V2ListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): V2ListResponse = - V2ListResponse( - checkRequired("token", token), - checkRequired("accountTokens", accountTokens).map { it.toImmutable() }, - checkRequired("businessAccountTokens", businessAccountTokens).map { - it.toImmutable() - }, - checkRequired("cardTokens", cardTokens).map { it.toImmutable() }, - checkRequired("currentVersion", currentVersion), - checkRequired("draftVersion", draftVersion), - checkRequired("eventStream", eventStream), - checkRequired("lithicManaged", lithicManaged), - checkRequired("name", name), - checkRequired("programLevel", programLevel), - checkRequired("state", state), - checkRequired("type", type), - (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): V2ListResponse = apply { - if (validated) { - return@apply - } - - token() - accountTokens() - businessAccountTokens() - cardTokens() - currentVersion().ifPresent { it.validate() } - draftVersion().ifPresent { it.validate() } - eventStream().validate() - lithicManaged() - name() - programLevel() - state().validate() - type().validate() - excludedCardTokens() - 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) + - (accountTokens.asKnown().getOrNull()?.size ?: 0) + - (businessAccountTokens.asKnown().getOrNull()?.size ?: 0) + - (cardTokens.asKnown().getOrNull()?.size ?: 0) + - (currentVersion.asKnown().getOrNull()?.validity() ?: 0) + - (draftVersion.asKnown().getOrNull()?.validity() ?: 0) + - (eventStream.asKnown().getOrNull()?.validity() ?: 0) + - (if (lithicManaged.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (programLevel.asKnown().isPresent) 1 else 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (excludedCardTokens.asKnown().getOrNull()?.size ?: 0) - - class CurrentVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [CurrentVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CurrentVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(currentVersion: CurrentVersion) = apply { - parameters = currentVersion.parameters - version = currentVersion.version - additionalProperties = currentVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [CurrentVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CurrentVersion = - CurrentVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CurrentVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CurrentVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - class DraftVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [DraftVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draftVersion: DraftVersion) = apply { - parameters = draftVersion.parameters - version = draftVersion.version - additionalProperties = draftVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [DraftVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DraftVersion = - DraftVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DraftVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - /** The event stream during which the rule will be evaluated. */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The state of the Auth Rule */ - class AuthRuleState @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 ACTIVE = of("ACTIVE") - - @JvmField val INACTIVE = of("INACTIVE") - - @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) - } - - /** An enum containing [AuthRuleState]'s known values. */ - enum class Known { - ACTIVE, - INACTIVE, - } - - /** - * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleState] 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 { - ACTIVE, - INACTIVE, - /** - * An enum member indicating that [AuthRuleState] 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) { - ACTIVE -> Value.ACTIVE - INACTIVE -> Value.INACTIVE - 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) { - ACTIVE -> Known.ACTIVE - INACTIVE -> Known.INACTIVE - else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleState = 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 AuthRuleState && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - class AuthRuleType @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 CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK") - - @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT") - - @JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK") - - @JvmField val CONDITIONAL_ACTION = of("CONDITIONAL_ACTION") - - @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) - } - - /** An enum containing [AuthRuleType]'s known values. */ - enum class Known { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - } - - /** - * An enum containing [AuthRuleType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleType] 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 { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - /** - * An enum member indicating that [AuthRuleType] 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) { - CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Value.VELOCITY_LIMIT - MERCHANT_LOCK -> Value.MERCHANT_LOCK - CONDITIONAL_ACTION -> Value.CONDITIONAL_ACTION - 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) { - CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Known.VELOCITY_LIMIT - MERCHANT_LOCK -> Known.MERCHANT_LOCK - CONDITIONAL_ACTION -> Known.CONDITIONAL_ACTION - else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleType = 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 AuthRuleType && 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 V2ListResponse && - token == other.token && - accountTokens == other.accountTokens && - businessAccountTokens == other.businessAccountTokens && - cardTokens == other.cardTokens && - currentVersion == other.currentVersion && - draftVersion == other.draftVersion && - eventStream == other.eventStream && - lithicManaged == other.lithicManaged && - name == other.name && - programLevel == other.programLevel && - state == other.state && - type == other.type && - excludedCardTokens == other.excludedCardTokens && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "V2ListResponse{token=$token, accountTokens=$accountTokens, businessAccountTokens=$businessAccountTokens, cardTokens=$cardTokens, currentVersion=$currentVersion, draftVersion=$draftVersion, eventStream=$eventStream, lithicManaged=$lithicManaged, name=$name, programLevel=$programLevel, state=$state, type=$type, excludedCardTokens=$excludedCardTokens, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt deleted file mode 100644 index 2e39b9789..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2PromoteResponse.kt +++ /dev/null @@ -1,2547 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.lithic.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.lithic.api.core.BaseDeserializer -import com.lithic.api.core.BaseSerializer -import com.lithic.api.core.Enum -import com.lithic.api.core.ExcludeMissing -import com.lithic.api.core.JsonField -import com.lithic.api.core.JsonMissing -import com.lithic.api.core.JsonValue -import com.lithic.api.core.allMaxBy -import com.lithic.api.core.checkKnown -import com.lithic.api.core.checkRequired -import com.lithic.api.core.getOrThrow -import com.lithic.api.core.toImmutable -import com.lithic.api.errors.LithicInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class V2PromoteResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val accountTokens: JsonField>, - private val businessAccountTokens: JsonField>, - private val cardTokens: JsonField>, - private val currentVersion: JsonField, - private val draftVersion: JsonField, - private val eventStream: JsonField, - private val lithicManaged: JsonField, - private val name: JsonField, - private val programLevel: JsonField, - private val state: JsonField, - private val type: JsonField, - private val excludedCardTokens: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("account_tokens") - @ExcludeMissing - accountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("business_account_tokens") - @ExcludeMissing - businessAccountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("card_tokens") - @ExcludeMissing - cardTokens: JsonField> = JsonMissing.of(), - @JsonProperty("current_version") - @ExcludeMissing - currentVersion: JsonField = JsonMissing.of(), - @JsonProperty("draft_version") - @ExcludeMissing - draftVersion: JsonField = JsonMissing.of(), - @JsonProperty("event_stream") - @ExcludeMissing - eventStream: JsonField = JsonMissing.of(), - @JsonProperty("lithic_managed") - @ExcludeMissing - lithicManaged: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("program_level") - @ExcludeMissing - programLevel: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - excludedCardTokens: JsonField> = JsonMissing.of(), - ) : this( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - mutableMapOf(), - ) - - /** - * Auth Rule Token - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun token(): String = token.getRequired("token") - - /** - * Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accountTokens(): List = accountTokens.getRequired("account_tokens") - - /** - * Business Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun businessAccountTokens(): List = - businessAccountTokens.getRequired("business_account_tokens") - - /** - * Card tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cardTokens(): List = cardTokens.getRequired("card_tokens") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currentVersion(): Optional = currentVersion.getOptional("current_version") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun draftVersion(): Optional = draftVersion.getOptional("draft_version") - - /** - * The event stream during which the rule will be evaluated. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun eventStream(): EventStream = eventStream.getRequired("event_stream") - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be modified - * or deleted by the user - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lithicManaged(): Boolean = lithicManaged.getRequired("lithic_managed") - - /** - * Auth Rule Name - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Whether the Auth Rule applies to all authorizations on the card program. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun programLevel(): Boolean = programLevel.getRequired("program_level") - - /** - * The state of the Auth Rule - * - * @throws LithicInvalidDataException if 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(): AuthRuleState = state.getRequired("state") - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - * - * @throws LithicInvalidDataException if 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(): AuthRuleType = type.getRequired("type") - - /** - * Card tokens to which the Auth Rule does not apply. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun excludedCardTokens(): Optional> = - excludedCardTokens.getOptional("excluded_card_tokens") - - /** - * 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 [accountTokens]. - * - * Unlike [accountTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account_tokens") - @ExcludeMissing - fun _accountTokens(): JsonField> = accountTokens - - /** - * Returns the raw JSON value of [businessAccountTokens]. - * - * Unlike [businessAccountTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("business_account_tokens") - @ExcludeMissing - fun _businessAccountTokens(): JsonField> = businessAccountTokens - - /** - * Returns the raw JSON value of [cardTokens]. - * - * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("card_tokens") - @ExcludeMissing - fun _cardTokens(): JsonField> = cardTokens - - /** - * Returns the raw JSON value of [currentVersion]. - * - * Unlike [currentVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("current_version") - @ExcludeMissing - fun _currentVersion(): JsonField = currentVersion - - /** - * Returns the raw JSON value of [draftVersion]. - * - * Unlike [draftVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("draft_version") - @ExcludeMissing - fun _draftVersion(): JsonField = draftVersion - - /** - * Returns the raw JSON value of [eventStream]. - * - * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event_stream") - @ExcludeMissing - fun _eventStream(): JsonField = eventStream - - /** - * Returns the raw JSON value of [lithicManaged]. - * - * Unlike [lithicManaged], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lithic_managed") - @ExcludeMissing - fun _lithicManaged(): JsonField = lithicManaged - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [programLevel]. - * - * Unlike [programLevel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("program_level") - @ExcludeMissing - fun _programLevel(): JsonField = programLevel - - /** - * 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 - - /** - * Returns the raw JSON value of [excludedCardTokens]. - * - * Unlike [excludedCardTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - fun _excludedCardTokens(): JsonField> = excludedCardTokens - - @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 [V2PromoteResponse]. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [V2PromoteResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var accountTokens: JsonField>? = null - private var businessAccountTokens: JsonField>? = null - private var cardTokens: JsonField>? = null - private var currentVersion: JsonField? = null - private var draftVersion: JsonField? = null - private var eventStream: JsonField? = null - private var lithicManaged: JsonField? = null - private var name: JsonField? = null - private var programLevel: JsonField? = null - private var state: JsonField? = null - private var type: JsonField? = null - private var excludedCardTokens: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(v2PromoteResponse: V2PromoteResponse) = apply { - token = v2PromoteResponse.token - accountTokens = v2PromoteResponse.accountTokens.map { it.toMutableList() } - businessAccountTokens = - v2PromoteResponse.businessAccountTokens.map { it.toMutableList() } - cardTokens = v2PromoteResponse.cardTokens.map { it.toMutableList() } - currentVersion = v2PromoteResponse.currentVersion - draftVersion = v2PromoteResponse.draftVersion - eventStream = v2PromoteResponse.eventStream - lithicManaged = v2PromoteResponse.lithicManaged - name = v2PromoteResponse.name - programLevel = v2PromoteResponse.programLevel - state = v2PromoteResponse.state - type = v2PromoteResponse.type - excludedCardTokens = v2PromoteResponse.excludedCardTokens.map { it.toMutableList() } - additionalProperties = v2PromoteResponse.additionalProperties.toMutableMap() - } - - /** Auth Rule Token */ - 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 } - - /** Account tokens to which the Auth Rule applies. */ - fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) - - /** - * Sets [Builder.accountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.accountTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [accountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAccountToken(accountToken: String) = apply { - accountTokens = - (accountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("accountTokens", it).add(accountToken) - } - } - - /** Business Account tokens to which the Auth Rule applies. */ - fun businessAccountTokens(businessAccountTokens: List) = - businessAccountTokens(JsonField.of(businessAccountTokens)) - - /** - * Sets [Builder.businessAccountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.businessAccountTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun businessAccountTokens(businessAccountTokens: JsonField>) = apply { - this.businessAccountTokens = businessAccountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [businessAccountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBusinessAccountToken(businessAccountToken: String) = apply { - businessAccountTokens = - (businessAccountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("businessAccountTokens", it).add(businessAccountToken) - } - } - - /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) - - /** - * Sets [Builder.cardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.cardTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cardTokens(cardTokens: JsonField>) = apply { - this.cardTokens = cardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [cardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCardToken(cardToken: String) = apply { - cardTokens = - (cardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("cardTokens", it).add(cardToken) - } - } - - fun currentVersion(currentVersion: CurrentVersion?) = - currentVersion(JsonField.ofNullable(currentVersion)) - - /** Alias for calling [Builder.currentVersion] with `currentVersion.orElse(null)`. */ - fun currentVersion(currentVersion: Optional) = - currentVersion(currentVersion.getOrNull()) - - /** - * Sets [Builder.currentVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.currentVersion] with a well-typed [CurrentVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currentVersion(currentVersion: JsonField) = apply { - this.currentVersion = currentVersion - } - - fun draftVersion(draftVersion: DraftVersion?) = - draftVersion(JsonField.ofNullable(draftVersion)) - - /** Alias for calling [Builder.draftVersion] with `draftVersion.orElse(null)`. */ - fun draftVersion(draftVersion: Optional) = - draftVersion(draftVersion.getOrNull()) - - /** - * Sets [Builder.draftVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.draftVersion] with a well-typed [DraftVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun draftVersion(draftVersion: JsonField) = apply { - this.draftVersion = draftVersion - } - - /** The event stream during which the rule will be evaluated. */ - fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) - - /** - * Sets [Builder.eventStream] to an arbitrary JSON value. - * - * You should usually call [Builder.eventStream] with a well-typed [EventStream] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventStream(eventStream: JsonField) = apply { - this.eventStream = eventStream - } - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be - * modified or deleted by the user - */ - fun lithicManaged(lithicManaged: Boolean) = lithicManaged(JsonField.of(lithicManaged)) - - /** - * Sets [Builder.lithicManaged] to an arbitrary JSON value. - * - * You should usually call [Builder.lithicManaged] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lithicManaged(lithicManaged: JsonField) = apply { - this.lithicManaged = lithicManaged - } - - /** Auth Rule Name */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Whether the Auth Rule applies to all authorizations on the card program. */ - fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) - - /** - * Sets [Builder.programLevel] to an arbitrary JSON value. - * - * You should usually call [Builder.programLevel] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun programLevel(programLevel: JsonField) = apply { - this.programLevel = programLevel - } - - /** The state of the Auth Rule */ - fun state(state: AuthRuleState) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [AuthRuleState] 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 } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during - * which it will be evaluated. For rules that can be applied to one of several event - * streams, the effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - fun type(type: AuthRuleType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [AuthRuleType] 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 } - - /** Card tokens to which the Auth Rule does not apply. */ - fun excludedCardTokens(excludedCardTokens: List) = - excludedCardTokens(JsonField.of(excludedCardTokens)) - - /** - * Sets [Builder.excludedCardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.excludedCardTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [excludedCardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExcludedCardToken(excludedCardToken: String) = apply { - excludedCardTokens = - (excludedCardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("excludedCardTokens", it).add(excludedCardToken) - } - } - - 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 [V2PromoteResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): V2PromoteResponse = - V2PromoteResponse( - checkRequired("token", token), - checkRequired("accountTokens", accountTokens).map { it.toImmutable() }, - checkRequired("businessAccountTokens", businessAccountTokens).map { - it.toImmutable() - }, - checkRequired("cardTokens", cardTokens).map { it.toImmutable() }, - checkRequired("currentVersion", currentVersion), - checkRequired("draftVersion", draftVersion), - checkRequired("eventStream", eventStream), - checkRequired("lithicManaged", lithicManaged), - checkRequired("name", name), - checkRequired("programLevel", programLevel), - checkRequired("state", state), - checkRequired("type", type), - (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): V2PromoteResponse = apply { - if (validated) { - return@apply - } - - token() - accountTokens() - businessAccountTokens() - cardTokens() - currentVersion().ifPresent { it.validate() } - draftVersion().ifPresent { it.validate() } - eventStream().validate() - lithicManaged() - name() - programLevel() - state().validate() - type().validate() - excludedCardTokens() - 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) + - (accountTokens.asKnown().getOrNull()?.size ?: 0) + - (businessAccountTokens.asKnown().getOrNull()?.size ?: 0) + - (cardTokens.asKnown().getOrNull()?.size ?: 0) + - (currentVersion.asKnown().getOrNull()?.validity() ?: 0) + - (draftVersion.asKnown().getOrNull()?.validity() ?: 0) + - (eventStream.asKnown().getOrNull()?.validity() ?: 0) + - (if (lithicManaged.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (programLevel.asKnown().isPresent) 1 else 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (excludedCardTokens.asKnown().getOrNull()?.size ?: 0) - - class CurrentVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [CurrentVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CurrentVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(currentVersion: CurrentVersion) = apply { - parameters = currentVersion.parameters - version = currentVersion.version - additionalProperties = currentVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [CurrentVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CurrentVersion = - CurrentVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CurrentVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CurrentVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - class DraftVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [DraftVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draftVersion: DraftVersion) = apply { - parameters = draftVersion.parameters - version = draftVersion.version - additionalProperties = draftVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [DraftVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DraftVersion = - DraftVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DraftVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - /** The event stream during which the rule will be evaluated. */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The state of the Auth Rule */ - class AuthRuleState @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 ACTIVE = of("ACTIVE") - - @JvmField val INACTIVE = of("INACTIVE") - - @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) - } - - /** An enum containing [AuthRuleState]'s known values. */ - enum class Known { - ACTIVE, - INACTIVE, - } - - /** - * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleState] 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 { - ACTIVE, - INACTIVE, - /** - * An enum member indicating that [AuthRuleState] 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) { - ACTIVE -> Value.ACTIVE - INACTIVE -> Value.INACTIVE - 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) { - ACTIVE -> Known.ACTIVE - INACTIVE -> Known.INACTIVE - else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleState = 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 AuthRuleState && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - class AuthRuleType @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 CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK") - - @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT") - - @JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK") - - @JvmField val CONDITIONAL_ACTION = of("CONDITIONAL_ACTION") - - @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) - } - - /** An enum containing [AuthRuleType]'s known values. */ - enum class Known { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - } - - /** - * An enum containing [AuthRuleType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleType] 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 { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - /** - * An enum member indicating that [AuthRuleType] 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) { - CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Value.VELOCITY_LIMIT - MERCHANT_LOCK -> Value.MERCHANT_LOCK - CONDITIONAL_ACTION -> Value.CONDITIONAL_ACTION - 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) { - CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Known.VELOCITY_LIMIT - MERCHANT_LOCK -> Known.MERCHANT_LOCK - CONDITIONAL_ACTION -> Known.CONDITIONAL_ACTION - else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleType = 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 AuthRuleType && 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 V2PromoteResponse && - token == other.token && - accountTokens == other.accountTokens && - businessAccountTokens == other.businessAccountTokens && - cardTokens == other.cardTokens && - currentVersion == other.currentVersion && - draftVersion == other.draftVersion && - eventStream == other.eventStream && - lithicManaged == other.lithicManaged && - name == other.name && - programLevel == other.programLevel && - state == other.state && - type == other.type && - excludedCardTokens == other.excludedCardTokens && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "V2PromoteResponse{token=$token, accountTokens=$accountTokens, businessAccountTokens=$businessAccountTokens, cardTokens=$cardTokens, currentVersion=$currentVersion, draftVersion=$draftVersion, eventStream=$eventStream, lithicManaged=$lithicManaged, name=$name, programLevel=$programLevel, state=$state, type=$type, excludedCardTokens=$excludedCardTokens, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt deleted file mode 100644 index 18cabbff0..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2RetrieveResponse.kt +++ /dev/null @@ -1,2547 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.lithic.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.lithic.api.core.BaseDeserializer -import com.lithic.api.core.BaseSerializer -import com.lithic.api.core.Enum -import com.lithic.api.core.ExcludeMissing -import com.lithic.api.core.JsonField -import com.lithic.api.core.JsonMissing -import com.lithic.api.core.JsonValue -import com.lithic.api.core.allMaxBy -import com.lithic.api.core.checkKnown -import com.lithic.api.core.checkRequired -import com.lithic.api.core.getOrThrow -import com.lithic.api.core.toImmutable -import com.lithic.api.errors.LithicInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class V2RetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val accountTokens: JsonField>, - private val businessAccountTokens: JsonField>, - private val cardTokens: JsonField>, - private val currentVersion: JsonField, - private val draftVersion: JsonField, - private val eventStream: JsonField, - private val lithicManaged: JsonField, - private val name: JsonField, - private val programLevel: JsonField, - private val state: JsonField, - private val type: JsonField, - private val excludedCardTokens: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("account_tokens") - @ExcludeMissing - accountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("business_account_tokens") - @ExcludeMissing - businessAccountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("card_tokens") - @ExcludeMissing - cardTokens: JsonField> = JsonMissing.of(), - @JsonProperty("current_version") - @ExcludeMissing - currentVersion: JsonField = JsonMissing.of(), - @JsonProperty("draft_version") - @ExcludeMissing - draftVersion: JsonField = JsonMissing.of(), - @JsonProperty("event_stream") - @ExcludeMissing - eventStream: JsonField = JsonMissing.of(), - @JsonProperty("lithic_managed") - @ExcludeMissing - lithicManaged: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("program_level") - @ExcludeMissing - programLevel: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - excludedCardTokens: JsonField> = JsonMissing.of(), - ) : this( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - mutableMapOf(), - ) - - /** - * Auth Rule Token - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun token(): String = token.getRequired("token") - - /** - * Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accountTokens(): List = accountTokens.getRequired("account_tokens") - - /** - * Business Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun businessAccountTokens(): List = - businessAccountTokens.getRequired("business_account_tokens") - - /** - * Card tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cardTokens(): List = cardTokens.getRequired("card_tokens") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currentVersion(): Optional = currentVersion.getOptional("current_version") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun draftVersion(): Optional = draftVersion.getOptional("draft_version") - - /** - * The event stream during which the rule will be evaluated. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun eventStream(): EventStream = eventStream.getRequired("event_stream") - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be modified - * or deleted by the user - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lithicManaged(): Boolean = lithicManaged.getRequired("lithic_managed") - - /** - * Auth Rule Name - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Whether the Auth Rule applies to all authorizations on the card program. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun programLevel(): Boolean = programLevel.getRequired("program_level") - - /** - * The state of the Auth Rule - * - * @throws LithicInvalidDataException if 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(): AuthRuleState = state.getRequired("state") - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - * - * @throws LithicInvalidDataException if 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(): AuthRuleType = type.getRequired("type") - - /** - * Card tokens to which the Auth Rule does not apply. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun excludedCardTokens(): Optional> = - excludedCardTokens.getOptional("excluded_card_tokens") - - /** - * 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 [accountTokens]. - * - * Unlike [accountTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account_tokens") - @ExcludeMissing - fun _accountTokens(): JsonField> = accountTokens - - /** - * Returns the raw JSON value of [businessAccountTokens]. - * - * Unlike [businessAccountTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("business_account_tokens") - @ExcludeMissing - fun _businessAccountTokens(): JsonField> = businessAccountTokens - - /** - * Returns the raw JSON value of [cardTokens]. - * - * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("card_tokens") - @ExcludeMissing - fun _cardTokens(): JsonField> = cardTokens - - /** - * Returns the raw JSON value of [currentVersion]. - * - * Unlike [currentVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("current_version") - @ExcludeMissing - fun _currentVersion(): JsonField = currentVersion - - /** - * Returns the raw JSON value of [draftVersion]. - * - * Unlike [draftVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("draft_version") - @ExcludeMissing - fun _draftVersion(): JsonField = draftVersion - - /** - * Returns the raw JSON value of [eventStream]. - * - * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event_stream") - @ExcludeMissing - fun _eventStream(): JsonField = eventStream - - /** - * Returns the raw JSON value of [lithicManaged]. - * - * Unlike [lithicManaged], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lithic_managed") - @ExcludeMissing - fun _lithicManaged(): JsonField = lithicManaged - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [programLevel]. - * - * Unlike [programLevel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("program_level") - @ExcludeMissing - fun _programLevel(): JsonField = programLevel - - /** - * 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 - - /** - * Returns the raw JSON value of [excludedCardTokens]. - * - * Unlike [excludedCardTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - fun _excludedCardTokens(): JsonField> = excludedCardTokens - - @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 [V2RetrieveResponse]. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [V2RetrieveResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var accountTokens: JsonField>? = null - private var businessAccountTokens: JsonField>? = null - private var cardTokens: JsonField>? = null - private var currentVersion: JsonField? = null - private var draftVersion: JsonField? = null - private var eventStream: JsonField? = null - private var lithicManaged: JsonField? = null - private var name: JsonField? = null - private var programLevel: JsonField? = null - private var state: JsonField? = null - private var type: JsonField? = null - private var excludedCardTokens: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(v2RetrieveResponse: V2RetrieveResponse) = apply { - token = v2RetrieveResponse.token - accountTokens = v2RetrieveResponse.accountTokens.map { it.toMutableList() } - businessAccountTokens = - v2RetrieveResponse.businessAccountTokens.map { it.toMutableList() } - cardTokens = v2RetrieveResponse.cardTokens.map { it.toMutableList() } - currentVersion = v2RetrieveResponse.currentVersion - draftVersion = v2RetrieveResponse.draftVersion - eventStream = v2RetrieveResponse.eventStream - lithicManaged = v2RetrieveResponse.lithicManaged - name = v2RetrieveResponse.name - programLevel = v2RetrieveResponse.programLevel - state = v2RetrieveResponse.state - type = v2RetrieveResponse.type - excludedCardTokens = v2RetrieveResponse.excludedCardTokens.map { it.toMutableList() } - additionalProperties = v2RetrieveResponse.additionalProperties.toMutableMap() - } - - /** Auth Rule Token */ - 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 } - - /** Account tokens to which the Auth Rule applies. */ - fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) - - /** - * Sets [Builder.accountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.accountTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [accountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAccountToken(accountToken: String) = apply { - accountTokens = - (accountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("accountTokens", it).add(accountToken) - } - } - - /** Business Account tokens to which the Auth Rule applies. */ - fun businessAccountTokens(businessAccountTokens: List) = - businessAccountTokens(JsonField.of(businessAccountTokens)) - - /** - * Sets [Builder.businessAccountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.businessAccountTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun businessAccountTokens(businessAccountTokens: JsonField>) = apply { - this.businessAccountTokens = businessAccountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [businessAccountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBusinessAccountToken(businessAccountToken: String) = apply { - businessAccountTokens = - (businessAccountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("businessAccountTokens", it).add(businessAccountToken) - } - } - - /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) - - /** - * Sets [Builder.cardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.cardTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cardTokens(cardTokens: JsonField>) = apply { - this.cardTokens = cardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [cardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCardToken(cardToken: String) = apply { - cardTokens = - (cardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("cardTokens", it).add(cardToken) - } - } - - fun currentVersion(currentVersion: CurrentVersion?) = - currentVersion(JsonField.ofNullable(currentVersion)) - - /** Alias for calling [Builder.currentVersion] with `currentVersion.orElse(null)`. */ - fun currentVersion(currentVersion: Optional) = - currentVersion(currentVersion.getOrNull()) - - /** - * Sets [Builder.currentVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.currentVersion] with a well-typed [CurrentVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currentVersion(currentVersion: JsonField) = apply { - this.currentVersion = currentVersion - } - - fun draftVersion(draftVersion: DraftVersion?) = - draftVersion(JsonField.ofNullable(draftVersion)) - - /** Alias for calling [Builder.draftVersion] with `draftVersion.orElse(null)`. */ - fun draftVersion(draftVersion: Optional) = - draftVersion(draftVersion.getOrNull()) - - /** - * Sets [Builder.draftVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.draftVersion] with a well-typed [DraftVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun draftVersion(draftVersion: JsonField) = apply { - this.draftVersion = draftVersion - } - - /** The event stream during which the rule will be evaluated. */ - fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) - - /** - * Sets [Builder.eventStream] to an arbitrary JSON value. - * - * You should usually call [Builder.eventStream] with a well-typed [EventStream] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventStream(eventStream: JsonField) = apply { - this.eventStream = eventStream - } - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be - * modified or deleted by the user - */ - fun lithicManaged(lithicManaged: Boolean) = lithicManaged(JsonField.of(lithicManaged)) - - /** - * Sets [Builder.lithicManaged] to an arbitrary JSON value. - * - * You should usually call [Builder.lithicManaged] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lithicManaged(lithicManaged: JsonField) = apply { - this.lithicManaged = lithicManaged - } - - /** Auth Rule Name */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Whether the Auth Rule applies to all authorizations on the card program. */ - fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) - - /** - * Sets [Builder.programLevel] to an arbitrary JSON value. - * - * You should usually call [Builder.programLevel] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun programLevel(programLevel: JsonField) = apply { - this.programLevel = programLevel - } - - /** The state of the Auth Rule */ - fun state(state: AuthRuleState) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [AuthRuleState] 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 } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during - * which it will be evaluated. For rules that can be applied to one of several event - * streams, the effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - fun type(type: AuthRuleType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [AuthRuleType] 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 } - - /** Card tokens to which the Auth Rule does not apply. */ - fun excludedCardTokens(excludedCardTokens: List) = - excludedCardTokens(JsonField.of(excludedCardTokens)) - - /** - * Sets [Builder.excludedCardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.excludedCardTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [excludedCardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExcludedCardToken(excludedCardToken: String) = apply { - excludedCardTokens = - (excludedCardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("excludedCardTokens", it).add(excludedCardToken) - } - } - - 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 [V2RetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): V2RetrieveResponse = - V2RetrieveResponse( - checkRequired("token", token), - checkRequired("accountTokens", accountTokens).map { it.toImmutable() }, - checkRequired("businessAccountTokens", businessAccountTokens).map { - it.toImmutable() - }, - checkRequired("cardTokens", cardTokens).map { it.toImmutable() }, - checkRequired("currentVersion", currentVersion), - checkRequired("draftVersion", draftVersion), - checkRequired("eventStream", eventStream), - checkRequired("lithicManaged", lithicManaged), - checkRequired("name", name), - checkRequired("programLevel", programLevel), - checkRequired("state", state), - checkRequired("type", type), - (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): V2RetrieveResponse = apply { - if (validated) { - return@apply - } - - token() - accountTokens() - businessAccountTokens() - cardTokens() - currentVersion().ifPresent { it.validate() } - draftVersion().ifPresent { it.validate() } - eventStream().validate() - lithicManaged() - name() - programLevel() - state().validate() - type().validate() - excludedCardTokens() - 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) + - (accountTokens.asKnown().getOrNull()?.size ?: 0) + - (businessAccountTokens.asKnown().getOrNull()?.size ?: 0) + - (cardTokens.asKnown().getOrNull()?.size ?: 0) + - (currentVersion.asKnown().getOrNull()?.validity() ?: 0) + - (draftVersion.asKnown().getOrNull()?.validity() ?: 0) + - (eventStream.asKnown().getOrNull()?.validity() ?: 0) + - (if (lithicManaged.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (programLevel.asKnown().isPresent) 1 else 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (excludedCardTokens.asKnown().getOrNull()?.size ?: 0) - - class CurrentVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [CurrentVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CurrentVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(currentVersion: CurrentVersion) = apply { - parameters = currentVersion.parameters - version = currentVersion.version - additionalProperties = currentVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [CurrentVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CurrentVersion = - CurrentVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CurrentVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CurrentVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - class DraftVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [DraftVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draftVersion: DraftVersion) = apply { - parameters = draftVersion.parameters - version = draftVersion.version - additionalProperties = draftVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [DraftVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DraftVersion = - DraftVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DraftVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - /** The event stream during which the rule will be evaluated. */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The state of the Auth Rule */ - class AuthRuleState @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 ACTIVE = of("ACTIVE") - - @JvmField val INACTIVE = of("INACTIVE") - - @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) - } - - /** An enum containing [AuthRuleState]'s known values. */ - enum class Known { - ACTIVE, - INACTIVE, - } - - /** - * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleState] 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 { - ACTIVE, - INACTIVE, - /** - * An enum member indicating that [AuthRuleState] 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) { - ACTIVE -> Value.ACTIVE - INACTIVE -> Value.INACTIVE - 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) { - ACTIVE -> Known.ACTIVE - INACTIVE -> Known.INACTIVE - else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleState = 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 AuthRuleState && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - class AuthRuleType @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 CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK") - - @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT") - - @JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK") - - @JvmField val CONDITIONAL_ACTION = of("CONDITIONAL_ACTION") - - @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) - } - - /** An enum containing [AuthRuleType]'s known values. */ - enum class Known { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - } - - /** - * An enum containing [AuthRuleType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleType] 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 { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - /** - * An enum member indicating that [AuthRuleType] 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) { - CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Value.VELOCITY_LIMIT - MERCHANT_LOCK -> Value.MERCHANT_LOCK - CONDITIONAL_ACTION -> Value.CONDITIONAL_ACTION - 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) { - CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Known.VELOCITY_LIMIT - MERCHANT_LOCK -> Known.MERCHANT_LOCK - CONDITIONAL_ACTION -> Known.CONDITIONAL_ACTION - else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleType = 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 AuthRuleType && 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 V2RetrieveResponse && - token == other.token && - accountTokens == other.accountTokens && - businessAccountTokens == other.businessAccountTokens && - cardTokens == other.cardTokens && - currentVersion == other.currentVersion && - draftVersion == other.draftVersion && - eventStream == other.eventStream && - lithicManaged == other.lithicManaged && - name == other.name && - programLevel == other.programLevel && - state == other.state && - type == other.type && - excludedCardTokens == other.excludedCardTokens && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "V2RetrieveResponse{token=$token, accountTokens=$accountTokens, businessAccountTokens=$businessAccountTokens, cardTokens=$cardTokens, currentVersion=$currentVersion, draftVersion=$draftVersion, eventStream=$eventStream, lithicManaged=$lithicManaged, name=$name, programLevel=$programLevel, state=$state, type=$type, excludedCardTokens=$excludedCardTokens, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt deleted file mode 100644 index 18ebaf6c7..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2UpdateResponse.kt +++ /dev/null @@ -1,2547 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.lithic.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.lithic.api.core.BaseDeserializer -import com.lithic.api.core.BaseSerializer -import com.lithic.api.core.Enum -import com.lithic.api.core.ExcludeMissing -import com.lithic.api.core.JsonField -import com.lithic.api.core.JsonMissing -import com.lithic.api.core.JsonValue -import com.lithic.api.core.allMaxBy -import com.lithic.api.core.checkKnown -import com.lithic.api.core.checkRequired -import com.lithic.api.core.getOrThrow -import com.lithic.api.core.toImmutable -import com.lithic.api.errors.LithicInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class V2UpdateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val accountTokens: JsonField>, - private val businessAccountTokens: JsonField>, - private val cardTokens: JsonField>, - private val currentVersion: JsonField, - private val draftVersion: JsonField, - private val eventStream: JsonField, - private val lithicManaged: JsonField, - private val name: JsonField, - private val programLevel: JsonField, - private val state: JsonField, - private val type: JsonField, - private val excludedCardTokens: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("account_tokens") - @ExcludeMissing - accountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("business_account_tokens") - @ExcludeMissing - businessAccountTokens: JsonField> = JsonMissing.of(), - @JsonProperty("card_tokens") - @ExcludeMissing - cardTokens: JsonField> = JsonMissing.of(), - @JsonProperty("current_version") - @ExcludeMissing - currentVersion: JsonField = JsonMissing.of(), - @JsonProperty("draft_version") - @ExcludeMissing - draftVersion: JsonField = JsonMissing.of(), - @JsonProperty("event_stream") - @ExcludeMissing - eventStream: JsonField = JsonMissing.of(), - @JsonProperty("lithic_managed") - @ExcludeMissing - lithicManaged: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("program_level") - @ExcludeMissing - programLevel: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - excludedCardTokens: JsonField> = JsonMissing.of(), - ) : this( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - mutableMapOf(), - ) - - /** - * Auth Rule Token - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun token(): String = token.getRequired("token") - - /** - * Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accountTokens(): List = accountTokens.getRequired("account_tokens") - - /** - * Business Account tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun businessAccountTokens(): List = - businessAccountTokens.getRequired("business_account_tokens") - - /** - * Card tokens to which the Auth Rule applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun cardTokens(): List = cardTokens.getRequired("card_tokens") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currentVersion(): Optional = currentVersion.getOptional("current_version") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun draftVersion(): Optional = draftVersion.getOptional("draft_version") - - /** - * The event stream during which the rule will be evaluated. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun eventStream(): EventStream = eventStream.getRequired("event_stream") - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be modified - * or deleted by the user - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lithicManaged(): Boolean = lithicManaged.getRequired("lithic_managed") - - /** - * Auth Rule Name - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Whether the Auth Rule applies to all authorizations on the card program. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun programLevel(): Boolean = programLevel.getRequired("program_level") - - /** - * The state of the Auth Rule - * - * @throws LithicInvalidDataException if 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(): AuthRuleState = state.getRequired("state") - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - * - * @throws LithicInvalidDataException if 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(): AuthRuleType = type.getRequired("type") - - /** - * Card tokens to which the Auth Rule does not apply. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun excludedCardTokens(): Optional> = - excludedCardTokens.getOptional("excluded_card_tokens") - - /** - * 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 [accountTokens]. - * - * Unlike [accountTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account_tokens") - @ExcludeMissing - fun _accountTokens(): JsonField> = accountTokens - - /** - * Returns the raw JSON value of [businessAccountTokens]. - * - * Unlike [businessAccountTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("business_account_tokens") - @ExcludeMissing - fun _businessAccountTokens(): JsonField> = businessAccountTokens - - /** - * Returns the raw JSON value of [cardTokens]. - * - * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("card_tokens") - @ExcludeMissing - fun _cardTokens(): JsonField> = cardTokens - - /** - * Returns the raw JSON value of [currentVersion]. - * - * Unlike [currentVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("current_version") - @ExcludeMissing - fun _currentVersion(): JsonField = currentVersion - - /** - * Returns the raw JSON value of [draftVersion]. - * - * Unlike [draftVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("draft_version") - @ExcludeMissing - fun _draftVersion(): JsonField = draftVersion - - /** - * Returns the raw JSON value of [eventStream]. - * - * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event_stream") - @ExcludeMissing - fun _eventStream(): JsonField = eventStream - - /** - * Returns the raw JSON value of [lithicManaged]. - * - * Unlike [lithicManaged], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lithic_managed") - @ExcludeMissing - fun _lithicManaged(): JsonField = lithicManaged - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [programLevel]. - * - * Unlike [programLevel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("program_level") - @ExcludeMissing - fun _programLevel(): JsonField = programLevel - - /** - * 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 - - /** - * Returns the raw JSON value of [excludedCardTokens]. - * - * Unlike [excludedCardTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("excluded_card_tokens") - @ExcludeMissing - fun _excludedCardTokens(): JsonField> = excludedCardTokens - - @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 [V2UpdateResponse]. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [V2UpdateResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var accountTokens: JsonField>? = null - private var businessAccountTokens: JsonField>? = null - private var cardTokens: JsonField>? = null - private var currentVersion: JsonField? = null - private var draftVersion: JsonField? = null - private var eventStream: JsonField? = null - private var lithicManaged: JsonField? = null - private var name: JsonField? = null - private var programLevel: JsonField? = null - private var state: JsonField? = null - private var type: JsonField? = null - private var excludedCardTokens: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(v2UpdateResponse: V2UpdateResponse) = apply { - token = v2UpdateResponse.token - accountTokens = v2UpdateResponse.accountTokens.map { it.toMutableList() } - businessAccountTokens = - v2UpdateResponse.businessAccountTokens.map { it.toMutableList() } - cardTokens = v2UpdateResponse.cardTokens.map { it.toMutableList() } - currentVersion = v2UpdateResponse.currentVersion - draftVersion = v2UpdateResponse.draftVersion - eventStream = v2UpdateResponse.eventStream - lithicManaged = v2UpdateResponse.lithicManaged - name = v2UpdateResponse.name - programLevel = v2UpdateResponse.programLevel - state = v2UpdateResponse.state - type = v2UpdateResponse.type - excludedCardTokens = v2UpdateResponse.excludedCardTokens.map { it.toMutableList() } - additionalProperties = v2UpdateResponse.additionalProperties.toMutableMap() - } - - /** Auth Rule Token */ - 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 } - - /** Account tokens to which the Auth Rule applies. */ - fun accountTokens(accountTokens: List) = accountTokens(JsonField.of(accountTokens)) - - /** - * Sets [Builder.accountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.accountTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun accountTokens(accountTokens: JsonField>) = apply { - this.accountTokens = accountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [accountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAccountToken(accountToken: String) = apply { - accountTokens = - (accountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("accountTokens", it).add(accountToken) - } - } - - /** Business Account tokens to which the Auth Rule applies. */ - fun businessAccountTokens(businessAccountTokens: List) = - businessAccountTokens(JsonField.of(businessAccountTokens)) - - /** - * Sets [Builder.businessAccountTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.businessAccountTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun businessAccountTokens(businessAccountTokens: JsonField>) = apply { - this.businessAccountTokens = businessAccountTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [businessAccountTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBusinessAccountToken(businessAccountToken: String) = apply { - businessAccountTokens = - (businessAccountTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("businessAccountTokens", it).add(businessAccountToken) - } - } - - /** Card tokens to which the Auth Rule applies. */ - fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) - - /** - * Sets [Builder.cardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.cardTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cardTokens(cardTokens: JsonField>) = apply { - this.cardTokens = cardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [cardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCardToken(cardToken: String) = apply { - cardTokens = - (cardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("cardTokens", it).add(cardToken) - } - } - - fun currentVersion(currentVersion: CurrentVersion?) = - currentVersion(JsonField.ofNullable(currentVersion)) - - /** Alias for calling [Builder.currentVersion] with `currentVersion.orElse(null)`. */ - fun currentVersion(currentVersion: Optional) = - currentVersion(currentVersion.getOrNull()) - - /** - * Sets [Builder.currentVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.currentVersion] with a well-typed [CurrentVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currentVersion(currentVersion: JsonField) = apply { - this.currentVersion = currentVersion - } - - fun draftVersion(draftVersion: DraftVersion?) = - draftVersion(JsonField.ofNullable(draftVersion)) - - /** Alias for calling [Builder.draftVersion] with `draftVersion.orElse(null)`. */ - fun draftVersion(draftVersion: Optional) = - draftVersion(draftVersion.getOrNull()) - - /** - * Sets [Builder.draftVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.draftVersion] with a well-typed [DraftVersion] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun draftVersion(draftVersion: JsonField) = apply { - this.draftVersion = draftVersion - } - - /** The event stream during which the rule will be evaluated. */ - fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) - - /** - * Sets [Builder.eventStream] to an arbitrary JSON value. - * - * You should usually call [Builder.eventStream] with a well-typed [EventStream] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun eventStream(eventStream: JsonField) = apply { - this.eventStream = eventStream - } - - /** - * Indicates whether this auth rule is managed by Lithic. If true, the rule cannot be - * modified or deleted by the user - */ - fun lithicManaged(lithicManaged: Boolean) = lithicManaged(JsonField.of(lithicManaged)) - - /** - * Sets [Builder.lithicManaged] to an arbitrary JSON value. - * - * You should usually call [Builder.lithicManaged] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lithicManaged(lithicManaged: JsonField) = apply { - this.lithicManaged = lithicManaged - } - - /** Auth Rule Name */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Whether the Auth Rule applies to all authorizations on the card program. */ - fun programLevel(programLevel: Boolean) = programLevel(JsonField.of(programLevel)) - - /** - * Sets [Builder.programLevel] to an arbitrary JSON value. - * - * You should usually call [Builder.programLevel] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun programLevel(programLevel: JsonField) = apply { - this.programLevel = programLevel - } - - /** The state of the Auth Rule */ - fun state(state: AuthRuleState) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [AuthRuleState] 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 } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during - * which it will be evaluated. For rules that can be applied to one of several event - * streams, the effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - fun type(type: AuthRuleType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [AuthRuleType] 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 } - - /** Card tokens to which the Auth Rule does not apply. */ - fun excludedCardTokens(excludedCardTokens: List) = - excludedCardTokens(JsonField.of(excludedCardTokens)) - - /** - * Sets [Builder.excludedCardTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.excludedCardTokens] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun excludedCardTokens(excludedCardTokens: JsonField>) = apply { - this.excludedCardTokens = excludedCardTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [excludedCardTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExcludedCardToken(excludedCardToken: String) = apply { - excludedCardTokens = - (excludedCardTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("excludedCardTokens", it).add(excludedCardToken) - } - } - - 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 [V2UpdateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .accountTokens() - * .businessAccountTokens() - * .cardTokens() - * .currentVersion() - * .draftVersion() - * .eventStream() - * .lithicManaged() - * .name() - * .programLevel() - * .state() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): V2UpdateResponse = - V2UpdateResponse( - checkRequired("token", token), - checkRequired("accountTokens", accountTokens).map { it.toImmutable() }, - checkRequired("businessAccountTokens", businessAccountTokens).map { - it.toImmutable() - }, - checkRequired("cardTokens", cardTokens).map { it.toImmutable() }, - checkRequired("currentVersion", currentVersion), - checkRequired("draftVersion", draftVersion), - checkRequired("eventStream", eventStream), - checkRequired("lithicManaged", lithicManaged), - checkRequired("name", name), - checkRequired("programLevel", programLevel), - checkRequired("state", state), - checkRequired("type", type), - (excludedCardTokens ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): V2UpdateResponse = apply { - if (validated) { - return@apply - } - - token() - accountTokens() - businessAccountTokens() - cardTokens() - currentVersion().ifPresent { it.validate() } - draftVersion().ifPresent { it.validate() } - eventStream().validate() - lithicManaged() - name() - programLevel() - state().validate() - type().validate() - excludedCardTokens() - 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) + - (accountTokens.asKnown().getOrNull()?.size ?: 0) + - (businessAccountTokens.asKnown().getOrNull()?.size ?: 0) + - (cardTokens.asKnown().getOrNull()?.size ?: 0) + - (currentVersion.asKnown().getOrNull()?.validity() ?: 0) + - (draftVersion.asKnown().getOrNull()?.validity() ?: 0) + - (eventStream.asKnown().getOrNull()?.validity() ?: 0) + - (if (lithicManaged.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (programLevel.asKnown().isPresent) 1 else 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (excludedCardTokens.asKnown().getOrNull()?.size ?: 0) - - class CurrentVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [CurrentVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CurrentVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(currentVersion: CurrentVersion) = apply { - parameters = currentVersion.parameters - version = currentVersion.version - additionalProperties = currentVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [CurrentVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CurrentVersion = - CurrentVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CurrentVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CurrentVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CurrentVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - class DraftVersion - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val parameters: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(parameters, version, mutableMapOf()) - - /** - * Parameters for the Auth Rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Parameters = parameters.getRequired("parameters") - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): Long = version.getRequired("version") - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @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 [DraftVersion]. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftVersion]. */ - class Builder internal constructor() { - - private var parameters: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(draftVersion: DraftVersion) = apply { - parameters = draftVersion.parameters - version = draftVersion.version - additionalProperties = draftVersion.additionalProperties.toMutableMap() - } - - /** Parameters for the Auth Rule */ - fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters)) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalBlock(conditionalBlock)`. - */ - fun parameters(conditionalBlock: ConditionalBlockParameters) = - parameters(Parameters.ofConditionalBlock(conditionalBlock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofVelocityLimitParams(velocityLimitParams)`. - */ - fun parameters(velocityLimitParams: VelocityLimitParams) = - parameters(Parameters.ofVelocityLimitParams(velocityLimitParams)) - - /** Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`. */ - fun parameters(merchantLock: MerchantLockParameters) = - parameters(Parameters.ofMerchantLock(merchantLock)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditional3dsAction(conditional3dsAction)`. - */ - fun parameters(conditional3dsAction: Conditional3dsActionParameters) = - parameters(Parameters.ofConditional3dsAction(conditional3dsAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction)`. - */ - fun parameters( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = - parameters( - Parameters.ofConditionalAuthorizationAction(conditionalAuthorizationAction) - ) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalAchAction(conditionalAchAction)`. - */ - fun parameters(conditionalAchAction: ConditionalAchActionParameters) = - parameters(Parameters.ofConditionalAchAction(conditionalAchAction)) - - /** - * Alias for calling [parameters] with - * `Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction)`. - */ - fun parameters(conditionalTokenizationAction: ConditionalTokenizationActionParameters) = - parameters( - Parameters.ofConditionalTokenizationAction(conditionalTokenizationAction) - ) - - /** - * The version of the rule, this is incremented whenever the rule's parameters change. - */ - fun version(version: Long) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - 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 [DraftVersion]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .parameters() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): DraftVersion = - DraftVersion( - checkRequired("parameters", parameters), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DraftVersion = apply { - if (validated) { - return@apply - } - - parameters().validate() - version() - 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 = - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - /** Parameters for the Auth Rule */ - @JsonDeserialize(using = Parameters.Deserializer::class) - @JsonSerialize(using = Parameters.Serializer::class) - class Parameters - private constructor( - private val conditionalBlock: ConditionalBlockParameters? = null, - private val velocityLimitParams: VelocityLimitParams? = null, - private val merchantLock: MerchantLockParameters? = null, - private val conditional3dsAction: Conditional3dsActionParameters? = null, - private val conditionalAuthorizationAction: ConditionalAuthorizationActionParameters? = - null, - private val conditionalAchAction: ConditionalAchActionParameters? = null, - private val conditionalTokenizationAction: ConditionalTokenizationActionParameters? = - null, - private val _json: JsonValue? = null, - ) { - - fun conditionalBlock(): Optional = - Optional.ofNullable(conditionalBlock) - - fun velocityLimitParams(): Optional = - Optional.ofNullable(velocityLimitParams) - - fun merchantLock(): Optional = Optional.ofNullable(merchantLock) - - fun conditional3dsAction(): Optional = - Optional.ofNullable(conditional3dsAction) - - fun conditionalAuthorizationAction(): - Optional = - Optional.ofNullable(conditionalAuthorizationAction) - - fun conditionalAchAction(): Optional = - Optional.ofNullable(conditionalAchAction) - - fun conditionalTokenizationAction(): Optional = - Optional.ofNullable(conditionalTokenizationAction) - - fun isConditionalBlock(): Boolean = conditionalBlock != null - - fun isVelocityLimitParams(): Boolean = velocityLimitParams != null - - fun isMerchantLock(): Boolean = merchantLock != null - - fun isConditional3dsAction(): Boolean = conditional3dsAction != null - - fun isConditionalAuthorizationAction(): Boolean = conditionalAuthorizationAction != null - - fun isConditionalAchAction(): Boolean = conditionalAchAction != null - - fun isConditionalTokenizationAction(): Boolean = conditionalTokenizationAction != null - - fun asConditionalBlock(): ConditionalBlockParameters = - conditionalBlock.getOrThrow("conditionalBlock") - - fun asVelocityLimitParams(): VelocityLimitParams = - velocityLimitParams.getOrThrow("velocityLimitParams") - - fun asMerchantLock(): MerchantLockParameters = merchantLock.getOrThrow("merchantLock") - - fun asConditional3dsAction(): Conditional3dsActionParameters = - conditional3dsAction.getOrThrow("conditional3dsAction") - - fun asConditionalAuthorizationAction(): ConditionalAuthorizationActionParameters = - conditionalAuthorizationAction.getOrThrow("conditionalAuthorizationAction") - - fun asConditionalAchAction(): ConditionalAchActionParameters = - conditionalAchAction.getOrThrow("conditionalAchAction") - - fun asConditionalTokenizationAction(): ConditionalTokenizationActionParameters = - conditionalTokenizationAction.getOrThrow("conditionalTokenizationAction") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock) - velocityLimitParams != null -> - visitor.visitVelocityLimitParams(velocityLimitParams) - merchantLock != null -> visitor.visitMerchantLock(merchantLock) - conditional3dsAction != null -> - visitor.visitConditional3dsAction(conditional3dsAction) - conditionalAuthorizationAction != null -> - visitor.visitConditionalAuthorizationAction(conditionalAuthorizationAction) - conditionalAchAction != null -> - visitor.visitConditionalAchAction(conditionalAchAction) - conditionalTokenizationAction != null -> - visitor.visitConditionalTokenizationAction(conditionalTokenizationAction) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Parameters = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) { - conditionalBlock.validate() - } - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) { - velocityLimitParams.validate() - } - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) { - merchantLock.validate() - } - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) { - conditional3dsAction.validate() - } - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) { - conditionalAuthorizationAction.validate() - } - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) { - conditionalAchAction.validate() - } - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) { - conditionalTokenizationAction.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitConditionalBlock( - conditionalBlock: ConditionalBlockParameters - ) = conditionalBlock.validity() - - override fun visitVelocityLimitParams( - velocityLimitParams: VelocityLimitParams - ) = velocityLimitParams.validity() - - override fun visitMerchantLock(merchantLock: MerchantLockParameters) = - merchantLock.validity() - - override fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ) = conditional3dsAction.validity() - - override fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = conditionalAuthorizationAction.validity() - - override fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ) = conditionalAchAction.validity() - - override fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = conditionalTokenizationAction.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - conditionalBlock == other.conditionalBlock && - velocityLimitParams == other.velocityLimitParams && - merchantLock == other.merchantLock && - conditional3dsAction == other.conditional3dsAction && - conditionalAuthorizationAction == other.conditionalAuthorizationAction && - conditionalAchAction == other.conditionalAchAction && - conditionalTokenizationAction == other.conditionalTokenizationAction - } - - override fun hashCode(): Int = - Objects.hash( - conditionalBlock, - velocityLimitParams, - merchantLock, - conditional3dsAction, - conditionalAuthorizationAction, - conditionalAchAction, - conditionalTokenizationAction, - ) - - override fun toString(): String = - when { - conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}" - velocityLimitParams != null -> - "Parameters{velocityLimitParams=$velocityLimitParams}" - merchantLock != null -> "Parameters{merchantLock=$merchantLock}" - conditional3dsAction != null -> - "Parameters{conditional3dsAction=$conditional3dsAction}" - conditionalAuthorizationAction != null -> - "Parameters{conditionalAuthorizationAction=$conditionalAuthorizationAction}" - conditionalAchAction != null -> - "Parameters{conditionalAchAction=$conditionalAchAction}" - conditionalTokenizationAction != null -> - "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" - _json != null -> "Parameters{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Parameters") - } - - companion object { - - @JvmStatic - fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) = - Parameters(conditionalBlock = conditionalBlock) - - @JvmStatic - fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) = - Parameters(velocityLimitParams = velocityLimitParams) - - @JvmStatic - fun ofMerchantLock(merchantLock: MerchantLockParameters) = - Parameters(merchantLock = merchantLock) - - @JvmStatic - fun ofConditional3dsAction(conditional3dsAction: Conditional3dsActionParameters) = - Parameters(conditional3dsAction = conditional3dsAction) - - @JvmStatic - fun ofConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ) = Parameters(conditionalAuthorizationAction = conditionalAuthorizationAction) - - @JvmStatic - fun ofConditionalAchAction(conditionalAchAction: ConditionalAchActionParameters) = - Parameters(conditionalAchAction = conditionalAchAction) - - @JvmStatic - fun ofConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ) = Parameters(conditionalTokenizationAction = conditionalTokenizationAction) - } - - /** - * An interface that defines how to map each variant of [Parameters] to a value of type - * [T]. - */ - interface Visitor { - - fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T - - fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T - - fun visitMerchantLock(merchantLock: MerchantLockParameters): T - - fun visitConditional3dsAction( - conditional3dsAction: Conditional3dsActionParameters - ): T - - fun visitConditionalAuthorizationAction( - conditionalAuthorizationAction: ConditionalAuthorizationActionParameters - ): T - - fun visitConditionalAchAction( - conditionalAchAction: ConditionalAchActionParameters - ): T - - fun visitConditionalTokenizationAction( - conditionalTokenizationAction: ConditionalTokenizationActionParameters - ): T - - /** - * Maps an unknown variant of [Parameters] to a value of type [T]. - * - * An instance of [Parameters] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LithicInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LithicInvalidDataException("Unknown Parameters: $json") - } - } - - internal class Deserializer : BaseDeserializer(Parameters::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Parameters { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(conditionalBlock = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Parameters(velocityLimitParams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Parameters(merchantLock = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditional3dsAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters( - conditionalAuthorizationAction = it, - _json = json, - ) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Parameters(conditionalAchAction = it, _json = json) }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Parameters(conditionalTokenizationAction = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Parameters(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Parameters::class) { - - override fun serialize( - value: Parameters, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.conditionalBlock != null -> - generator.writeObject(value.conditionalBlock) - value.velocityLimitParams != null -> - generator.writeObject(value.velocityLimitParams) - value.merchantLock != null -> generator.writeObject(value.merchantLock) - value.conditional3dsAction != null -> - generator.writeObject(value.conditional3dsAction) - value.conditionalAuthorizationAction != null -> - generator.writeObject(value.conditionalAuthorizationAction) - value.conditionalAchAction != null -> - generator.writeObject(value.conditionalAchAction) - value.conditionalTokenizationAction != null -> - generator.writeObject(value.conditionalTokenizationAction) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Parameters") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftVersion && - parameters == other.parameters && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(parameters, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" - } - - /** The event stream during which the rule will be evaluated. */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The state of the Auth Rule */ - class AuthRuleState @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 ACTIVE = of("ACTIVE") - - @JvmField val INACTIVE = of("INACTIVE") - - @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) - } - - /** An enum containing [AuthRuleState]'s known values. */ - enum class Known { - ACTIVE, - INACTIVE, - } - - /** - * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleState] 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 { - ACTIVE, - INACTIVE, - /** - * An enum member indicating that [AuthRuleState] 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) { - ACTIVE -> Value.ACTIVE - INACTIVE -> Value.INACTIVE - 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) { - ACTIVE -> Known.ACTIVE - INACTIVE -> Known.INACTIVE - else -> throw LithicInvalidDataException("Unknown AuthRuleState: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleState = 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 AuthRuleState && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The type of Auth Rule. For certain rule types, this determines the event stream during which - * it will be evaluated. For rules that can be applied to one of several event streams, the - * effective one is defined by the separate `event_stream` field. - * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream. - * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. - * - `MERCHANT_LOCK`: AUTHORIZATION event stream. - * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, or ACH_DEBIT_RECEIPT event stream. - */ - class AuthRuleType @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 CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK") - - @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT") - - @JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK") - - @JvmField val CONDITIONAL_ACTION = of("CONDITIONAL_ACTION") - - @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value)) - } - - /** An enum containing [AuthRuleType]'s known values. */ - enum class Known { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - } - - /** - * An enum containing [AuthRuleType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [AuthRuleType] 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 { - CONDITIONAL_BLOCK, - VELOCITY_LIMIT, - MERCHANT_LOCK, - CONDITIONAL_ACTION, - /** - * An enum member indicating that [AuthRuleType] 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) { - CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Value.VELOCITY_LIMIT - MERCHANT_LOCK -> Value.MERCHANT_LOCK - CONDITIONAL_ACTION -> Value.CONDITIONAL_ACTION - 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) { - CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK - VELOCITY_LIMIT -> Known.VELOCITY_LIMIT - MERCHANT_LOCK -> Known.MERCHANT_LOCK - CONDITIONAL_ACTION -> Known.CONDITIONAL_ACTION - else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): AuthRuleType = 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 AuthRuleType && 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 V2UpdateResponse && - token == other.token && - accountTokens == other.accountTokens && - businessAccountTokens == other.businessAccountTokens && - cardTokens == other.cardTokens && - currentVersion == other.currentVersion && - draftVersion == other.draftVersion && - eventStream == other.eventStream && - lithicManaged == other.lithicManaged && - name == other.name && - programLevel == other.programLevel && - state == other.state && - type == other.type && - excludedCardTokens == other.excludedCardTokens && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - accountTokens, - businessAccountTokens, - cardTokens, - currentVersion, - draftVersion, - eventStream, - lithicManaged, - name, - programLevel, - state, - type, - excludedCardTokens, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "V2UpdateResponse{token=$token, accountTokens=$accountTokens, businessAccountTokens=$businessAccountTokens, cardTokens=$cardTokens, currentVersion=$currentVersion, draftVersion=$draftVersion, eventStream=$eventStream, lithicManaged=$lithicManaged, name=$name, programLevel=$programLevel, state=$state, type=$type, excludedCardTokens=$excludedCardTokens, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsync.kt index 6bafb65e9..32518f909 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsync.kt @@ -15,10 +15,8 @@ import com.lithic.api.models.TokenizationPauseParams import com.lithic.api.models.TokenizationResendActivationCodeParams import com.lithic.api.models.TokenizationRetrieveParams import com.lithic.api.models.TokenizationSimulateParams -import com.lithic.api.models.TokenizationSimulateResponse import com.lithic.api.models.TokenizationUnpauseParams import com.lithic.api.models.TokenizationUpdateDigitalCardArtParams -import com.lithic.api.models.TokenizationUpdateDigitalCardArtResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -276,15 +274,14 @@ interface TokenizationServiceAsync { * This endpoint is used to simulate a card's tokenization in the Digital Wallet and merchant * tokenization ecosystem. */ - fun simulate( - params: TokenizationSimulateParams - ): CompletableFuture = simulate(params, RequestOptions.none()) + fun simulate(params: TokenizationSimulateParams): CompletableFuture = + simulate(params, RequestOptions.none()) /** @see simulate */ fun simulate( params: TokenizationSimulateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * This endpoint is used to ask the card network to unpause a tokenization. A successful @@ -337,9 +334,7 @@ interface TokenizationServiceAsync { * with the art referenced in the card object's `digital_card_art_token` field. Reach out at * [lithic.com/contact](https://lithic.com/contact) for more information. */ - fun updateDigitalCardArt( - tokenizationToken: String - ): CompletableFuture = + fun updateDigitalCardArt(tokenizationToken: String): CompletableFuture = updateDigitalCardArt(tokenizationToken, TokenizationUpdateDigitalCardArtParams.none()) /** @see updateDigitalCardArt */ @@ -348,7 +343,7 @@ interface TokenizationServiceAsync { params: TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = updateDigitalCardArt( params.toBuilder().tokenizationToken(tokenizationToken).build(), requestOptions, @@ -359,26 +354,25 @@ interface TokenizationServiceAsync { tokenizationToken: String, params: TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams.none(), - ): CompletableFuture = + ): CompletableFuture = updateDigitalCardArt(tokenizationToken, params, RequestOptions.none()) /** @see updateDigitalCardArt */ fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see updateDigitalCardArt */ fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams - ): CompletableFuture = - updateDigitalCardArt(params, RequestOptions.none()) + ): CompletableFuture = updateDigitalCardArt(params, RequestOptions.none()) /** @see updateDigitalCardArt */ fun updateDigitalCardArt( tokenizationToken: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = updateDigitalCardArt( tokenizationToken, TokenizationUpdateDigitalCardArtParams.none(), @@ -647,14 +641,14 @@ interface TokenizationServiceAsync { */ fun simulate( params: TokenizationSimulateParams - ): CompletableFuture> = + ): CompletableFuture> = simulate(params, RequestOptions.none()) /** @see simulate */ fun simulate( params: TokenizationSimulateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `post /v1/tokenizations/{tokenization_token}/unpause`, @@ -702,7 +696,7 @@ interface TokenizationServiceAsync { */ fun updateDigitalCardArt( tokenizationToken: String - ): CompletableFuture> = + ): CompletableFuture> = updateDigitalCardArt(tokenizationToken, TokenizationUpdateDigitalCardArtParams.none()) /** @see updateDigitalCardArt */ @@ -711,7 +705,7 @@ interface TokenizationServiceAsync { params: TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = updateDigitalCardArt( params.toBuilder().tokenizationToken(tokenizationToken).build(), requestOptions, @@ -722,26 +716,26 @@ interface TokenizationServiceAsync { tokenizationToken: String, params: TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = updateDigitalCardArt(tokenizationToken, params, RequestOptions.none()) /** @see updateDigitalCardArt */ fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see updateDigitalCardArt */ fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams - ): CompletableFuture> = + ): CompletableFuture> = updateDigitalCardArt(params, RequestOptions.none()) /** @see updateDigitalCardArt */ fun updateDigitalCardArt( tokenizationToken: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = updateDigitalCardArt( tokenizationToken, TokenizationUpdateDigitalCardArtParams.none(), diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncImpl.kt index ba7d4b5ae..5e9e88e7e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncImpl.kt @@ -27,10 +27,8 @@ import com.lithic.api.models.TokenizationPauseParams import com.lithic.api.models.TokenizationResendActivationCodeParams import com.lithic.api.models.TokenizationRetrieveParams import com.lithic.api.models.TokenizationSimulateParams -import com.lithic.api.models.TokenizationSimulateResponse import com.lithic.api.models.TokenizationUnpauseParams import com.lithic.api.models.TokenizationUpdateDigitalCardArtParams -import com.lithic.api.models.TokenizationUpdateDigitalCardArtResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -92,7 +90,7 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption override fun simulate( params: TokenizationSimulateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/simulate/tokenizations withRawResponse().simulate(params, requestOptions).thenApply { it.parse() } @@ -106,7 +104,7 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption override fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/tokenizations/{tokenization_token}/update_digital_card_art withRawResponse().updateDigitalCardArt(params, requestOptions).thenApply { it.parse() } @@ -307,13 +305,13 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption } } - private val simulateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val simulateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun simulate( params: TokenizationSimulateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -365,13 +363,13 @@ class TokenizationServiceAsyncImpl internal constructor(private val clientOption } } - private val updateDigitalCardArtHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateDigitalCardArtHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("tokenizationToken", params.tokenizationToken().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt index d4e7ba2ea..0998d0b61 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt @@ -6,6 +6,7 @@ import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.AuthRule import com.lithic.api.models.AuthRuleV2CreateParams import com.lithic.api.models.AuthRuleV2DeleteParams import com.lithic.api.models.AuthRuleV2DraftParams @@ -16,13 +17,8 @@ import com.lithic.api.models.AuthRuleV2RetrieveFeaturesParams import com.lithic.api.models.AuthRuleV2RetrieveParams import com.lithic.api.models.AuthRuleV2RetrieveReportParams import com.lithic.api.models.AuthRuleV2UpdateParams -import com.lithic.api.models.V2CreateResponse -import com.lithic.api.models.V2DraftResponse -import com.lithic.api.models.V2PromoteResponse import com.lithic.api.models.V2RetrieveFeaturesResponse import com.lithic.api.models.V2RetrieveReportResponse -import com.lithic.api.models.V2RetrieveResponse -import com.lithic.api.models.V2UpdateResponse import com.lithic.api.services.async.authRules.v2.BacktestServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -44,17 +40,17 @@ interface V2ServiceAsync { fun backtests(): BacktestServiceAsync /** Creates a new V2 Auth rule in draft mode */ - fun create(params: AuthRuleV2CreateParams): CompletableFuture = + fun create(params: AuthRuleV2CreateParams): CompletableFuture = create(params, RequestOptions.none()) /** @see create */ fun create( params: AuthRuleV2CreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** Fetches a V2 Auth rule by its token */ - fun retrieve(authRuleToken: String): CompletableFuture = + fun retrieve(authRuleToken: String): CompletableFuture = retrieve(authRuleToken, AuthRuleV2RetrieveParams.none()) /** @see retrieve */ @@ -62,31 +58,30 @@ interface V2ServiceAsync { authRuleToken: String, params: AuthRuleV2RetrieveParams = AuthRuleV2RetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieve(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see retrieve */ fun retrieve( authRuleToken: String, params: AuthRuleV2RetrieveParams = AuthRuleV2RetrieveParams.none(), - ): CompletableFuture = - retrieve(authRuleToken, params, RequestOptions.none()) + ): CompletableFuture = retrieve(authRuleToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: AuthRuleV2RetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieve */ - fun retrieve(params: AuthRuleV2RetrieveParams): CompletableFuture = + fun retrieve(params: AuthRuleV2RetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( authRuleToken: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = retrieve(authRuleToken, AuthRuleV2RetrieveParams.none(), requestOptions) /** @@ -95,28 +90,26 @@ interface V2ServiceAsync { * If `account_tokens`, `card_tokens`, `program_level`, or `excluded_card_tokens` is provided, * this will replace existing associations with the provided list of entities. */ - fun update( - authRuleToken: String, - params: AuthRuleV2UpdateParams, - ): CompletableFuture = update(authRuleToken, params, RequestOptions.none()) + fun update(authRuleToken: String, params: AuthRuleV2UpdateParams): CompletableFuture = + update(authRuleToken, params, RequestOptions.none()) /** @see update */ fun update( authRuleToken: String, params: AuthRuleV2UpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = update(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see update */ - fun update(params: AuthRuleV2UpdateParams): CompletableFuture = + fun update(params: AuthRuleV2UpdateParams): CompletableFuture = update(params, RequestOptions.none()) /** @see update */ fun update( params: AuthRuleV2UpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** Lists V2 Auth rules */ fun list(): CompletableFuture = list(AuthRuleV2ListParams.none()) @@ -174,7 +167,7 @@ interface V2ServiceAsync { * This can also be utilized to reset the draft parameters, causing a draft version to no longer * be ran in shadow mode. */ - fun draft(authRuleToken: String): CompletableFuture = + fun draft(authRuleToken: String): CompletableFuture = draft(authRuleToken, AuthRuleV2DraftParams.none()) /** @see draft */ @@ -182,37 +175,34 @@ interface V2ServiceAsync { authRuleToken: String, params: AuthRuleV2DraftParams = AuthRuleV2DraftParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = draft(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see draft */ fun draft( authRuleToken: String, params: AuthRuleV2DraftParams = AuthRuleV2DraftParams.none(), - ): CompletableFuture = draft(authRuleToken, params, RequestOptions.none()) + ): CompletableFuture = draft(authRuleToken, params, RequestOptions.none()) /** @see draft */ fun draft( params: AuthRuleV2DraftParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see draft */ - fun draft(params: AuthRuleV2DraftParams): CompletableFuture = + fun draft(params: AuthRuleV2DraftParams): CompletableFuture = draft(params, RequestOptions.none()) /** @see draft */ - fun draft( - authRuleToken: String, - requestOptions: RequestOptions, - ): CompletableFuture = + fun draft(authRuleToken: String, requestOptions: RequestOptions): CompletableFuture = draft(authRuleToken, AuthRuleV2DraftParams.none(), requestOptions) /** * Promotes the draft version of an Auth rule to the currently active version such that it is * enforced in the respective stream. */ - fun promote(authRuleToken: String): CompletableFuture = + fun promote(authRuleToken: String): CompletableFuture = promote(authRuleToken, AuthRuleV2PromoteParams.none()) /** @see promote */ @@ -220,30 +210,30 @@ interface V2ServiceAsync { authRuleToken: String, params: AuthRuleV2PromoteParams = AuthRuleV2PromoteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = promote(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see promote */ fun promote( authRuleToken: String, params: AuthRuleV2PromoteParams = AuthRuleV2PromoteParams.none(), - ): CompletableFuture = promote(authRuleToken, params, RequestOptions.none()) + ): CompletableFuture = promote(authRuleToken, params, RequestOptions.none()) /** @see promote */ fun promote( params: AuthRuleV2PromoteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see promote */ - fun promote(params: AuthRuleV2PromoteParams): CompletableFuture = + fun promote(params: AuthRuleV2PromoteParams): CompletableFuture = promote(params, RequestOptions.none()) /** @see promote */ fun promote( authRuleToken: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = promote(authRuleToken, AuthRuleV2PromoteParams.none(), requestOptions) /** @@ -346,24 +336,20 @@ interface V2ServiceAsync { * Returns a raw HTTP response for `post /v2/auth_rules`, but is otherwise the same as * [V2ServiceAsync.create]. */ - fun create( - params: AuthRuleV2CreateParams - ): CompletableFuture> = + fun create(params: AuthRuleV2CreateParams): CompletableFuture> = create(params, RequestOptions.none()) /** @see create */ fun create( params: AuthRuleV2CreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v2/auth_rules/{auth_rule_token}`, but is otherwise * the same as [V2ServiceAsync.retrieve]. */ - fun retrieve( - authRuleToken: String - ): CompletableFuture> = + fun retrieve(authRuleToken: String): CompletableFuture> = retrieve(authRuleToken, AuthRuleV2RetrieveParams.none()) /** @see retrieve */ @@ -371,33 +357,32 @@ interface V2ServiceAsync { authRuleToken: String, params: AuthRuleV2RetrieveParams = AuthRuleV2RetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see retrieve */ fun retrieve( authRuleToken: String, params: AuthRuleV2RetrieveParams = AuthRuleV2RetrieveParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve(authRuleToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: AuthRuleV2RetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see retrieve */ fun retrieve( params: AuthRuleV2RetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( authRuleToken: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = retrieve(authRuleToken, AuthRuleV2RetrieveParams.none(), requestOptions) /** @@ -407,7 +392,7 @@ interface V2ServiceAsync { fun update( authRuleToken: String, params: AuthRuleV2UpdateParams, - ): CompletableFuture> = + ): CompletableFuture> = update(authRuleToken, params, RequestOptions.none()) /** @see update */ @@ -415,20 +400,18 @@ interface V2ServiceAsync { authRuleToken: String, params: AuthRuleV2UpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = update(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see update */ - fun update( - params: AuthRuleV2UpdateParams - ): CompletableFuture> = + fun update(params: AuthRuleV2UpdateParams): CompletableFuture> = update(params, RequestOptions.none()) /** @see update */ fun update( params: AuthRuleV2UpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `get /v2/auth_rules`, but is otherwise the same as @@ -497,7 +480,7 @@ interface V2ServiceAsync { * Returns a raw HTTP response for `post /v2/auth_rules/{auth_rule_token}/draft`, but is * otherwise the same as [V2ServiceAsync.draft]. */ - fun draft(authRuleToken: String): CompletableFuture> = + fun draft(authRuleToken: String): CompletableFuture> = draft(authRuleToken, AuthRuleV2DraftParams.none()) /** @see draft */ @@ -505,40 +488,38 @@ interface V2ServiceAsync { authRuleToken: String, params: AuthRuleV2DraftParams = AuthRuleV2DraftParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = draft(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see draft */ fun draft( authRuleToken: String, params: AuthRuleV2DraftParams = AuthRuleV2DraftParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = draft(authRuleToken, params, RequestOptions.none()) /** @see draft */ fun draft( params: AuthRuleV2DraftParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see draft */ - fun draft( - params: AuthRuleV2DraftParams - ): CompletableFuture> = + fun draft(params: AuthRuleV2DraftParams): CompletableFuture> = draft(params, RequestOptions.none()) /** @see draft */ fun draft( authRuleToken: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = draft(authRuleToken, AuthRuleV2DraftParams.none(), requestOptions) /** * Returns a raw HTTP response for `post /v2/auth_rules/{auth_rule_token}/promote`, but is * otherwise the same as [V2ServiceAsync.promote]. */ - fun promote(authRuleToken: String): CompletableFuture> = + fun promote(authRuleToken: String): CompletableFuture> = promote(authRuleToken, AuthRuleV2PromoteParams.none()) /** @see promote */ @@ -546,33 +527,31 @@ interface V2ServiceAsync { authRuleToken: String, params: AuthRuleV2PromoteParams = AuthRuleV2PromoteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = promote(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see promote */ fun promote( authRuleToken: String, params: AuthRuleV2PromoteParams = AuthRuleV2PromoteParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = promote(authRuleToken, params, RequestOptions.none()) /** @see promote */ fun promote( params: AuthRuleV2PromoteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see promote */ - fun promote( - params: AuthRuleV2PromoteParams - ): CompletableFuture> = + fun promote(params: AuthRuleV2PromoteParams): CompletableFuture> = promote(params, RequestOptions.none()) /** @see promote */ fun promote( authRuleToken: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = promote(authRuleToken, AuthRuleV2PromoteParams.none(), requestOptions) /** diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt index 7cd57cb22..cdc0b2f24 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import com.lithic.api.core.http.HttpResponseFor 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.AuthRule import com.lithic.api.models.AuthRuleV2CreateParams import com.lithic.api.models.AuthRuleV2DeleteParams import com.lithic.api.models.AuthRuleV2DraftParams @@ -28,13 +29,8 @@ import com.lithic.api.models.AuthRuleV2RetrieveFeaturesParams import com.lithic.api.models.AuthRuleV2RetrieveParams import com.lithic.api.models.AuthRuleV2RetrieveReportParams import com.lithic.api.models.AuthRuleV2UpdateParams -import com.lithic.api.models.V2CreateResponse -import com.lithic.api.models.V2DraftResponse -import com.lithic.api.models.V2PromoteResponse import com.lithic.api.models.V2RetrieveFeaturesResponse import com.lithic.api.models.V2RetrieveReportResponse -import com.lithic.api.models.V2RetrieveResponse -import com.lithic.api.models.V2UpdateResponse import com.lithic.api.services.async.authRules.v2.BacktestServiceAsync import com.lithic.api.services.async.authRules.v2.BacktestServiceAsyncImpl import java.util.concurrent.CompletableFuture @@ -60,21 +56,21 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO override fun create( params: AuthRuleV2CreateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v2/auth_rules withRawResponse().create(params, requestOptions).thenApply { it.parse() } override fun retrieve( params: AuthRuleV2RetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v2/auth_rules/{auth_rule_token} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } override fun update( params: AuthRuleV2UpdateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // patch /v2/auth_rules/{auth_rule_token} withRawResponse().update(params, requestOptions).thenApply { it.parse() } @@ -95,14 +91,14 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO override fun draft( params: AuthRuleV2DraftParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v2/auth_rules/{auth_rule_token}/draft withRawResponse().draft(params, requestOptions).thenApply { it.parse() } override fun promote( params: AuthRuleV2PromoteParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v2/auth_rules/{auth_rule_token}/promote withRawResponse().promote(params, requestOptions).thenApply { it.parse() } @@ -139,13 +135,13 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO override fun backtests(): BacktestServiceAsync.WithRawResponse = backtests - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: AuthRuleV2CreateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -170,13 +166,13 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AuthRuleV2RetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("authRuleToken", params.authRuleToken().getOrNull()) @@ -203,13 +199,13 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: AuthRuleV2UpdateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("authRuleToken", params.authRuleToken().getOrNull()) @@ -302,13 +298,13 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } } - private val draftHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val draftHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun draft( params: AuthRuleV2DraftParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("authRuleToken", params.authRuleToken().getOrNull()) @@ -336,13 +332,13 @@ class V2ServiceAsyncImpl internal constructor(private val clientOptions: ClientO } } - private val promoteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val promoteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun promote( params: AuthRuleV2PromoteParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("authRuleToken", params.authRuleToken().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationService.kt index 27cfc0a3e..54c62fb19 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationService.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationService.kt @@ -16,10 +16,8 @@ import com.lithic.api.models.TokenizationPauseParams import com.lithic.api.models.TokenizationResendActivationCodeParams import com.lithic.api.models.TokenizationRetrieveParams import com.lithic.api.models.TokenizationSimulateParams -import com.lithic.api.models.TokenizationSimulateResponse import com.lithic.api.models.TokenizationUnpauseParams import com.lithic.api.models.TokenizationUpdateDigitalCardArtParams -import com.lithic.api.models.TokenizationUpdateDigitalCardArtResponse import java.util.function.Consumer interface TokenizationService { @@ -254,14 +252,14 @@ interface TokenizationService { * This endpoint is used to simulate a card's tokenization in the Digital Wallet and merchant * tokenization ecosystem. */ - fun simulate(params: TokenizationSimulateParams): TokenizationSimulateResponse = + fun simulate(params: TokenizationSimulateParams): Tokenization = simulate(params, RequestOptions.none()) /** @see simulate */ fun simulate( params: TokenizationSimulateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): TokenizationSimulateResponse + ): Tokenization /** * This endpoint is used to ask the card network to unpause a tokenization. A successful @@ -309,7 +307,7 @@ interface TokenizationService { * with the art referenced in the card object's `digital_card_art_token` field. Reach out at * [lithic.com/contact](https://lithic.com/contact) for more information. */ - fun updateDigitalCardArt(tokenizationToken: String): TokenizationUpdateDigitalCardArtResponse = + fun updateDigitalCardArt(tokenizationToken: String): Tokenization = updateDigitalCardArt(tokenizationToken, TokenizationUpdateDigitalCardArtParams.none()) /** @see updateDigitalCardArt */ @@ -318,7 +316,7 @@ interface TokenizationService { params: TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): TokenizationUpdateDigitalCardArtResponse = + ): Tokenization = updateDigitalCardArt( params.toBuilder().tokenizationToken(tokenizationToken).build(), requestOptions, @@ -329,26 +327,23 @@ interface TokenizationService { tokenizationToken: String, params: TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams.none(), - ): TokenizationUpdateDigitalCardArtResponse = - updateDigitalCardArt(tokenizationToken, params, RequestOptions.none()) + ): Tokenization = updateDigitalCardArt(tokenizationToken, params, RequestOptions.none()) /** @see updateDigitalCardArt */ fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, requestOptions: RequestOptions = RequestOptions.none(), - ): TokenizationUpdateDigitalCardArtResponse + ): Tokenization /** @see updateDigitalCardArt */ - fun updateDigitalCardArt( - params: TokenizationUpdateDigitalCardArtParams - ): TokenizationUpdateDigitalCardArtResponse = + fun updateDigitalCardArt(params: TokenizationUpdateDigitalCardArtParams): Tokenization = updateDigitalCardArt(params, RequestOptions.none()) /** @see updateDigitalCardArt */ fun updateDigitalCardArt( tokenizationToken: String, requestOptions: RequestOptions, - ): TokenizationUpdateDigitalCardArtResponse = + ): Tokenization = updateDigitalCardArt( tokenizationToken, TokenizationUpdateDigitalCardArtParams.none(), @@ -630,16 +625,15 @@ interface TokenizationService { * same as [TokenizationService.simulate]. */ @MustBeClosed - fun simulate( - params: TokenizationSimulateParams - ): HttpResponseFor = simulate(params, RequestOptions.none()) + fun simulate(params: TokenizationSimulateParams): HttpResponseFor = + simulate(params, RequestOptions.none()) /** @see simulate */ @MustBeClosed fun simulate( params: TokenizationSimulateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `post /v1/tokenizations/{tokenization_token}/unpause`, @@ -688,9 +682,7 @@ interface TokenizationService { * same as [TokenizationService.updateDigitalCardArt]. */ @MustBeClosed - fun updateDigitalCardArt( - tokenizationToken: String - ): HttpResponseFor = + fun updateDigitalCardArt(tokenizationToken: String): HttpResponseFor = updateDigitalCardArt(tokenizationToken, TokenizationUpdateDigitalCardArtParams.none()) /** @see updateDigitalCardArt */ @@ -700,7 +692,7 @@ interface TokenizationService { params: TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = updateDigitalCardArt( params.toBuilder().tokenizationToken(tokenizationToken).build(), requestOptions, @@ -712,7 +704,7 @@ interface TokenizationService { tokenizationToken: String, params: TokenizationUpdateDigitalCardArtParams = TokenizationUpdateDigitalCardArtParams.none(), - ): HttpResponseFor = + ): HttpResponseFor = updateDigitalCardArt(tokenizationToken, params, RequestOptions.none()) /** @see updateDigitalCardArt */ @@ -720,21 +712,20 @@ interface TokenizationService { fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see updateDigitalCardArt */ @MustBeClosed fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams - ): HttpResponseFor = - updateDigitalCardArt(params, RequestOptions.none()) + ): HttpResponseFor = updateDigitalCardArt(params, RequestOptions.none()) /** @see updateDigitalCardArt */ @MustBeClosed fun updateDigitalCardArt( tokenizationToken: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = updateDigitalCardArt( tokenizationToken, TokenizationUpdateDigitalCardArtParams.none(), diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationServiceImpl.kt index 02e97eb10..cfc8785d4 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TokenizationServiceImpl.kt @@ -27,10 +27,8 @@ import com.lithic.api.models.TokenizationPauseParams import com.lithic.api.models.TokenizationResendActivationCodeParams import com.lithic.api.models.TokenizationRetrieveParams import com.lithic.api.models.TokenizationSimulateParams -import com.lithic.api.models.TokenizationSimulateResponse import com.lithic.api.models.TokenizationUnpauseParams import com.lithic.api.models.TokenizationUpdateDigitalCardArtParams -import com.lithic.api.models.TokenizationUpdateDigitalCardArtResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -86,7 +84,7 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl override fun simulate( params: TokenizationSimulateParams, requestOptions: RequestOptions, - ): TokenizationSimulateResponse = + ): Tokenization = // post /v1/simulate/tokenizations withRawResponse().simulate(params, requestOptions).parse() @@ -98,7 +96,7 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl override fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, requestOptions: RequestOptions, - ): TokenizationUpdateDigitalCardArtResponse = + ): Tokenization = // post /v1/tokenizations/{tokenization_token}/update_digital_card_art withRawResponse().updateDigitalCardArt(params, requestOptions).parse() @@ -280,13 +278,13 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl } } - private val simulateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val simulateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun simulate( params: TokenizationSimulateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -332,13 +330,13 @@ class TokenizationServiceImpl internal constructor(private val clientOptions: Cl } } - private val updateDigitalCardArtHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateDigitalCardArtHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun updateDigitalCardArt( params: TokenizationUpdateDigitalCardArtParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("tokenizationToken", params.tokenizationToken().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt index b14d6ca58..d7bbf2379 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt @@ -7,6 +7,7 @@ import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.AuthRule import com.lithic.api.models.AuthRuleV2CreateParams import com.lithic.api.models.AuthRuleV2DeleteParams import com.lithic.api.models.AuthRuleV2DraftParams @@ -17,13 +18,8 @@ import com.lithic.api.models.AuthRuleV2RetrieveFeaturesParams import com.lithic.api.models.AuthRuleV2RetrieveParams import com.lithic.api.models.AuthRuleV2RetrieveReportParams import com.lithic.api.models.AuthRuleV2UpdateParams -import com.lithic.api.models.V2CreateResponse -import com.lithic.api.models.V2DraftResponse -import com.lithic.api.models.V2PromoteResponse import com.lithic.api.models.V2RetrieveFeaturesResponse import com.lithic.api.models.V2RetrieveReportResponse -import com.lithic.api.models.V2RetrieveResponse -import com.lithic.api.models.V2UpdateResponse import com.lithic.api.services.blocking.authRules.v2.BacktestService import java.util.function.Consumer @@ -44,17 +40,16 @@ interface V2Service { fun backtests(): BacktestService /** Creates a new V2 Auth rule in draft mode */ - fun create(params: AuthRuleV2CreateParams): V2CreateResponse = - create(params, RequestOptions.none()) + fun create(params: AuthRuleV2CreateParams): AuthRule = create(params, RequestOptions.none()) /** @see create */ fun create( params: AuthRuleV2CreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): V2CreateResponse + ): AuthRule /** Fetches a V2 Auth rule by its token */ - fun retrieve(authRuleToken: String): V2RetrieveResponse = + fun retrieve(authRuleToken: String): AuthRule = retrieve(authRuleToken, AuthRuleV2RetrieveParams.none()) /** @see retrieve */ @@ -62,27 +57,26 @@ interface V2Service { authRuleToken: String, params: AuthRuleV2RetrieveParams = AuthRuleV2RetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): V2RetrieveResponse = - retrieve(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) + ): AuthRule = retrieve(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see retrieve */ fun retrieve( authRuleToken: String, params: AuthRuleV2RetrieveParams = AuthRuleV2RetrieveParams.none(), - ): V2RetrieveResponse = retrieve(authRuleToken, params, RequestOptions.none()) + ): AuthRule = retrieve(authRuleToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: AuthRuleV2RetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): V2RetrieveResponse + ): AuthRule /** @see retrieve */ - fun retrieve(params: AuthRuleV2RetrieveParams): V2RetrieveResponse = + fun retrieve(params: AuthRuleV2RetrieveParams): AuthRule = retrieve(params, RequestOptions.none()) /** @see retrieve */ - fun retrieve(authRuleToken: String, requestOptions: RequestOptions): V2RetrieveResponse = + fun retrieve(authRuleToken: String, requestOptions: RequestOptions): AuthRule = retrieve(authRuleToken, AuthRuleV2RetrieveParams.none(), requestOptions) /** @@ -91,7 +85,7 @@ interface V2Service { * If `account_tokens`, `card_tokens`, `program_level`, or `excluded_card_tokens` is provided, * this will replace existing associations with the provided list of entities. */ - fun update(authRuleToken: String, params: AuthRuleV2UpdateParams): V2UpdateResponse = + fun update(authRuleToken: String, params: AuthRuleV2UpdateParams): AuthRule = update(authRuleToken, params, RequestOptions.none()) /** @see update */ @@ -99,18 +93,16 @@ interface V2Service { authRuleToken: String, params: AuthRuleV2UpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): V2UpdateResponse = - update(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) + ): AuthRule = update(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see update */ - fun update(params: AuthRuleV2UpdateParams): V2UpdateResponse = - update(params, RequestOptions.none()) + fun update(params: AuthRuleV2UpdateParams): AuthRule = update(params, RequestOptions.none()) /** @see update */ fun update( params: AuthRuleV2UpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): V2UpdateResponse + ): AuthRule /** Lists V2 Auth rules */ fun list(): AuthRuleV2ListPage = list(AuthRuleV2ListParams.none()) @@ -164,41 +156,39 @@ interface V2Service { * This can also be utilized to reset the draft parameters, causing a draft version to no longer * be ran in shadow mode. */ - fun draft(authRuleToken: String): V2DraftResponse = - draft(authRuleToken, AuthRuleV2DraftParams.none()) + fun draft(authRuleToken: String): AuthRule = draft(authRuleToken, AuthRuleV2DraftParams.none()) /** @see draft */ fun draft( authRuleToken: String, params: AuthRuleV2DraftParams = AuthRuleV2DraftParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): V2DraftResponse = - draft(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) + ): AuthRule = draft(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see draft */ fun draft( authRuleToken: String, params: AuthRuleV2DraftParams = AuthRuleV2DraftParams.none(), - ): V2DraftResponse = draft(authRuleToken, params, RequestOptions.none()) + ): AuthRule = draft(authRuleToken, params, RequestOptions.none()) /** @see draft */ fun draft( params: AuthRuleV2DraftParams, requestOptions: RequestOptions = RequestOptions.none(), - ): V2DraftResponse + ): AuthRule /** @see draft */ - fun draft(params: AuthRuleV2DraftParams): V2DraftResponse = draft(params, RequestOptions.none()) + fun draft(params: AuthRuleV2DraftParams): AuthRule = draft(params, RequestOptions.none()) /** @see draft */ - fun draft(authRuleToken: String, requestOptions: RequestOptions): V2DraftResponse = + fun draft(authRuleToken: String, requestOptions: RequestOptions): AuthRule = draft(authRuleToken, AuthRuleV2DraftParams.none(), requestOptions) /** * Promotes the draft version of an Auth rule to the currently active version such that it is * enforced in the respective stream. */ - fun promote(authRuleToken: String): V2PromoteResponse = + fun promote(authRuleToken: String): AuthRule = promote(authRuleToken, AuthRuleV2PromoteParams.none()) /** @see promote */ @@ -206,27 +196,25 @@ interface V2Service { authRuleToken: String, params: AuthRuleV2PromoteParams = AuthRuleV2PromoteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): V2PromoteResponse = - promote(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) + ): AuthRule = promote(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see promote */ fun promote( authRuleToken: String, params: AuthRuleV2PromoteParams = AuthRuleV2PromoteParams.none(), - ): V2PromoteResponse = promote(authRuleToken, params, RequestOptions.none()) + ): AuthRule = promote(authRuleToken, params, RequestOptions.none()) /** @see promote */ fun promote( params: AuthRuleV2PromoteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): V2PromoteResponse + ): AuthRule /** @see promote */ - fun promote(params: AuthRuleV2PromoteParams): V2PromoteResponse = - promote(params, RequestOptions.none()) + fun promote(params: AuthRuleV2PromoteParams): AuthRule = promote(params, RequestOptions.none()) /** @see promote */ - fun promote(authRuleToken: String, requestOptions: RequestOptions): V2PromoteResponse = + fun promote(authRuleToken: String, requestOptions: RequestOptions): AuthRule = promote(authRuleToken, AuthRuleV2PromoteParams.none(), requestOptions) /** @@ -325,7 +313,7 @@ interface V2Service { * [V2Service.create]. */ @MustBeClosed - fun create(params: AuthRuleV2CreateParams): HttpResponseFor = + fun create(params: AuthRuleV2CreateParams): HttpResponseFor = create(params, RequestOptions.none()) /** @see create */ @@ -333,14 +321,14 @@ interface V2Service { fun create( params: AuthRuleV2CreateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v2/auth_rules/{auth_rule_token}`, but is otherwise * the same as [V2Service.retrieve]. */ @MustBeClosed - fun retrieve(authRuleToken: String): HttpResponseFor = + fun retrieve(authRuleToken: String): HttpResponseFor = retrieve(authRuleToken, AuthRuleV2RetrieveParams.none()) /** @see retrieve */ @@ -349,7 +337,7 @@ interface V2Service { authRuleToken: String, params: AuthRuleV2RetrieveParams = AuthRuleV2RetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = retrieve(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see retrieve */ @@ -357,19 +345,18 @@ interface V2Service { fun retrieve( authRuleToken: String, params: AuthRuleV2RetrieveParams = AuthRuleV2RetrieveParams.none(), - ): HttpResponseFor = - retrieve(authRuleToken, params, RequestOptions.none()) + ): HttpResponseFor = retrieve(authRuleToken, params, RequestOptions.none()) /** @see retrieve */ @MustBeClosed fun retrieve( params: AuthRuleV2RetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see retrieve */ @MustBeClosed - fun retrieve(params: AuthRuleV2RetrieveParams): HttpResponseFor = + fun retrieve(params: AuthRuleV2RetrieveParams): HttpResponseFor = retrieve(params, RequestOptions.none()) /** @see retrieve */ @@ -377,7 +364,7 @@ interface V2Service { fun retrieve( authRuleToken: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = retrieve(authRuleToken, AuthRuleV2RetrieveParams.none(), requestOptions) /** @@ -388,7 +375,7 @@ interface V2Service { fun update( authRuleToken: String, params: AuthRuleV2UpdateParams, - ): HttpResponseFor = update(authRuleToken, params, RequestOptions.none()) + ): HttpResponseFor = update(authRuleToken, params, RequestOptions.none()) /** @see update */ @MustBeClosed @@ -396,12 +383,12 @@ interface V2Service { authRuleToken: String, params: AuthRuleV2UpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = update(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see update */ @MustBeClosed - fun update(params: AuthRuleV2UpdateParams): HttpResponseFor = + fun update(params: AuthRuleV2UpdateParams): HttpResponseFor = update(params, RequestOptions.none()) /** @see update */ @@ -409,7 +396,7 @@ interface V2Service { fun update( params: AuthRuleV2UpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `get /v2/auth_rules`, but is otherwise the same as @@ -482,7 +469,7 @@ interface V2Service { * otherwise the same as [V2Service.draft]. */ @MustBeClosed - fun draft(authRuleToken: String): HttpResponseFor = + fun draft(authRuleToken: String): HttpResponseFor = draft(authRuleToken, AuthRuleV2DraftParams.none()) /** @see draft */ @@ -491,7 +478,7 @@ interface V2Service { authRuleToken: String, params: AuthRuleV2DraftParams = AuthRuleV2DraftParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = draft(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see draft */ @@ -499,18 +486,18 @@ interface V2Service { fun draft( authRuleToken: String, params: AuthRuleV2DraftParams = AuthRuleV2DraftParams.none(), - ): HttpResponseFor = draft(authRuleToken, params, RequestOptions.none()) + ): HttpResponseFor = draft(authRuleToken, params, RequestOptions.none()) /** @see draft */ @MustBeClosed fun draft( params: AuthRuleV2DraftParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see draft */ @MustBeClosed - fun draft(params: AuthRuleV2DraftParams): HttpResponseFor = + fun draft(params: AuthRuleV2DraftParams): HttpResponseFor = draft(params, RequestOptions.none()) /** @see draft */ @@ -518,7 +505,7 @@ interface V2Service { fun draft( authRuleToken: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = draft(authRuleToken, AuthRuleV2DraftParams.none(), requestOptions) /** @@ -526,7 +513,7 @@ interface V2Service { * otherwise the same as [V2Service.promote]. */ @MustBeClosed - fun promote(authRuleToken: String): HttpResponseFor = + fun promote(authRuleToken: String): HttpResponseFor = promote(authRuleToken, AuthRuleV2PromoteParams.none()) /** @see promote */ @@ -535,7 +522,7 @@ interface V2Service { authRuleToken: String, params: AuthRuleV2PromoteParams = AuthRuleV2PromoteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = promote(params.toBuilder().authRuleToken(authRuleToken).build(), requestOptions) /** @see promote */ @@ -543,19 +530,18 @@ interface V2Service { fun promote( authRuleToken: String, params: AuthRuleV2PromoteParams = AuthRuleV2PromoteParams.none(), - ): HttpResponseFor = - promote(authRuleToken, params, RequestOptions.none()) + ): HttpResponseFor = promote(authRuleToken, params, RequestOptions.none()) /** @see promote */ @MustBeClosed fun promote( params: AuthRuleV2PromoteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see promote */ @MustBeClosed - fun promote(params: AuthRuleV2PromoteParams): HttpResponseFor = + fun promote(params: AuthRuleV2PromoteParams): HttpResponseFor = promote(params, RequestOptions.none()) /** @see promote */ @@ -563,7 +549,7 @@ interface V2Service { fun promote( authRuleToken: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = promote(authRuleToken, AuthRuleV2PromoteParams.none(), requestOptions) /** diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt index 209c9e281..61a6e6c4f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt @@ -17,6 +17,7 @@ import com.lithic.api.core.http.HttpResponseFor 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.AuthRule import com.lithic.api.models.AuthRuleV2CreateParams import com.lithic.api.models.AuthRuleV2DeleteParams import com.lithic.api.models.AuthRuleV2DraftParams @@ -28,13 +29,8 @@ import com.lithic.api.models.AuthRuleV2RetrieveFeaturesParams import com.lithic.api.models.AuthRuleV2RetrieveParams import com.lithic.api.models.AuthRuleV2RetrieveReportParams import com.lithic.api.models.AuthRuleV2UpdateParams -import com.lithic.api.models.V2CreateResponse -import com.lithic.api.models.V2DraftResponse -import com.lithic.api.models.V2PromoteResponse import com.lithic.api.models.V2RetrieveFeaturesResponse import com.lithic.api.models.V2RetrieveReportResponse -import com.lithic.api.models.V2RetrieveResponse -import com.lithic.api.models.V2UpdateResponse import com.lithic.api.services.blocking.authRules.v2.BacktestService import com.lithic.api.services.blocking.authRules.v2.BacktestServiceImpl import java.util.function.Consumer @@ -55,24 +51,18 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption override fun backtests(): BacktestService = backtests - override fun create( - params: AuthRuleV2CreateParams, - requestOptions: RequestOptions, - ): V2CreateResponse = + override fun create(params: AuthRuleV2CreateParams, requestOptions: RequestOptions): AuthRule = // post /v2/auth_rules withRawResponse().create(params, requestOptions).parse() override fun retrieve( params: AuthRuleV2RetrieveParams, requestOptions: RequestOptions, - ): V2RetrieveResponse = + ): AuthRule = // get /v2/auth_rules/{auth_rule_token} withRawResponse().retrieve(params, requestOptions).parse() - override fun update( - params: AuthRuleV2UpdateParams, - requestOptions: RequestOptions, - ): V2UpdateResponse = + override fun update(params: AuthRuleV2UpdateParams, requestOptions: RequestOptions): AuthRule = // patch /v2/auth_rules/{auth_rule_token} withRawResponse().update(params, requestOptions).parse() @@ -88,17 +78,14 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption withRawResponse().delete(params, requestOptions) } - override fun draft( - params: AuthRuleV2DraftParams, - requestOptions: RequestOptions, - ): V2DraftResponse = + override fun draft(params: AuthRuleV2DraftParams, requestOptions: RequestOptions): AuthRule = // post /v2/auth_rules/{auth_rule_token}/draft withRawResponse().draft(params, requestOptions).parse() override fun promote( params: AuthRuleV2PromoteParams, requestOptions: RequestOptions, - ): V2PromoteResponse = + ): AuthRule = // post /v2/auth_rules/{auth_rule_token}/promote withRawResponse().promote(params, requestOptions).parse() @@ -135,13 +122,13 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption override fun backtests(): BacktestService.WithRawResponse = backtests - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun create( params: AuthRuleV2CreateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -163,13 +150,13 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } } - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: AuthRuleV2RetrieveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("authRuleToken", params.authRuleToken().getOrNull()) @@ -193,13 +180,13 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } } - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun update( params: AuthRuleV2UpdateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("authRuleToken", params.authRuleToken().getOrNull()) @@ -282,13 +269,13 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } } - private val draftHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val draftHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun draft( params: AuthRuleV2DraftParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("authRuleToken", params.authRuleToken().getOrNull()) @@ -313,13 +300,13 @@ class V2ServiceImpl internal constructor(private val clientOptions: ClientOption } } - private val promoteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val promoteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun promote( params: AuthRuleV2PromoteParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("authRuleToken", params.authRuleToken().getOrNull()) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateParamsTest.kt index f7fffbd0e..41cf0349d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreateParamsTest.kt @@ -47,7 +47,7 @@ internal class AccountHolderCreateParamsTest { .governmentId("12-3456789") .legalBusinessName("Busy Business, Inc.") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("Example Business Solutions") .parentCompany("parent_company") .build() ) @@ -75,7 +75,7 @@ internal class AccountHolderCreateParamsTest { "Software company selling solutions to the restaurant industry" ) .tosTimestamp("2022-03-08T08:00:00Z") - .workflow(Kyb.Workflow.KYB_BASIC) + .workflow(Kyb.Workflow.KYB_BYO) .addBeneficialOwnerEntity( Kyb.BusinessEntity.builder() .address( @@ -91,7 +91,7 @@ internal class AccountHolderCreateParamsTest { .governmentId("98-7654321") .legalBusinessName("Majority Holdings LLC") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("MHoldings") .parentCompany("parent_company") .build() ) @@ -144,7 +144,7 @@ internal class AccountHolderCreateParamsTest { .governmentId("12-3456789") .legalBusinessName("Busy Business, Inc.") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("Example Business Solutions") .parentCompany("parent_company") .build() ) @@ -172,7 +172,7 @@ internal class AccountHolderCreateParamsTest { "Software company selling solutions to the restaurant industry" ) .tosTimestamp("2022-03-08T08:00:00Z") - .workflow(Kyb.Workflow.KYB_BASIC) + .workflow(Kyb.Workflow.KYB_BYO) .addBeneficialOwnerEntity( Kyb.BusinessEntity.builder() .address( @@ -188,7 +188,7 @@ internal class AccountHolderCreateParamsTest { .governmentId("98-7654321") .legalBusinessName("Majority Holdings LLC") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("MHoldings") .parentCompany("parent_company") .build() ) @@ -240,7 +240,7 @@ internal class AccountHolderCreateParamsTest { .governmentId("12-3456789") .legalBusinessName("Busy Business, Inc.") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("Example Business Solutions") .parentCompany("parent_company") .build() ) @@ -268,7 +268,7 @@ internal class AccountHolderCreateParamsTest { "Software company selling solutions to the restaurant industry" ) .tosTimestamp("2022-03-08T08:00:00Z") - .workflow(Kyb.Workflow.KYB_BASIC) + .workflow(Kyb.Workflow.KYB_BYO) .addBeneficialOwnerEntity( Kyb.BusinessEntity.builder() .address( @@ -284,7 +284,7 @@ internal class AccountHolderCreateParamsTest { .governmentId("98-7654321") .legalBusinessName("Majority Holdings LLC") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("MHoldings") .parentCompany("parent_company") .build() ) @@ -358,7 +358,7 @@ internal class AccountHolderCreateParamsTest { "Software company selling solutions to the restaurant industry" ) .tosTimestamp("2022-03-08T08:00:00Z") - .workflow(Kyb.Workflow.KYB_BASIC) + .workflow(Kyb.Workflow.KYB_BYO) .build() ) .build() @@ -425,7 +425,7 @@ internal class AccountHolderCreateParamsTest { "Software company selling solutions to the restaurant industry" ) .tosTimestamp("2022-03-08T08:00:00Z") - .workflow(Kyb.Workflow.KYB_BASIC) + .workflow(Kyb.Workflow.KYB_BYO) .build() ) ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUpdateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUpdateParamsTest.kt index 2401cae81..d3953760d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUpdateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUpdateParamsTest.kt @@ -13,7 +13,93 @@ internal class AccountHolderUpdateParamsTest { .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .body( AccountHolderUpdateParams.Body.KybPatchRequest.builder() + .addBeneficialOwnerEntity( + AccountHolderUpdateParams.Body.KybPatchRequest.KybBusinessEntityPatch + .builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .addBeneficialOwnerIndividual( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + AccountHolderUpdateParams.Body.KybPatchRequest.KybBusinessEntityPatch + .builder() + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("61023") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .controlPerson( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch.builder() + .entityToken("fd771a07-c5c2-42f3-a53c-a6c79c6c0d07") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68023") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) .externalId("external_id") + .natureOfBusiness( + "Software company selling solutions to the restaurant industry" + ) + .websiteUrl("https://www.mynewbusiness.com") .build() ) .build() @@ -39,7 +125,93 @@ internal class AccountHolderUpdateParamsTest { .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .body( AccountHolderUpdateParams.Body.KybPatchRequest.builder() + .addBeneficialOwnerEntity( + AccountHolderUpdateParams.Body.KybPatchRequest.KybBusinessEntityPatch + .builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .addBeneficialOwnerIndividual( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + AccountHolderUpdateParams.Body.KybPatchRequest.KybBusinessEntityPatch + .builder() + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("61023") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .controlPerson( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch.builder() + .entityToken("fd771a07-c5c2-42f3-a53c-a6c79c6c0d07") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68023") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) .externalId("external_id") + .natureOfBusiness( + "Software company selling solutions to the restaurant industry" + ) + .websiteUrl("https://www.mynewbusiness.com") .build() ) .build() @@ -50,7 +222,93 @@ internal class AccountHolderUpdateParamsTest { .isEqualTo( AccountHolderUpdateParams.Body.ofKybPatchRequest( AccountHolderUpdateParams.Body.KybPatchRequest.builder() + .addBeneficialOwnerEntity( + AccountHolderUpdateParams.Body.KybPatchRequest.KybBusinessEntityPatch + .builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .addBeneficialOwnerIndividual( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + AccountHolderUpdateParams.Body.KybPatchRequest.KybBusinessEntityPatch + .builder() + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("61023") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .controlPerson( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch.builder() + .entityToken("fd771a07-c5c2-42f3-a53c-a6c79c6c0d07") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68023") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) .externalId("external_id") + .natureOfBusiness( + "Software company selling solutions to the restaurant industry" + ) + .websiteUrl("https://www.mynewbusiness.com") .build() ) ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParamsTest.kt index 66e097743..ea59babd4 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUploadDocumentParamsTest.kt @@ -12,7 +12,7 @@ internal class AccountHolderUploadDocumentParamsTest { AccountHolderUploadDocumentParams.builder() .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .documentType(AccountHolderUploadDocumentParams.DocumentType.EIN_LETTER) - .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") .build() } @@ -22,7 +22,7 @@ internal class AccountHolderUploadDocumentParamsTest { AccountHolderUploadDocumentParams.builder() .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .documentType(AccountHolderUploadDocumentParams.DocumentType.EIN_LETTER) - .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") .build() assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -36,13 +36,13 @@ internal class AccountHolderUploadDocumentParamsTest { AccountHolderUploadDocumentParams.builder() .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .documentType(AccountHolderUploadDocumentParams.DocumentType.EIN_LETTER) - .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") .build() val body = params._body() assertThat(body.documentType()) .isEqualTo(AccountHolderUploadDocumentParams.DocumentType.EIN_LETTER) - assertThat(body.entityToken()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.entityToken()).isEqualTo("83cf25ae-c14f-4d10-9fa2-0119f36c7286") } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountListPageResponseTest.kt index fc4eabdbb..e46d6b10a 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountListPageResponseTest.kt @@ -31,7 +31,7 @@ internal class AccountListPageResponseTest { .token("95e5f1b7-cfd5-4520-aa3c-2451bab8608d") .businessAccountToken("e87db14a-4abf-4901-adad-5d5c9f46aff2") .email("jack@lithic.com") - .phoneNumber("+12124007676") + .phoneNumber("+15555555555") .build() ) .addAuthRuleToken("string") @@ -71,7 +71,7 @@ internal class AccountListPageResponseTest { .token("95e5f1b7-cfd5-4520-aa3c-2451bab8608d") .businessAccountToken("e87db14a-4abf-4901-adad-5d5c9f46aff2") .email("jack@lithic.com") - .phoneNumber("+12124007676") + .phoneNumber("+15555555555") .build() ) .addAuthRuleToken("string") @@ -115,7 +115,7 @@ internal class AccountListPageResponseTest { .token("95e5f1b7-cfd5-4520-aa3c-2451bab8608d") .businessAccountToken("e87db14a-4abf-4901-adad-5d5c9f46aff2") .email("jack@lithic.com") - .phoneNumber("+12124007676") + .phoneNumber("+15555555555") .build() ) .addAuthRuleToken("string") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountTest.kt index 7e1d1a3de..a26473887 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountTest.kt @@ -30,7 +30,7 @@ internal class AccountTest { .token("95e5f1b7-cfd5-4520-aa3c-2451bab8608d") .businessAccountToken("e87db14a-4abf-4901-adad-5d5c9f46aff2") .email("jack@lithic.com") - .phoneNumber("+12124007676") + .phoneNumber("+15555555555") .build() ) .addAuthRuleToken("string") @@ -62,7 +62,7 @@ internal class AccountTest { .token("95e5f1b7-cfd5-4520-aa3c-2451bab8608d") .businessAccountToken("e87db14a-4abf-4901-adad-5d5c9f46aff2") .email("jack@lithic.com") - .phoneNumber("+12124007676") + .phoneNumber("+15555555555") .build() ) assertThat(account.authRuleTokens().getOrNull()).containsExactly("string") @@ -102,7 +102,7 @@ internal class AccountTest { .token("95e5f1b7-cfd5-4520-aa3c-2451bab8608d") .businessAccountToken("e87db14a-4abf-4901-adad-5d5c9f46aff2") .email("jack@lithic.com") - .phoneNumber("+12124007676") + .phoneNumber("+15555555555") .build() ) .addAuthRuleToken("string") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt index f0a19d132..7f4ebe4c8 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt @@ -15,29 +15,97 @@ internal class AuthRuleTest { val authRule = AuthRule.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .state(AuthRule.State.ACTIVE) - .addAccountToken("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .addAllowedCountry("MEX") - .addAllowedMcc("3000") - .addBlockedCountry("CAN") - .addBlockedCountry("USA") - .addBlockedMcc("5811") - .addBlockedMcc("5812") - .addCardToken("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .programLevel(false) + .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .currentVersion( + AuthRule.CurrentVersion.builder() + .parameters( + ConditionalBlockParameters.builder() + .addCondition( + AuthRuleCondition.builder() + .attribute(ConditionalAttribute.MCC) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + .build() + ) + .version(0L) + .build() + ) + .draftVersion( + AuthRule.DraftVersion.builder() + .parameters( + ConditionalBlockParameters.builder() + .addCondition( + AuthRuleCondition.builder() + .attribute(ConditionalAttribute.MCC) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + .build() + ) + .version(0L) + .build() + ) + .eventStream(AuthRule.EventStream.AUTHORIZATION) + .lithicManaged(true) + .name("name") + .programLevel(true) + .state(AuthRule.AuthRuleState.ACTIVE) + .type(AuthRule.AuthRuleType.CONDITIONAL_BLOCK) + .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(authRule.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(authRule.state()).isEqualTo(AuthRule.State.ACTIVE) - assertThat(authRule.accountTokens().getOrNull()) - .containsExactly("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(authRule.allowedCountries().getOrNull()).containsExactly("MEX") - assertThat(authRule.allowedMcc().getOrNull()).containsExactly("3000") - assertThat(authRule.blockedCountries().getOrNull()).containsExactly("CAN", "USA") - assertThat(authRule.blockedMcc().getOrNull()).containsExactly("5811", "5812") - assertThat(authRule.cardTokens().getOrNull()) - .containsExactly("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(authRule.programLevel()).contains(false) + assertThat(authRule.accountTokens()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(authRule.businessAccountTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(authRule.cardTokens()).containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(authRule.currentVersion()) + .contains( + AuthRule.CurrentVersion.builder() + .parameters( + ConditionalBlockParameters.builder() + .addCondition( + AuthRuleCondition.builder() + .attribute(ConditionalAttribute.MCC) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + .build() + ) + .version(0L) + .build() + ) + assertThat(authRule.draftVersion()) + .contains( + AuthRule.DraftVersion.builder() + .parameters( + ConditionalBlockParameters.builder() + .addCondition( + AuthRuleCondition.builder() + .attribute(ConditionalAttribute.MCC) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + .build() + ) + .version(0L) + .build() + ) + assertThat(authRule.eventStream()).isEqualTo(AuthRule.EventStream.AUTHORIZATION) + assertThat(authRule.lithicManaged()).isEqualTo(true) + assertThat(authRule.name()).contains("name") + assertThat(authRule.programLevel()).isEqualTo(true) + assertThat(authRule.state()).isEqualTo(AuthRule.AuthRuleState.ACTIVE) + assertThat(authRule.type()).isEqualTo(AuthRule.AuthRuleType.CONDITIONAL_BLOCK) + assertThat(authRule.excludedCardTokens().getOrNull()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test @@ -46,16 +114,48 @@ internal class AuthRuleTest { val authRule = AuthRule.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .state(AuthRule.State.ACTIVE) - .addAccountToken("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .addAllowedCountry("MEX") - .addAllowedMcc("3000") - .addBlockedCountry("CAN") - .addBlockedCountry("USA") - .addBlockedMcc("5811") - .addBlockedMcc("5812") - .addCardToken("3fa85f64-5717-4562-b3fc-2c963f66afa6") - .programLevel(false) + .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .currentVersion( + AuthRule.CurrentVersion.builder() + .parameters( + ConditionalBlockParameters.builder() + .addCondition( + AuthRuleCondition.builder() + .attribute(ConditionalAttribute.MCC) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + .build() + ) + .version(0L) + .build() + ) + .draftVersion( + AuthRule.DraftVersion.builder() + .parameters( + ConditionalBlockParameters.builder() + .addCondition( + AuthRuleCondition.builder() + .attribute(ConditionalAttribute.MCC) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + .build() + ) + .version(0L) + .build() + ) + .eventStream(AuthRule.EventStream.AUTHORIZATION) + .lithicManaged(true) + .name("name") + .programLevel(true) + .state(AuthRule.AuthRuleState.ACTIVE) + .type(AuthRule.AuthRuleType.CONDITIONAL_BLOCK) + .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val roundtrippedAuthRule = diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponseTest.kt index 1244611cb..1dcc5f02e 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponseTest.kt @@ -14,13 +14,13 @@ internal class AuthRuleV2ListPageResponseTest { val authRuleV2ListPageResponse = AuthRuleV2ListPageResponse.builder() .addData( - V2ListResponse.builder() + AuthRule.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .currentVersion( - V2ListResponse.CurrentVersion.builder() + AuthRule.CurrentVersion.builder() .parameters( ConditionalBlockParameters.builder() .addCondition( @@ -36,7 +36,7 @@ internal class AuthRuleV2ListPageResponseTest { .build() ) .draftVersion( - V2ListResponse.DraftVersion.builder() + AuthRule.DraftVersion.builder() .parameters( ConditionalBlockParameters.builder() .addCondition( @@ -51,12 +51,12 @@ internal class AuthRuleV2ListPageResponseTest { .version(0L) .build() ) - .eventStream(V2ListResponse.EventStream.AUTHORIZATION) + .eventStream(AuthRule.EventStream.AUTHORIZATION) .lithicManaged(true) .name("name") .programLevel(true) - .state(V2ListResponse.AuthRuleState.ACTIVE) - .type(V2ListResponse.AuthRuleType.CONDITIONAL_BLOCK) + .state(AuthRule.AuthRuleState.ACTIVE) + .type(AuthRule.AuthRuleType.CONDITIONAL_BLOCK) .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -65,13 +65,13 @@ internal class AuthRuleV2ListPageResponseTest { assertThat(authRuleV2ListPageResponse.data()) .containsExactly( - V2ListResponse.builder() + AuthRule.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .currentVersion( - V2ListResponse.CurrentVersion.builder() + AuthRule.CurrentVersion.builder() .parameters( ConditionalBlockParameters.builder() .addCondition( @@ -87,7 +87,7 @@ internal class AuthRuleV2ListPageResponseTest { .build() ) .draftVersion( - V2ListResponse.DraftVersion.builder() + AuthRule.DraftVersion.builder() .parameters( ConditionalBlockParameters.builder() .addCondition( @@ -102,12 +102,12 @@ internal class AuthRuleV2ListPageResponseTest { .version(0L) .build() ) - .eventStream(V2ListResponse.EventStream.AUTHORIZATION) + .eventStream(AuthRule.EventStream.AUTHORIZATION) .lithicManaged(true) .name("name") .programLevel(true) - .state(V2ListResponse.AuthRuleState.ACTIVE) - .type(V2ListResponse.AuthRuleType.CONDITIONAL_BLOCK) + .state(AuthRule.AuthRuleState.ACTIVE) + .type(AuthRule.AuthRuleType.CONDITIONAL_BLOCK) .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) @@ -120,13 +120,13 @@ internal class AuthRuleV2ListPageResponseTest { val authRuleV2ListPageResponse = AuthRuleV2ListPageResponse.builder() .addData( - V2ListResponse.builder() + AuthRule.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .currentVersion( - V2ListResponse.CurrentVersion.builder() + AuthRule.CurrentVersion.builder() .parameters( ConditionalBlockParameters.builder() .addCondition( @@ -142,7 +142,7 @@ internal class AuthRuleV2ListPageResponseTest { .build() ) .draftVersion( - V2ListResponse.DraftVersion.builder() + AuthRule.DraftVersion.builder() .parameters( ConditionalBlockParameters.builder() .addCondition( @@ -157,12 +157,12 @@ internal class AuthRuleV2ListPageResponseTest { .version(0L) .build() ) - .eventStream(V2ListResponse.EventStream.AUTHORIZATION) + .eventStream(AuthRule.EventStream.AUTHORIZATION) .lithicManaged(true) .name("name") .programLevel(true) - .state(V2ListResponse.AuthRuleState.ACTIVE) - .type(V2ListResponse.AuthRuleType.CONDITIONAL_BLOCK) + .state(AuthRule.AuthRuleState.ACTIVE) + .type(AuthRule.AuthRuleType.CONDITIONAL_BLOCK) .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt index af4278789..98587981a 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt @@ -12,17 +12,17 @@ internal class CardCreateParamsTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -52,17 +52,17 @@ internal class CardCreateParamsTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -89,17 +89,17 @@ internal class CardCreateParamsTest { assertThat(body.type()).isEqualTo(CardCreateParams.Type.VIRTUAL) assertThat(body.accountToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(body.cardProgramToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.cardProgramToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(body.carrier()).contains(Carrier.builder().qrCodeUrl("qr_code_url").build()) - assertThat(body.digitalCardArtToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.digitalCardArtToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(body.expMonth()).contains("06") assertThat(body.expYear()).contains("2027") assertThat(body.memo()).contains("New Card") assertThat(body.pin()).contains("pin") assertThat(body.productId()).contains("1") - assertThat(body.replacementAccountToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.replacementAccountToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(body.replacementComment()).contains("replacement_comment") - assertThat(body.replacementFor()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.replacementFor()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(body.replacementSubstatus()).contains(CardCreateParams.ReplacementSubstatus.LOST) assertThat(body.shippingAddress()) .contains( diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt index 2630da9d1..fe85b513f 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt @@ -40,7 +40,7 @@ internal class CardListPageResponseTest { .addAuthRuleToken("string") .cardholderCurrency("USD") .comment("comment") - .digitalCardArtToken("00000000-0000-0000-1000-000000000000") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .hostname("hostname") @@ -82,7 +82,7 @@ internal class CardListPageResponseTest { .addAuthRuleToken("string") .cardholderCurrency("USD") .comment("comment") - .digitalCardArtToken("00000000-0000-0000-1000-000000000000") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .hostname("hostname") @@ -128,7 +128,7 @@ internal class CardListPageResponseTest { .addAuthRuleToken("string") .cardholderCurrency("USD") .comment("comment") - .digitalCardArtToken("00000000-0000-0000-1000-000000000000") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .hostname("hostname") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramListPageResponseTest.kt index f7c923dbb..d5c4b9f87 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramListPageResponseTest.kt @@ -17,11 +17,11 @@ internal class CardProgramListPageResponseTest { .addData( CardProgram.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountLevelManagementEnabled(true) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") - .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") @@ -34,11 +34,11 @@ internal class CardProgramListPageResponseTest { .containsExactly( CardProgram.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountLevelManagementEnabled(true) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") - .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") @@ -55,11 +55,11 @@ internal class CardProgramListPageResponseTest { .addData( CardProgram.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountLevelManagementEnabled(true) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") - .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramTest.kt index 8abf7716e..96a043301 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardProgramTest.kt @@ -16,23 +16,23 @@ internal class CardProgramTest { val cardProgram = CardProgram.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountLevelManagementEnabled(true) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") - .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") .build() assertThat(cardProgram.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardProgram.accountLevelManagementEnabled()).isEqualTo(true) assertThat(cardProgram.created()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(cardProgram.name()).isEqualTo("My Prepaid Program") assertThat(cardProgram.panRangeEnd()).isEqualTo("52304803") assertThat(cardProgram.panRangeStart()).isEqualTo("52304803") - assertThat(cardProgram.accountLevelManagementEnabled()).contains(true) assertThat(cardProgram.cardholderCurrency()).contains("USD") assertThat(cardProgram.settlementCurrencies().getOrNull()).containsExactly("USD", "CAD") } @@ -43,11 +43,11 @@ internal class CardProgramTest { val cardProgram = CardProgram.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountLevelManagementEnabled(true) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .name("My Prepaid Program") .panRangeEnd("52304803") .panRangeStart("52304803") - .accountLevelManagementEnabled(true) .cardholderCurrency("USD") .addSettlementCurrency("USD") .addSettlementCurrency("CAD") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt index f676e77f8..c31c63ad8 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt @@ -39,7 +39,7 @@ internal class CardTest { .addAuthRuleToken("string") .cardholderCurrency("USD") .comment("comment") - .digitalCardArtToken("00000000-0000-0000-1000-000000000000") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .hostname("hostname") @@ -78,7 +78,7 @@ internal class CardTest { assertThat(card.authRuleTokens().getOrNull()).containsExactly("string") assertThat(card.cardholderCurrency()).contains("USD") assertThat(card.comment()).contains("comment") - assertThat(card.digitalCardArtToken()).contains("00000000-0000-0000-1000-000000000000") + assertThat(card.digitalCardArtToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(card.expMonth()).contains("06") assertThat(card.expYear()).contains("2027") assertThat(card.hostname()).contains("hostname") @@ -121,7 +121,7 @@ internal class CardTest { .addAuthRuleToken("string") .cardholderCurrency("USD") .comment("comment") - .digitalCardArtToken("00000000-0000-0000-1000-000000000000") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .hostname("hostname") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardUpdateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardUpdateParamsTest.kt index 5d229f8b0..ddbc7625d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardUpdateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardUpdateParamsTest.kt @@ -12,9 +12,9 @@ internal class CardUpdateParamsTest { CardUpdateParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .memo("Updated Name") - .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .networkProgramToken("00000000-0000-0000-1000-000000000000") .pin("pin") .pinStatus(CardUpdateParams.PinStatus.OK) .spendLimit(100L) @@ -40,9 +40,9 @@ internal class CardUpdateParamsTest { CardUpdateParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .memo("Updated Name") - .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .networkProgramToken("00000000-0000-0000-1000-000000000000") .pin("pin") .pinStatus(CardUpdateParams.PinStatus.OK) .spendLimit(100L) @@ -54,9 +54,9 @@ internal class CardUpdateParamsTest { val body = params._body() assertThat(body.comment()).contains("comment") - assertThat(body.digitalCardArtToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.digitalCardArtToken()).contains("00000000-0000-0000-1000-000000000000") assertThat(body.memo()).contains("Updated Name") - assertThat(body.networkProgramToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.networkProgramToken()).contains("00000000-0000-0000-1000-000000000000") assertThat(body.pin()).contains("pin") assertThat(body.pinStatus()).contains(CardUpdateParams.PinStatus.OK) assertThat(body.spendLimit()).contains(100L) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountCreateParamsTest.kt index 6e66283a6..6e389c434 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountCreateParamsTest.kt @@ -27,7 +27,7 @@ internal class ExternalBankAccountCreateParamsTest { .AccountType .CHECKING ) - .verificationMethod(VerificationMethod.PRENOTE) + .verificationMethod(VerificationMethod.MICRO_DEPOSIT) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .address( ExternalBankAccountAddress.builder() @@ -70,7 +70,7 @@ internal class ExternalBankAccountCreateParamsTest { .AccountType .CHECKING ) - .verificationMethod(VerificationMethod.PRENOTE) + .verificationMethod(VerificationMethod.MICRO_DEPOSIT) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .address( ExternalBankAccountAddress.builder() @@ -112,7 +112,7 @@ internal class ExternalBankAccountCreateParamsTest { .AccountType .CHECKING ) - .verificationMethod(VerificationMethod.PRENOTE) + .verificationMethod(VerificationMethod.MICRO_DEPOSIT) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .address( ExternalBankAccountAddress.builder() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt index 222bda14c..75f6cc4c9 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt @@ -39,7 +39,7 @@ internal class NonPciCardTest { .addAuthRuleToken("string") .cardholderCurrency("USD") .comment("comment") - .digitalCardArtToken("00000000-0000-0000-1000-000000000000") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .hostname("hostname") @@ -77,7 +77,7 @@ internal class NonPciCardTest { assertThat(nonPciCard.cardholderCurrency()).contains("USD") assertThat(nonPciCard.comment()).contains("comment") assertThat(nonPciCard.digitalCardArtToken()) - .contains("00000000-0000-0000-1000-000000000000") + .contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(nonPciCard.expMonth()).contains("06") assertThat(nonPciCard.expYear()).contains("2027") assertThat(nonPciCard.hostname()).contains("hostname") @@ -119,7 +119,7 @@ internal class NonPciCardTest { .addAuthRuleToken("string") .cardholderCurrency("USD") .comment("comment") - .digitalCardArtToken("00000000-0000-0000-1000-000000000000") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .hostname("hostname") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ReportSettlementListDetailsPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ReportSettlementListDetailsPageResponseTest.kt index f1ee301e8..78d16ac03 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ReportSettlementListDetailsPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ReportSettlementListDetailsPageResponseTest.kt @@ -20,7 +20,7 @@ internal class ReportSettlementListDetailsPageResponseTest { .accountToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardProgramToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") - .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .disputesGrossAmount(0L) .addEventToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") @@ -37,7 +37,7 @@ internal class ReportSettlementListDetailsPageResponseTest { .transactionToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .transactionsGrossAmount(1900L) .type(SettlementDetail.Type.CLEARING) - .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .feeDescription("INTERCHANGE COMPLIANCE ADJUSTMENT FOR : 11/12/24") .build() ) @@ -51,7 +51,7 @@ internal class ReportSettlementListDetailsPageResponseTest { .accountToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardProgramToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") - .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .disputesGrossAmount(0L) .addEventToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") @@ -66,7 +66,7 @@ internal class ReportSettlementListDetailsPageResponseTest { .transactionToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .transactionsGrossAmount(1900L) .type(SettlementDetail.Type.CLEARING) - .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .feeDescription("INTERCHANGE COMPLIANCE ADJUSTMENT FOR : 11/12/24") .build() ) @@ -84,7 +84,7 @@ internal class ReportSettlementListDetailsPageResponseTest { .accountToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardProgramToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") - .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .disputesGrossAmount(0L) .addEventToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") @@ -101,7 +101,7 @@ internal class ReportSettlementListDetailsPageResponseTest { .transactionToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .transactionsGrossAmount(1900L) .type(SettlementDetail.Type.CLEARING) - .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .feeDescription("INTERCHANGE COMPLIANCE ADJUSTMENT FOR : 11/12/24") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt index b6e156240..fc2ad32a2 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt @@ -18,7 +18,7 @@ internal class SettlementDetailTest { .accountToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardProgramToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") - .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .disputesGrossAmount(0L) .addEventToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") @@ -33,7 +33,7 @@ internal class SettlementDetailTest { .transactionToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .transactionsGrossAmount(1900L) .type(SettlementDetail.Type.CLEARING) - .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .feeDescription("INTERCHANGE COMPLIANCE ADJUSTMENT FOR : 11/12/24") .build() @@ -44,7 +44,7 @@ internal class SettlementDetailTest { .isEqualTo("e34a817f-119d-4976-9fb3-8b020b8bbec3") assertThat(settlementDetail.cardToken()).isEqualTo("e34a817f-119d-4976-9fb3-8b020b8bbec3") assertThat(settlementDetail.created()) - .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(settlementDetail.currency()).isEqualTo("USD") assertThat(settlementDetail.disputesGrossAmount()).isEqualTo(0L) assertThat(settlementDetail.eventTokens()) @@ -63,7 +63,7 @@ internal class SettlementDetailTest { assertThat(settlementDetail.transactionsGrossAmount()).isEqualTo(1900L) assertThat(settlementDetail.type()).isEqualTo(SettlementDetail.Type.CLEARING) assertThat(settlementDetail.updated()) - .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(settlementDetail.feeDescription()) .contains("INTERCHANGE COMPLIANCE ADJUSTMENT FOR : 11/12/24") } @@ -77,7 +77,7 @@ internal class SettlementDetailTest { .accountToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardProgramToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .cardToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") - .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .disputesGrossAmount(0L) .addEventToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") @@ -92,7 +92,7 @@ internal class SettlementDetailTest { .transactionToken("e34a817f-119d-4976-9fb3-8b020b8bbec3") .transactionsGrossAmount(1900L) .type(SettlementDetail.Type.CLEARING) - .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .feeDescription("INTERCHANGE COMPLIANCE ADJUSTMENT FOR : 11/12/24") .build() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementReportTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementReportTest.kt index 3694be6b6..65e7821b4 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementReportTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementReportTest.kt @@ -14,7 +14,7 @@ internal class SettlementReportTest { fun create() { val settlementReport = SettlementReport.builder() - .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .addDetail( SettlementSummaryDetails.builder() @@ -35,11 +35,11 @@ internal class SettlementReportTest { .reportDate("2023-06-01") .settledNetAmount(1893L) .transactionsGrossAmount(1900L) - .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() assertThat(settlementReport.created()) - .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(settlementReport.currency()).isEqualTo("USD") assertThat(settlementReport.details()) .containsExactly( @@ -62,7 +62,7 @@ internal class SettlementReportTest { assertThat(settlementReport.settledNetAmount()).isEqualTo(1893L) assertThat(settlementReport.transactionsGrossAmount()).isEqualTo(1900L) assertThat(settlementReport.updated()) - .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } @Test @@ -70,7 +70,7 @@ internal class SettlementReportTest { val jsonMapper = jsonMapper() val settlementReport = SettlementReport.builder() - .created(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .currency("USD") .addDetail( SettlementSummaryDetails.builder() @@ -91,7 +91,7 @@ internal class SettlementReportTest { .reportDate("2023-06-01") .settledNetAmount(1893L) .transactionsGrossAmount(1900L) - .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() val roundtrippedSettlementReport = diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationSimulateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationSimulateResponseTest.kt deleted file mode 100644 index 286f353ad..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationSimulateResponseTest.kt +++ /dev/null @@ -1,178 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TokenizationSimulateResponseTest { - - @Test - fun create() { - val tokenizationSimulateResponse = - TokenizationSimulateResponse.builder() - .addData( - Tokenization.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dpan("dpan") - .status(Tokenization.Status.ACTIVE) - .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) - .tokenUniqueReference("token_unique_reference") - .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deviceId("device_id") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - Tokenization.TokenizationEvent.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .result( - Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED - ) - .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() - .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .explanation("explanation") - .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult - .Result - .APPROVED - ) - .build() - ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) - .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) - .build() - ) - .paymentAccountReferenceId("payment_account_reference_id") - .build() - ) - .build() - - assertThat(tokenizationSimulateResponse.data().getOrNull()) - .containsExactly( - Tokenization.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dpan("dpan") - .status(Tokenization.Status.ACTIVE) - .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) - .tokenUniqueReference("token_unique_reference") - .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deviceId("device_id") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - Tokenization.TokenizationEvent.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .result( - Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED - ) - .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() - .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .explanation("explanation") - .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult.Result - .APPROVED - ) - .build() - ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) - .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) - .build() - ) - .paymentAccountReferenceId("payment_account_reference_id") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tokenizationSimulateResponse = - TokenizationSimulateResponse.builder() - .addData( - Tokenization.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dpan("dpan") - .status(Tokenization.Status.ACTIVE) - .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) - .tokenUniqueReference("token_unique_reference") - .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deviceId("device_id") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - Tokenization.TokenizationEvent.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .result( - Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED - ) - .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() - .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .explanation("explanation") - .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult - .Result - .APPROVED - ) - .build() - ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) - .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) - .build() - ) - .paymentAccountReferenceId("payment_account_reference_id") - .build() - ) - .build() - - val roundtrippedTokenizationSimulateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tokenizationSimulateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTokenizationSimulateResponse).isEqualTo(tokenizationSimulateResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtParamsTest.kt index bc8784111..a41e5f762 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtParamsTest.kt @@ -11,7 +11,7 @@ internal class TokenizationUpdateDigitalCardArtParamsTest { fun create() { TokenizationUpdateDigitalCardArtParams.builder() .tokenizationToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .build() } @@ -32,12 +32,12 @@ internal class TokenizationUpdateDigitalCardArtParamsTest { val params = TokenizationUpdateDigitalCardArtParams.builder() .tokenizationToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .build() val body = params._body() - assertThat(body.digitalCardArtToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.digitalCardArtToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") } @Test diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponseTest.kt deleted file mode 100644 index df815fcad..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdateDigitalCardArtResponseTest.kt +++ /dev/null @@ -1,178 +0,0 @@ -// 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 TokenizationUpdateDigitalCardArtResponseTest { - - @Test - fun create() { - val tokenizationUpdateDigitalCardArtResponse = - TokenizationUpdateDigitalCardArtResponse.builder() - .data( - Tokenization.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dpan("dpan") - .status(Tokenization.Status.ACTIVE) - .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) - .tokenUniqueReference("token_unique_reference") - .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deviceId("device_id") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - Tokenization.TokenizationEvent.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .result( - Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED - ) - .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() - .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .explanation("explanation") - .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult - .Result - .APPROVED - ) - .build() - ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) - .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) - .build() - ) - .paymentAccountReferenceId("payment_account_reference_id") - .build() - ) - .build() - - assertThat(tokenizationUpdateDigitalCardArtResponse.data()) - .contains( - Tokenization.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dpan("dpan") - .status(Tokenization.Status.ACTIVE) - .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) - .tokenUniqueReference("token_unique_reference") - .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deviceId("device_id") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - Tokenization.TokenizationEvent.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .result( - Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED - ) - .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() - .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .explanation("explanation") - .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult.Result - .APPROVED - ) - .build() - ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) - .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) - .build() - ) - .paymentAccountReferenceId("payment_account_reference_id") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tokenizationUpdateDigitalCardArtResponse = - TokenizationUpdateDigitalCardArtResponse.builder() - .data( - Tokenization.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .dpan("dpan") - .status(Tokenization.Status.ACTIVE) - .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) - .tokenUniqueReference("token_unique_reference") - .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .deviceId("device_id") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addEvent( - Tokenization.TokenizationEvent.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .result( - Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED - ) - .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() - .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .explanation("explanation") - .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult - .Result - .APPROVED - ) - .build() - ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) - .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) - .build() - ) - .paymentAccountReferenceId("payment_account_reference_id") - .build() - ) - .build() - - val roundtrippedTokenizationUpdateDigitalCardArtResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tokenizationUpdateDigitalCardArtResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTokenizationUpdateDigitalCardArtResponse) - .isEqualTo(tokenizationUpdateDigitalCardArtResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2CreateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2CreateResponseTest.kt deleted file mode 100644 index 0480432b8..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2CreateResponseTest.kt +++ /dev/null @@ -1,173 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class V2CreateResponseTest { - - @Test - fun create() { - val v2CreateResponse = - V2CreateResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2CreateResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2CreateResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2CreateResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2CreateResponse.AuthRuleState.ACTIVE) - .type(V2CreateResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(v2CreateResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2CreateResponse.accountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2CreateResponse.businessAccountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2CreateResponse.cardTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2CreateResponse.currentVersion()) - .contains( - V2CreateResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2CreateResponse.draftVersion()) - .contains( - V2CreateResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2CreateResponse.eventStream()) - .isEqualTo(V2CreateResponse.EventStream.AUTHORIZATION) - assertThat(v2CreateResponse.lithicManaged()).isEqualTo(true) - assertThat(v2CreateResponse.name()).contains("name") - assertThat(v2CreateResponse.programLevel()).isEqualTo(true) - assertThat(v2CreateResponse.state()).isEqualTo(V2CreateResponse.AuthRuleState.ACTIVE) - assertThat(v2CreateResponse.type()) - .isEqualTo(V2CreateResponse.AuthRuleType.CONDITIONAL_BLOCK) - assertThat(v2CreateResponse.excludedCardTokens().getOrNull()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val v2CreateResponse = - V2CreateResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2CreateResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2CreateResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2CreateResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2CreateResponse.AuthRuleState.ACTIVE) - .type(V2CreateResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val roundtrippedV2CreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(v2CreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedV2CreateResponse).isEqualTo(v2CreateResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2DraftResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2DraftResponseTest.kt deleted file mode 100644 index a05541e5a..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2DraftResponseTest.kt +++ /dev/null @@ -1,172 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class V2DraftResponseTest { - - @Test - fun create() { - val v2DraftResponse = - V2DraftResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2DraftResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2DraftResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2DraftResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2DraftResponse.AuthRuleState.ACTIVE) - .type(V2DraftResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(v2DraftResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2DraftResponse.accountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2DraftResponse.businessAccountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2DraftResponse.cardTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2DraftResponse.currentVersion()) - .contains( - V2DraftResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2DraftResponse.draftVersion()) - .contains( - V2DraftResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2DraftResponse.eventStream()) - .isEqualTo(V2DraftResponse.EventStream.AUTHORIZATION) - assertThat(v2DraftResponse.lithicManaged()).isEqualTo(true) - assertThat(v2DraftResponse.name()).contains("name") - assertThat(v2DraftResponse.programLevel()).isEqualTo(true) - assertThat(v2DraftResponse.state()).isEqualTo(V2DraftResponse.AuthRuleState.ACTIVE) - assertThat(v2DraftResponse.type()).isEqualTo(V2DraftResponse.AuthRuleType.CONDITIONAL_BLOCK) - assertThat(v2DraftResponse.excludedCardTokens().getOrNull()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val v2DraftResponse = - V2DraftResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2DraftResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2DraftResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2DraftResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2DraftResponse.AuthRuleState.ACTIVE) - .type(V2DraftResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val roundtrippedV2DraftResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(v2DraftResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedV2DraftResponse).isEqualTo(v2DraftResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResponseTest.kt deleted file mode 100644 index a1ba25050..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResponseTest.kt +++ /dev/null @@ -1,171 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class V2ListResponseTest { - - @Test - fun create() { - val v2ListResponse = - V2ListResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2ListResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2ListResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2ListResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2ListResponse.AuthRuleState.ACTIVE) - .type(V2ListResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(v2ListResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2ListResponse.accountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2ListResponse.businessAccountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2ListResponse.cardTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2ListResponse.currentVersion()) - .contains( - V2ListResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2ListResponse.draftVersion()) - .contains( - V2ListResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2ListResponse.eventStream()).isEqualTo(V2ListResponse.EventStream.AUTHORIZATION) - assertThat(v2ListResponse.lithicManaged()).isEqualTo(true) - assertThat(v2ListResponse.name()).contains("name") - assertThat(v2ListResponse.programLevel()).isEqualTo(true) - assertThat(v2ListResponse.state()).isEqualTo(V2ListResponse.AuthRuleState.ACTIVE) - assertThat(v2ListResponse.type()).isEqualTo(V2ListResponse.AuthRuleType.CONDITIONAL_BLOCK) - assertThat(v2ListResponse.excludedCardTokens().getOrNull()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val v2ListResponse = - V2ListResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2ListResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2ListResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2ListResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2ListResponse.AuthRuleState.ACTIVE) - .type(V2ListResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val roundtrippedV2ListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(v2ListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedV2ListResponse).isEqualTo(v2ListResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2PromoteResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2PromoteResponseTest.kt deleted file mode 100644 index 2ed88c3a5..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2PromoteResponseTest.kt +++ /dev/null @@ -1,173 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class V2PromoteResponseTest { - - @Test - fun create() { - val v2PromoteResponse = - V2PromoteResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2PromoteResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2PromoteResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2PromoteResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2PromoteResponse.AuthRuleState.ACTIVE) - .type(V2PromoteResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(v2PromoteResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2PromoteResponse.accountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2PromoteResponse.businessAccountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2PromoteResponse.cardTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2PromoteResponse.currentVersion()) - .contains( - V2PromoteResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2PromoteResponse.draftVersion()) - .contains( - V2PromoteResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2PromoteResponse.eventStream()) - .isEqualTo(V2PromoteResponse.EventStream.AUTHORIZATION) - assertThat(v2PromoteResponse.lithicManaged()).isEqualTo(true) - assertThat(v2PromoteResponse.name()).contains("name") - assertThat(v2PromoteResponse.programLevel()).isEqualTo(true) - assertThat(v2PromoteResponse.state()).isEqualTo(V2PromoteResponse.AuthRuleState.ACTIVE) - assertThat(v2PromoteResponse.type()) - .isEqualTo(V2PromoteResponse.AuthRuleType.CONDITIONAL_BLOCK) - assertThat(v2PromoteResponse.excludedCardTokens().getOrNull()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val v2PromoteResponse = - V2PromoteResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2PromoteResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2PromoteResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2PromoteResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2PromoteResponse.AuthRuleState.ACTIVE) - .type(V2PromoteResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val roundtrippedV2PromoteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(v2PromoteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedV2PromoteResponse).isEqualTo(v2PromoteResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2RetrieveResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2RetrieveResponseTest.kt deleted file mode 100644 index e373da9c6..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2RetrieveResponseTest.kt +++ /dev/null @@ -1,173 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class V2RetrieveResponseTest { - - @Test - fun create() { - val v2RetrieveResponse = - V2RetrieveResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2RetrieveResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2RetrieveResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2RetrieveResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2RetrieveResponse.AuthRuleState.ACTIVE) - .type(V2RetrieveResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(v2RetrieveResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2RetrieveResponse.accountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2RetrieveResponse.businessAccountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2RetrieveResponse.cardTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2RetrieveResponse.currentVersion()) - .contains( - V2RetrieveResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2RetrieveResponse.draftVersion()) - .contains( - V2RetrieveResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2RetrieveResponse.eventStream()) - .isEqualTo(V2RetrieveResponse.EventStream.AUTHORIZATION) - assertThat(v2RetrieveResponse.lithicManaged()).isEqualTo(true) - assertThat(v2RetrieveResponse.name()).contains("name") - assertThat(v2RetrieveResponse.programLevel()).isEqualTo(true) - assertThat(v2RetrieveResponse.state()).isEqualTo(V2RetrieveResponse.AuthRuleState.ACTIVE) - assertThat(v2RetrieveResponse.type()) - .isEqualTo(V2RetrieveResponse.AuthRuleType.CONDITIONAL_BLOCK) - assertThat(v2RetrieveResponse.excludedCardTokens().getOrNull()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val v2RetrieveResponse = - V2RetrieveResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2RetrieveResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2RetrieveResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2RetrieveResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2RetrieveResponse.AuthRuleState.ACTIVE) - .type(V2RetrieveResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val roundtrippedV2RetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(v2RetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedV2RetrieveResponse).isEqualTo(v2RetrieveResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2UpdateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2UpdateResponseTest.kt deleted file mode 100644 index 7c9bcd271..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2UpdateResponseTest.kt +++ /dev/null @@ -1,173 +0,0 @@ -// 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 kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class V2UpdateResponseTest { - - @Test - fun create() { - val v2UpdateResponse = - V2UpdateResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2UpdateResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2UpdateResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2UpdateResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2UpdateResponse.AuthRuleState.ACTIVE) - .type(V2UpdateResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(v2UpdateResponse.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2UpdateResponse.accountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2UpdateResponse.businessAccountTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2UpdateResponse.cardTokens()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(v2UpdateResponse.currentVersion()) - .contains( - V2UpdateResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2UpdateResponse.draftVersion()) - .contains( - V2UpdateResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - assertThat(v2UpdateResponse.eventStream()) - .isEqualTo(V2UpdateResponse.EventStream.AUTHORIZATION) - assertThat(v2UpdateResponse.lithicManaged()).isEqualTo(true) - assertThat(v2UpdateResponse.name()).contains("name") - assertThat(v2UpdateResponse.programLevel()).isEqualTo(true) - assertThat(v2UpdateResponse.state()).isEqualTo(V2UpdateResponse.AuthRuleState.ACTIVE) - assertThat(v2UpdateResponse.type()) - .isEqualTo(V2UpdateResponse.AuthRuleType.CONDITIONAL_BLOCK) - assertThat(v2UpdateResponse.excludedCardTokens().getOrNull()) - .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val v2UpdateResponse = - V2UpdateResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .currentVersion( - V2UpdateResponse.CurrentVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .draftVersion( - V2UpdateResponse.DraftVersion.builder() - .parameters( - ConditionalBlockParameters.builder() - .addCondition( - AuthRuleCondition.builder() - .attribute(ConditionalAttribute.MCC) - .operation(ConditionalOperation.IS_ONE_OF) - .value("string") - .build() - ) - .build() - ) - .version(0L) - .build() - ) - .eventStream(V2UpdateResponse.EventStream.AUTHORIZATION) - .lithicManaged(true) - .name("name") - .programLevel(true) - .state(V2UpdateResponse.AuthRuleState.ACTIVE) - .type(V2UpdateResponse.AuthRuleType.CONDITIONAL_BLOCK) - .addExcludedCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val roundtrippedV2UpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(v2UpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedV2UpdateResponse).isEqualTo(v2UpdateResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt index ef6fd511e..ee633e9be 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt @@ -77,17 +77,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -133,17 +133,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -189,17 +189,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -245,17 +245,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -301,17 +301,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -357,17 +357,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -413,17 +413,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -469,17 +469,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -525,17 +525,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -581,17 +581,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -637,17 +637,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -693,17 +693,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -749,17 +749,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -805,17 +805,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -861,17 +861,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -917,17 +917,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -971,17 +971,17 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt index 56ab4c026..f180893b4 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt @@ -47,17 +47,17 @@ internal class ServiceParamsTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountHolderServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountHolderServiceAsyncTest.kt index 08f865ea5..16db460ef 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountHolderServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/AccountHolderServiceAsyncTest.kt @@ -11,6 +11,7 @@ import com.lithic.api.models.AccountHolderSimulateEnrollmentReviewParams import com.lithic.api.models.AccountHolderUpdateParams import com.lithic.api.models.AccountHolderUploadDocumentParams import com.lithic.api.models.Address +import com.lithic.api.models.AddressUpdate import com.lithic.api.models.Kyb import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -67,7 +68,7 @@ internal class AccountHolderServiceAsyncTest { .governmentId("12-3456789") .legalBusinessName("Busy Business, Inc.") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("Example Business Solutions") .parentCompany("parent_company") .build() ) @@ -95,7 +96,7 @@ internal class AccountHolderServiceAsyncTest { "Software company selling solutions to the restaurant industry" ) .tosTimestamp("2022-03-08T08:00:00Z") - .workflow(Kyb.Workflow.KYB_BASIC) + .workflow(Kyb.Workflow.KYB_BYO) .addBeneficialOwnerEntity( Kyb.BusinessEntity.builder() .address( @@ -111,7 +112,7 @@ internal class AccountHolderServiceAsyncTest { .governmentId("98-7654321") .legalBusinessName("Majority Holdings LLC") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("MHoldings") .parentCompany("parent_company") .build() ) @@ -158,7 +159,97 @@ internal class AccountHolderServiceAsyncTest { .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .body( AccountHolderUpdateParams.Body.KybPatchRequest.builder() + .addBeneficialOwnerEntity( + AccountHolderUpdateParams.Body.KybPatchRequest + .KybBusinessEntityPatch + .builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .addBeneficialOwnerIndividual( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch + .builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + AccountHolderUpdateParams.Body.KybPatchRequest + .KybBusinessEntityPatch + .builder() + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("61023") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .controlPerson( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch + .builder() + .entityToken("fd771a07-c5c2-42f3-a53c-a6c79c6c0d07") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68023") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) .externalId("external_id") + .natureOfBusiness( + "Software company selling solutions to the restaurant industry" + ) + .websiteUrl("https://www.mynewbusiness.com") .build() ) .build() @@ -286,7 +377,7 @@ internal class AccountHolderServiceAsyncTest { AccountHolderUploadDocumentParams.builder() .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .documentType(AccountHolderUploadDocumentParams.DocumentType.EIN_LETTER) - .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt index 159c0047c..2ea072311 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt @@ -36,17 +36,17 @@ internal class CardServiceAsyncTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -103,9 +103,9 @@ internal class CardServiceAsyncTest { CardUpdateParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .memo("Updated Name") - .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .networkProgramToken("00000000-0000-0000-1000-000000000000") .pin("pin") .pinStatus(CardUpdateParams.PinStatus.OK) .spendLimit(100L) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncTest.kt index b98e3850d..eebfe0891 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncTest.kt @@ -46,7 +46,7 @@ internal class ExternalBankAccountServiceAsyncTest { .AccountType .CHECKING ) - .verificationMethod(VerificationMethod.PRENOTE) + .verificationMethod(VerificationMethod.MICRO_DEPOSIT) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .address( ExternalBankAccountAddress.builder() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncTest.kt index a468f5bda..74d29cefa 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/TokenizationServiceAsyncTest.kt @@ -118,7 +118,7 @@ internal class TokenizationServiceAsyncTest { .build() val tokenizationServiceAsync = client.tokenizations() - val responseFuture = + val tokenizationFuture = tokenizationServiceAsync.simulate( TokenizationSimulateParams.builder() .cvv("776") @@ -134,8 +134,8 @@ internal class TokenizationServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val tokenization = tokenizationFuture.get() + tokenization.validate() } @Test @@ -161,15 +161,15 @@ internal class TokenizationServiceAsyncTest { .build() val tokenizationServiceAsync = client.tokenizations() - val responseFuture = + val tokenizationFuture = tokenizationServiceAsync.updateDigitalCardArt( TokenizationUpdateDigitalCardArtParams.builder() .tokenizationToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .build() ) - val response = responseFuture.get() - response.validate() + val tokenization = tokenizationFuture.get() + tokenization.validate() } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncTest.kt index 26f9afcb5..29e232658 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncTest.kt @@ -29,7 +29,7 @@ internal class V2ServiceAsyncTest { .build() val v2ServiceAsync = client.authRules().v2() - val v2Future = + val authRuleFuture = v2ServiceAsync.create( AuthRuleV2CreateParams.builder() .body( @@ -61,8 +61,8 @@ internal class V2ServiceAsyncTest { .build() ) - val v2 = v2Future.get() - v2.validate() + val authRule = authRuleFuture.get() + authRule.validate() } @Test @@ -74,10 +74,10 @@ internal class V2ServiceAsyncTest { .build() val v2ServiceAsync = client.authRules().v2() - val v2Future = v2ServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val authRuleFuture = v2ServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - val v2 = v2Future.get() - v2.validate() + val authRule = authRuleFuture.get() + authRule.validate() } @Test @@ -89,7 +89,7 @@ internal class V2ServiceAsyncTest { .build() val v2ServiceAsync = client.authRules().v2() - val v2Future = + val authRuleFuture = v2ServiceAsync.update( AuthRuleV2UpdateParams.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -104,8 +104,8 @@ internal class V2ServiceAsyncTest { .build() ) - val v2 = v2Future.get() - v2.validate() + val authRule = authRuleFuture.get() + authRule.validate() } @Test @@ -146,7 +146,7 @@ internal class V2ServiceAsyncTest { .build() val v2ServiceAsync = client.authRules().v2() - val responseFuture = + val authRuleFuture = v2ServiceAsync.draft( AuthRuleV2DraftParams.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -164,8 +164,8 @@ internal class V2ServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val authRule = authRuleFuture.get() + authRule.validate() } @Test @@ -177,10 +177,10 @@ internal class V2ServiceAsyncTest { .build() val v2ServiceAsync = client.authRules().v2() - val responseFuture = v2ServiceAsync.promote("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val authRuleFuture = v2ServiceAsync.promote("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - val response = responseFuture.get() - response.validate() + val authRule = authRuleFuture.get() + authRule.validate() } @Test diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountHolderServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountHolderServiceTest.kt index 5278ce0a7..62807a335 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountHolderServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/AccountHolderServiceTest.kt @@ -11,6 +11,7 @@ import com.lithic.api.models.AccountHolderSimulateEnrollmentReviewParams import com.lithic.api.models.AccountHolderUpdateParams import com.lithic.api.models.AccountHolderUploadDocumentParams import com.lithic.api.models.Address +import com.lithic.api.models.AddressUpdate import com.lithic.api.models.Kyb import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -67,7 +68,7 @@ internal class AccountHolderServiceTest { .governmentId("12-3456789") .legalBusinessName("Busy Business, Inc.") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("Example Business Solutions") .parentCompany("parent_company") .build() ) @@ -95,7 +96,7 @@ internal class AccountHolderServiceTest { "Software company selling solutions to the restaurant industry" ) .tosTimestamp("2022-03-08T08:00:00Z") - .workflow(Kyb.Workflow.KYB_BASIC) + .workflow(Kyb.Workflow.KYB_BYO) .addBeneficialOwnerEntity( Kyb.BusinessEntity.builder() .address( @@ -111,7 +112,7 @@ internal class AccountHolderServiceTest { .governmentId("98-7654321") .legalBusinessName("Majority Holdings LLC") .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") + .dbaBusinessName("MHoldings") .parentCompany("parent_company") .build() ) @@ -155,7 +156,97 @@ internal class AccountHolderServiceTest { .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .body( AccountHolderUpdateParams.Body.KybPatchRequest.builder() + .addBeneficialOwnerEntity( + AccountHolderUpdateParams.Body.KybPatchRequest + .KybBusinessEntityPatch + .builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .addBeneficialOwnerIndividual( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch + .builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + AccountHolderUpdateParams.Body.KybPatchRequest + .KybBusinessEntityPatch + .builder() + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("61023") + .state("NE") + .build() + ) + .dbaBusinessName("dba_business_name") + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .parentCompany("parent_company") + .addPhoneNumber("+15555555555") + .build() + ) + .controlPerson( + AccountHolderUpdateParams.Body.KybPatchRequest.IndividualPatch + .builder() + .entityToken("fd771a07-c5c2-42f3-a53c-a6c79c6c0d07") + .address( + AddressUpdate.builder() + .address1("123 Old Forest Way") + .address2("address2") + .city("Omaha") + .country("USA") + .postalCode("68023") + .state("NE") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) .externalId("external_id") + .natureOfBusiness( + "Software company selling solutions to the restaurant industry" + ) + .websiteUrl("https://www.mynewbusiness.com") .build() ) .build() @@ -276,7 +367,7 @@ internal class AccountHolderServiceTest { AccountHolderUploadDocumentParams.builder() .accountHolderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .documentType(AccountHolderUploadDocumentParams.DocumentType.EIN_LETTER) - .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .entityToken("83cf25ae-c14f-4d10-9fa2-0119f36c7286") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt index 95f9e2911..e9a299d20 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt @@ -36,17 +36,17 @@ internal class CardServiceTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .cardProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .expMonth("06") .expYear("2027") .memo("New Card") .pin("pin") .productId("1") - .replacementAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementAccountToken("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementComment("replacement_comment") - .replacementFor("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .replacementFor("5e9483eb-8103-4e16-9794-2106111b2eca") .replacementSubstatus(CardCreateParams.ReplacementSubstatus.LOST) .shippingAddress( ShippingAddress.builder() @@ -101,9 +101,9 @@ internal class CardServiceTest { CardUpdateParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .comment("comment") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("00000000-0000-0000-1000-000000000000") .memo("Updated Name") - .networkProgramToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .networkProgramToken("00000000-0000-0000-1000-000000000000") .pin("pin") .pinStatus(CardUpdateParams.PinStatus.OK) .spendLimit(100L) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceTest.kt index a1657b133..f4867a3b2 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceTest.kt @@ -46,7 +46,7 @@ internal class ExternalBankAccountServiceTest { .AccountType .CHECKING ) - .verificationMethod(VerificationMethod.PRENOTE) + .verificationMethod(VerificationMethod.MICRO_DEPOSIT) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .address( ExternalBankAccountAddress.builder() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/TokenizationServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/TokenizationServiceTest.kt index 5b2ed8b64..bdd8d0c01 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/TokenizationServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/TokenizationServiceTest.kt @@ -106,7 +106,7 @@ internal class TokenizationServiceTest { .build() val tokenizationService = client.tokenizations() - val response = + val tokenization = tokenizationService.simulate( TokenizationSimulateParams.builder() .cvv("776") @@ -122,7 +122,7 @@ internal class TokenizationServiceTest { .build() ) - response.validate() + tokenization.validate() } @Test @@ -146,14 +146,14 @@ internal class TokenizationServiceTest { .build() val tokenizationService = client.tokenizations() - val response = + val tokenization = tokenizationService.updateDigitalCardArt( TokenizationUpdateDigitalCardArtParams.builder() .tokenizationToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") .build() ) - response.validate() + tokenization.validate() } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt index 9ddbd7f05..81f9e8c97 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt @@ -29,7 +29,7 @@ internal class V2ServiceTest { .build() val v2Service = client.authRules().v2() - val v2 = + val authRule = v2Service.create( AuthRuleV2CreateParams.builder() .body( @@ -61,7 +61,7 @@ internal class V2ServiceTest { .build() ) - v2.validate() + authRule.validate() } @Test @@ -73,9 +73,9 @@ internal class V2ServiceTest { .build() val v2Service = client.authRules().v2() - val v2 = v2Service.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val authRule = v2Service.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - v2.validate() + authRule.validate() } @Test @@ -87,7 +87,7 @@ internal class V2ServiceTest { .build() val v2Service = client.authRules().v2() - val v2 = + val authRule = v2Service.update( AuthRuleV2UpdateParams.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -102,7 +102,7 @@ internal class V2ServiceTest { .build() ) - v2.validate() + authRule.validate() } @Test @@ -140,7 +140,7 @@ internal class V2ServiceTest { .build() val v2Service = client.authRules().v2() - val response = + val authRule = v2Service.draft( AuthRuleV2DraftParams.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -158,7 +158,7 @@ internal class V2ServiceTest { .build() ) - response.validate() + authRule.validate() } @Test @@ -170,9 +170,9 @@ internal class V2ServiceTest { .build() val v2Service = client.authRules().v2() - val response = v2Service.promote("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val authRule = v2Service.promote("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - response.validate() + authRule.validate() } @Test From 8c6e2447956a9d8459022539e57e91e3133c3bff Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 24 Nov 2025 12:57:27 +0000 Subject: [PATCH 02/12] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index ac9c2797c..3cab4cd3f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 172 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-a9de2732e7a28b7fc5b8b7b171781d617337b6223d82ef7d6a554d0bd2b33bab.yml openapi_spec_hash: fc6111d286c7002cd854af23841d137e -config_hash: f6f5c7f37033e89a3cf91a48371a718a +config_hash: cbad5dbbbeb0a85e4e3b70e5865a1900 From 99c266a62f1b3fcd92ea9cf0ad56c5c5e130fd06 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 26 Nov 2025 19:56:46 +0000 Subject: [PATCH 03/12] fix(client): cancel okhttp call when future cancelled --- lithic-java-client-okhttp/build.gradle.kts | 1 + .../lithic/api/client/okhttp/OkHttpClient.kt | 34 ++++++++------ .../api/client/okhttp/OkHttpClientTest.kt | 44 +++++++++++++++++++ 3 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 lithic-java-client-okhttp/src/test/kotlin/com/lithic/api/client/okhttp/OkHttpClientTest.kt diff --git a/lithic-java-client-okhttp/build.gradle.kts b/lithic-java-client-okhttp/build.gradle.kts index 5211494ba..0d61bae34 100644 --- a/lithic-java-client-okhttp/build.gradle.kts +++ b/lithic-java-client-okhttp/build.gradle.kts @@ -11,4 +11,5 @@ dependencies { testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/OkHttpClient.kt b/lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/OkHttpClient.kt index d4e9564d6..1b37107b8 100644 --- a/lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/OkHttpClient.kt +++ b/lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/OkHttpClient.kt @@ -13,6 +13,7 @@ import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration +import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory @@ -29,8 +30,8 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : - HttpClient { +class OkHttpClient +private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) @@ -50,20 +51,25 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC ): CompletableFuture { val future = CompletableFuture() - request.body?.run { future.whenComplete { _, _ -> close() } } - - newCall(request, requestOptions) - .enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + val call = newCall(request, requestOptions) + call.enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(LithicIoException("Request failed", e)) - } + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(LithicIoException("Request failed", e)) } - ) + } + ) + + future.whenComplete { _, e -> + if (e is CancellationException) { + call.cancel() + } + request.body?.close() + } return future } diff --git a/lithic-java-client-okhttp/src/test/kotlin/com/lithic/api/client/okhttp/OkHttpClientTest.kt b/lithic-java-client-okhttp/src/test/kotlin/com/lithic/api/client/okhttp/OkHttpClientTest.kt new file mode 100644 index 000000000..419166765 --- /dev/null +++ b/lithic-java-client-okhttp/src/test/kotlin/com/lithic/api/client/okhttp/OkHttpClientTest.kt @@ -0,0 +1,44 @@ +package com.lithic.api.client.okhttp + +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class OkHttpClientTest { + + private lateinit var baseUrl: String + private lateinit var httpClient: OkHttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + httpClient = OkHttpClient.builder().build() + } + + @Test + fun executeAsync_whenFutureCancelled_cancelsUnderlyingCall() { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val responseFuture = + httpClient.executeAsync( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build() + ) + val call = httpClient.okHttpClient.dispatcher.runningCalls().single() + + responseFuture.cancel(false) + + // Should have cancelled the underlying call + assertThat(call.isCanceled()).isTrue() + } +} From 7c3897e8506a633273f462ddd7964b92ace98d3f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 2 Dec 2025 08:48:04 +0000 Subject: [PATCH 04/12] docs: remove `$` for better copy-pasteabality --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ba333d9e5..9e682cdc3 100644 --- a/README.md +++ b/README.md @@ -345,13 +345,13 @@ The SDK uses the standard [OkHttp logging interceptor](https://github.com/square Enable logging by setting the `LITHIC_LOG` environment variable to `info`: ```sh -$ export LITHIC_LOG=info +export LITHIC_LOG=info ``` Or to `debug` for more verbose logging: ```sh -$ export LITHIC_LOG=debug +export LITHIC_LOG=debug ``` ## Webhook Verification From 713f81e8e58763762f07358edda1fe0b97a041dc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Dec 2025 09:05:56 +0000 Subject: [PATCH 05/12] feat(api): add bulk card creation APIs fix(api): extract several common types to reduce duplication --- .stats.yml | 8 +- .../com/lithic/api/client/LithicClient.kt | 10 + .../lithic/api/client/LithicClientAsync.kt | 10 + .../api/client/LithicClientAsyncImpl.kt | 29 + .../com/lithic/api/client/LithicClientImpl.kt | 29 + .../api/models/AccountActivityListResponse.kt | 51 +- ...ountActivityRetrieveTransactionResponse.kt | 51 +- .../main/kotlin/com/lithic/api/models/Card.kt | 55 +- .../lithic/api/models/CardBalanceListPage.kt | 8 +- .../api/models/CardBalanceListPageAsync.kt | 8 +- .../api/models/CardBalanceListPageResponse.kt | 22 +- .../com/lithic/api/models/CardBulkOrder.kt | 747 ++++++++ .../api/models/CardBulkOrderCreateParams.kt | 691 ++++++++ .../api/models/CardBulkOrderListPage.kt | 133 ++ .../api/models/CardBulkOrderListPageAsync.kt | 148 ++ .../models/CardBulkOrderListPageResponse.kt | 229 +++ .../api/models/CardBulkOrderListParams.kt | 298 ++++ .../api/models/CardBulkOrderRetrieveParams.kt | 197 +++ .../api/models/CardBulkOrderUpdateParams.kt | 565 ++++++ .../api/models/CardConvertPhysicalParams.kt | 11 + .../com/lithic/api/models/CardCreateParams.kt | 101 +- .../lithic/api/models/CardReissueParams.kt | 11 + .../com/lithic/api/models/CardRenewParams.kt | 11 + .../api/models/CardholderAuthentication.kt | 996 +++++++++++ .../kotlin/com/lithic/api/models/Device.kt | 265 +++ .../api/models/DigitalWalletTokenMetadata.kt | 1082 ++++++++++++ ...auseResponse.kt => ExternalBankAccount.kt} | 72 +- ...ExternalBankAccountRetryPrenoteResponse.kt | 1534 ---------------- ...Response.kt => FinancialAccountBalance.kt} | 42 +- .../models/FinancialAccountBalanceListPage.kt | 8 +- .../FinancialAccountBalanceListPageAsync.kt | 8 +- ...FinancialAccountBalanceListPageResponse.kt | 22 +- ...ngEventListResponse.kt => FundingEvent.kt} | 38 +- .../lithic/api/models/FundingEventListPage.kt | 9 +- .../api/models/FundingEventListPageAsync.kt | 10 +- .../models/FundingEventListPageResponse.kt | 26 +- .../models/FundingEventRetrieveResponse.kt | 888 ---------- .../lithic/api/models/InternalTransaction.kt | 1539 +++++++++++++++++ ...rkTotalListResponse.kt => NetworkTotal.kt} | 46 +- .../models/NetworkTotalRetrieveResponse.kt | 1112 ------------ .../com/lithic/api/models/NonPciCard.kt | 54 +- .../ReportSettlementNetworkTotalListPage.kt | 9 +- ...portSettlementNetworkTotalListPageAsync.kt | 10 +- ...tSettlementNetworkTotalListPageResponse.kt | 26 +- ...veResponse.kt => ThreeDSAuthentication.kt} | 64 +- .../kotlin/com/lithic/api/models/TokenInfo.kt | 342 ++++ .../com/lithic/api/models/Tokenization.kt | 879 ---------- .../api/models/TokenizationDeclineReason.kt | 203 +++ .../api/models/TokenizationRuleResult.kt | 454 +++++ .../api/models/TokenizationTfaReason.kt | 213 +++ .../com/lithic/api/models/Transaction.kt | 1329 -------------- .../api/models/WalletDecisioningInfo.kt | 357 ++++ .../async/CardBulkOrderServiceAsync.kt | 251 +++ .../async/CardBulkOrderServiceAsyncImpl.kt | 219 +++ .../async/ExternalBankAccountServiceAsync.kt | 58 +- .../ExternalBankAccountServiceAsyncImpl.kt | 19 +- .../async/FundingEventServiceAsync.kt | 32 +- .../async/FundingEventServiceAsyncImpl.kt | 10 +- .../async/InternalTransactionServiceAsync.kt | 37 + .../InternalTransactionServiceAsyncImpl.kt | 35 + .../settlement/NetworkTotalServiceAsync.kt | 32 +- .../NetworkTotalServiceAsyncImpl.kt | 10 +- .../threeDS/AuthenticationServiceAsync.kt | 28 +- .../threeDS/AuthenticationServiceAsyncImpl.kt | 10 +- .../services/blocking/CardBulkOrderService.kt | 251 +++ .../blocking/CardBulkOrderServiceImpl.kt | 205 +++ .../blocking/ExternalBankAccountService.kt | 62 +- .../ExternalBankAccountServiceImpl.kt | 19 +- .../services/blocking/FundingEventService.kt | 32 +- .../blocking/FundingEventServiceImpl.kt | 10 +- .../blocking/InternalTransactionService.kt | 37 + .../InternalTransactionServiceImpl.kt | 32 + .../reports/settlement/NetworkTotalService.kt | 31 +- .../settlement/NetworkTotalServiceImpl.kt | 10 +- .../blocking/threeDS/AuthenticationService.kt | 29 +- .../threeDS/AuthenticationServiceImpl.kt | 10 +- .../models/AccountActivityListResponseTest.kt | 38 +- ...ActivityRetrieveTransactionResponseTest.kt | 38 +- .../models/CardBalanceListPageResponseTest.kt | 12 +- .../models/CardBulkOrderCreateParamsTest.kt | 73 + .../CardBulkOrderListPageResponseTest.kt | 78 + .../api/models/CardBulkOrderListParamsTest.kt | 56 + .../models/CardBulkOrderRetrieveParamsTest.kt | 28 + .../lithic/api/models/CardBulkOrderTest.kt | 63 + .../models/CardBulkOrderUpdateParamsTest.kt | 43 + .../lithic/api/models/CardCreateParamsTest.kt | 3 + .../api/models/CardListPageResponseTest.kt | 3 + .../kotlin/com/lithic/api/models/CardTest.kt | 3 + .../models/CardholderAuthenticationTest.kt | 55 + .../com/lithic/api/models/DeviceTest.kt | 41 + .../models/DigitalWalletTokenMetadataTest.kt | 88 + ...rnalBankAccountRetryPrenoteResponseTest.kt | 150 -- ...onseTest.kt => ExternalBankAccountTest.kt} | 82 +- ...ncialAccountBalanceListPageResponseTest.kt | 12 +- ...Test.kt => FinancialAccountBalanceTest.kt} | 43 +- .../FundingEventListPageResponseTest.kt | 22 +- .../FundingEventRetrieveResponseTest.kt | 84 - ...istResponseTest.kt => FundingEventTest.kt} | 49 +- .../api/models/InternalTransactionTest.kt | 102 ++ .../NetworkTotalRetrieveResponseTest.kt | 100 -- ...istResponseTest.kt => NetworkTotalTest.kt} | 54 +- .../com/lithic/api/models/NonPciCardTest.kt | 3 + ...tlementNetworkTotalListPageResponseTest.kt | 72 +- ...seTest.kt => ThreeDSAuthenticationTest.kt} | 270 ++- .../com/lithic/api/models/TokenInfoTest.kt | 32 + .../TokenizationListPageResponseTest.kt | 45 +- .../api/models/TokenizationRuleResultTest.kt | 49 + .../com/lithic/api/models/TokenizationTest.kt | 47 +- .../models/TransactionListPageResponseTest.kt | 56 +- .../com/lithic/api/models/TransactionTest.kt | 60 +- .../api/models/WalletDecisioningInfoTest.kt | 49 + .../lithic/api/services/ErrorHandlingTest.kt | 17 + .../lithic/api/services/ServiceParamsTest.kt | 1 + .../async/CardBulkOrderServiceAsyncTest.kt | 101 ++ .../services/async/CardServiceAsyncTest.kt | 1 + .../ExternalBankAccountServiceAsyncTest.kt | 12 +- .../threeDS/AuthenticationServiceAsyncTest.kt | 6 +- .../blocking/CardBulkOrderServiceTest.kt | 96 + .../api/services/blocking/CardServiceTest.kt | 1 + .../ExternalBankAccountServiceTest.kt | 9 +- .../threeDS/AuthenticationServiceTest.kt | 5 +- .../api/proguard/ProGuardCompatibilityTest.kt | 2 + 122 files changed, 11649 insertions(+), 7134 deletions(-) create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrder.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderCreateParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPage.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPageAsync.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPageResponse.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderRetrieveParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderUpdateParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardholderAuthentication.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/Device.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenMetadata.kt rename lithic-java-core/src/main/kotlin/com/lithic/api/models/{ExternalBankAccountUnpauseResponse.kt => ExternalBankAccount.kt} (95%) delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponse.kt rename lithic-java-core/src/main/kotlin/com/lithic/api/models/{BalanceListResponse.kt => FinancialAccountBalance.kt} (94%) rename lithic-java-core/src/main/kotlin/com/lithic/api/models/{FundingEventListResponse.kt => FundingEvent.kt} (95%) delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventRetrieveResponse.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransaction.kt rename lithic-java-core/src/main/kotlin/com/lithic/api/models/{NetworkTotalListResponse.kt => NetworkTotal.kt} (96%) delete mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalRetrieveResponse.kt rename lithic-java-core/src/main/kotlin/com/lithic/api/models/{AuthenticationRetrieveResponse.kt => ThreeDSAuthentication.kt} (99%) create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenInfo.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationDeclineReason.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationRuleResult.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTfaReason.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/WalletDecisioningInfo.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsync.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsyncImpl.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/async/InternalTransactionServiceAsync.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/async/InternalTransactionServiceAsyncImpl.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardBulkOrderService.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardBulkOrderServiceImpl.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/InternalTransactionService.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/InternalTransactionServiceImpl.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderCreateParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderListPageResponseTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderListParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderRetrieveParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderUpdateParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardholderAuthenticationTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DeviceTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenMetadataTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponseTest.kt rename lithic-java-core/src/test/kotlin/com/lithic/api/models/{ExternalBankAccountUnpauseResponseTest.kt => ExternalBankAccountTest.kt} (54%) rename lithic-java-core/src/test/kotlin/com/lithic/api/models/{BalanceListResponseTest.kt => FinancialAccountBalanceTest.kt} (57%) delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventRetrieveResponseTest.kt rename lithic-java-core/src/test/kotlin/com/lithic/api/models/{FundingEventListResponseTest.kt => FundingEventTest.kt} (57%) create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionTest.kt delete mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalRetrieveResponseTest.kt rename lithic-java-core/src/test/kotlin/com/lithic/api/models/{NetworkTotalListResponseTest.kt => NetworkTotalTest.kt} (58%) rename lithic-java-core/src/test/kotlin/com/lithic/api/models/{AuthenticationRetrieveResponseTest.kt => ThreeDSAuthenticationTest.kt} (55%) create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenInfoTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationRuleResultTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/WalletDecisioningInfoTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsyncTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardBulkOrderServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 3cab4cd3f..284673ed2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 172 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-a9de2732e7a28b7fc5b8b7b171781d617337b6223d82ef7d6a554d0bd2b33bab.yml -openapi_spec_hash: fc6111d286c7002cd854af23841d137e -config_hash: cbad5dbbbeb0a85e4e3b70e5865a1900 +configured_endpoints: 176 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-6d54fb5bba49d761acf9d62a7e105443a80a0d34dda61932ff1d1cb8fe214393.yml +openapi_spec_hash: 20da53572fec9742df4a6d403464521b +config_hash: ba3fbfc99a1b8635d9e79e9e49d12952 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 4d7561aea..9b537b39a 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 @@ -16,6 +16,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.CardBulkOrderService import com.lithic.api.services.blocking.CardProgramService import com.lithic.api.services.blocking.CardService import com.lithic.api.services.blocking.CreditProductService @@ -28,6 +29,7 @@ import com.lithic.api.services.blocking.ExternalPaymentService import com.lithic.api.services.blocking.FinancialAccountService import com.lithic.api.services.blocking.FraudService import com.lithic.api.services.blocking.FundingEventService +import com.lithic.api.services.blocking.InternalTransactionService import com.lithic.api.services.blocking.ManagementOperationService import com.lithic.api.services.blocking.NetworkProgramService import com.lithic.api.services.blocking.PaymentService @@ -91,6 +93,8 @@ interface LithicClient { fun cards(): CardService + fun cardBulkOrders(): CardBulkOrderService + fun balances(): BalanceService fun aggregateBalances(): AggregateBalanceService @@ -131,6 +135,8 @@ interface LithicClient { fun managementOperations(): ManagementOperationService + fun internalTransaction(): InternalTransactionService + fun fundingEvents(): FundingEventService fun fraud(): FraudService @@ -193,6 +199,8 @@ interface LithicClient { fun cards(): CardService.WithRawResponse + fun cardBulkOrders(): CardBulkOrderService.WithRawResponse + fun balances(): BalanceService.WithRawResponse fun aggregateBalances(): AggregateBalanceService.WithRawResponse @@ -231,6 +239,8 @@ interface LithicClient { fun managementOperations(): ManagementOperationService.WithRawResponse + fun internalTransaction(): InternalTransactionService.WithRawResponse + fun fundingEvents(): FundingEventService.WithRawResponse fun fraud(): FraudService.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 e8aa12038..ca0f3cbf3 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 @@ -15,6 +15,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.CardBulkOrderServiceAsync import com.lithic.api.services.async.CardProgramServiceAsync import com.lithic.api.services.async.CardServiceAsync import com.lithic.api.services.async.CreditProductServiceAsync @@ -27,6 +28,7 @@ import com.lithic.api.services.async.ExternalPaymentServiceAsync import com.lithic.api.services.async.FinancialAccountServiceAsync import com.lithic.api.services.async.FraudServiceAsync import com.lithic.api.services.async.FundingEventServiceAsync +import com.lithic.api.services.async.InternalTransactionServiceAsync import com.lithic.api.services.async.ManagementOperationServiceAsync import com.lithic.api.services.async.NetworkProgramServiceAsync import com.lithic.api.services.async.PaymentServiceAsync @@ -91,6 +93,8 @@ interface LithicClientAsync { fun cards(): CardServiceAsync + fun cardBulkOrders(): CardBulkOrderServiceAsync + fun balances(): BalanceServiceAsync fun aggregateBalances(): AggregateBalanceServiceAsync @@ -131,6 +135,8 @@ interface LithicClientAsync { fun managementOperations(): ManagementOperationServiceAsync + fun internalTransaction(): InternalTransactionServiceAsync + fun fundingEvents(): FundingEventServiceAsync fun fraud(): FraudServiceAsync @@ -196,6 +202,8 @@ interface LithicClientAsync { fun cards(): CardServiceAsync.WithRawResponse + fun cardBulkOrders(): CardBulkOrderServiceAsync.WithRawResponse + fun balances(): BalanceServiceAsync.WithRawResponse fun aggregateBalances(): AggregateBalanceServiceAsync.WithRawResponse @@ -234,6 +242,8 @@ interface LithicClientAsync { fun managementOperations(): ManagementOperationServiceAsync.WithRawResponse + fun internalTransaction(): InternalTransactionServiceAsync.WithRawResponse + fun fundingEvents(): FundingEventServiceAsync.WithRawResponse fun fraud(): FraudServiceAsync.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 ec4117127..be7664e6c 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 @@ -33,6 +33,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.CardBulkOrderServiceAsync +import com.lithic.api.services.async.CardBulkOrderServiceAsyncImpl import com.lithic.api.services.async.CardProgramServiceAsync import com.lithic.api.services.async.CardProgramServiceAsyncImpl import com.lithic.api.services.async.CardServiceAsync @@ -57,6 +59,8 @@ import com.lithic.api.services.async.FraudServiceAsync import com.lithic.api.services.async.FraudServiceAsyncImpl import com.lithic.api.services.async.FundingEventServiceAsync import com.lithic.api.services.async.FundingEventServiceAsyncImpl +import com.lithic.api.services.async.InternalTransactionServiceAsync +import com.lithic.api.services.async.InternalTransactionServiceAsyncImpl import com.lithic.api.services.async.ManagementOperationServiceAsync import com.lithic.api.services.async.ManagementOperationServiceAsyncImpl import com.lithic.api.services.async.NetworkProgramServiceAsync @@ -125,6 +129,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl private val cards: CardServiceAsync by lazy { CardServiceAsyncImpl(clientOptionsWithUserAgent) } + private val cardBulkOrders: CardBulkOrderServiceAsync by lazy { + CardBulkOrderServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val balances: BalanceServiceAsync by lazy { BalanceServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -203,6 +211,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl ManagementOperationServiceAsyncImpl(clientOptionsWithUserAgent) } + private val internalTransaction: InternalTransactionServiceAsync by lazy { + InternalTransactionServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val fundingEvents: FundingEventServiceAsync by lazy { FundingEventServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -241,6 +253,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun cards(): CardServiceAsync = cards + override fun cardBulkOrders(): CardBulkOrderServiceAsync = cardBulkOrders + override fun balances(): BalanceServiceAsync = balances override fun aggregateBalances(): AggregateBalanceServiceAsync = aggregateBalances @@ -281,6 +295,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun managementOperations(): ManagementOperationServiceAsync = managementOperations + override fun internalTransaction(): InternalTransactionServiceAsync = internalTransaction + override fun fundingEvents(): FundingEventServiceAsync = fundingEvents override fun fraud(): FraudServiceAsync = fraud @@ -333,6 +349,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl CardServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val cardBulkOrders: CardBulkOrderServiceAsync.WithRawResponse by lazy { + CardBulkOrderServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val balances: BalanceServiceAsync.WithRawResponse by lazy { BalanceServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -409,6 +429,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl ManagementOperationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val internalTransaction: InternalTransactionServiceAsync.WithRawResponse by lazy { + InternalTransactionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val fundingEvents: FundingEventServiceAsync.WithRawResponse by lazy { FundingEventServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -448,6 +472,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun cards(): CardServiceAsync.WithRawResponse = cards + override fun cardBulkOrders(): CardBulkOrderServiceAsync.WithRawResponse = cardBulkOrders + override fun balances(): BalanceServiceAsync.WithRawResponse = balances override fun aggregateBalances(): AggregateBalanceServiceAsync.WithRawResponse = @@ -492,6 +518,9 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun managementOperations(): ManagementOperationServiceAsync.WithRawResponse = managementOperations + override fun internalTransaction(): InternalTransactionServiceAsync.WithRawResponse = + internalTransaction + override fun fundingEvents(): FundingEventServiceAsync.WithRawResponse = fundingEvents override fun fraud(): FraudServiceAsync.WithRawResponse = fraud 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 f3e4589f0..24ac9408c 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 @@ -33,6 +33,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.CardBulkOrderService +import com.lithic.api.services.blocking.CardBulkOrderServiceImpl import com.lithic.api.services.blocking.CardProgramService import com.lithic.api.services.blocking.CardProgramServiceImpl import com.lithic.api.services.blocking.CardService @@ -57,6 +59,8 @@ import com.lithic.api.services.blocking.FraudService import com.lithic.api.services.blocking.FraudServiceImpl import com.lithic.api.services.blocking.FundingEventService import com.lithic.api.services.blocking.FundingEventServiceImpl +import com.lithic.api.services.blocking.InternalTransactionService +import com.lithic.api.services.blocking.InternalTransactionServiceImpl import com.lithic.api.services.blocking.ManagementOperationService import com.lithic.api.services.blocking.ManagementOperationServiceImpl import com.lithic.api.services.blocking.NetworkProgramService @@ -122,6 +126,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient private val cards: CardService by lazy { CardServiceImpl(clientOptionsWithUserAgent) } + private val cardBulkOrders: CardBulkOrderService by lazy { + CardBulkOrderServiceImpl(clientOptionsWithUserAgent) + } + private val balances: BalanceService by lazy { BalanceServiceImpl(clientOptionsWithUserAgent) } private val aggregateBalances: AggregateBalanceService by lazy { @@ -188,6 +196,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient ManagementOperationServiceImpl(clientOptionsWithUserAgent) } + private val internalTransaction: InternalTransactionService by lazy { + InternalTransactionServiceImpl(clientOptionsWithUserAgent) + } + private val fundingEvents: FundingEventService by lazy { FundingEventServiceImpl(clientOptionsWithUserAgent) } @@ -223,6 +235,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun cards(): CardService = cards + override fun cardBulkOrders(): CardBulkOrderService = cardBulkOrders + override fun balances(): BalanceService = balances override fun aggregateBalances(): AggregateBalanceService = aggregateBalances @@ -263,6 +277,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun managementOperations(): ManagementOperationService = managementOperations + override fun internalTransaction(): InternalTransactionService = internalTransaction + override fun fundingEvents(): FundingEventService = fundingEvents override fun fraud(): FraudService = fraud @@ -315,6 +331,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient CardServiceImpl.WithRawResponseImpl(clientOptions) } + private val cardBulkOrders: CardBulkOrderService.WithRawResponse by lazy { + CardBulkOrderServiceImpl.WithRawResponseImpl(clientOptions) + } + private val balances: BalanceService.WithRawResponse by lazy { BalanceServiceImpl.WithRawResponseImpl(clientOptions) } @@ -391,6 +411,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient ManagementOperationServiceImpl.WithRawResponseImpl(clientOptions) } + private val internalTransaction: InternalTransactionService.WithRawResponse by lazy { + InternalTransactionServiceImpl.WithRawResponseImpl(clientOptions) + } + private val fundingEvents: FundingEventService.WithRawResponse by lazy { FundingEventServiceImpl.WithRawResponseImpl(clientOptions) } @@ -430,6 +454,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun cards(): CardService.WithRawResponse = cards + override fun cardBulkOrders(): CardBulkOrderService.WithRawResponse = cardBulkOrders + override fun balances(): BalanceService.WithRawResponse = balances override fun aggregateBalances(): AggregateBalanceService.WithRawResponse = @@ -473,6 +499,9 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun managementOperations(): ManagementOperationService.WithRawResponse = managementOperations + override fun internalTransaction(): InternalTransactionService.WithRawResponse = + internalTransaction + override fun fundingEvents(): FundingEventService.WithRawResponse = fundingEvents override fun fraud(): FraudService.WithRawResponse = fraud diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt index a9f83fd75..9423d092f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt @@ -1707,7 +1707,7 @@ private constructor( private val authorizationCode: JsonField, private val avs: JsonField, private val cardToken: JsonField, - private val cardholderAuthentication: JsonField, + private val cardholderAuthentication: JsonField, private val created: JsonField, private val financialAccountToken: JsonField, private val merchant: JsonField, @@ -1720,7 +1720,7 @@ private constructor( private val result: JsonField, private val settledAmount: JsonField, private val status: JsonField, - private val tokenInfo: JsonField, + private val tokenInfo: JsonField, private val updated: JsonField, private val events: JsonField>, private val family: JsonField, @@ -1755,8 +1755,7 @@ private constructor( cardToken: JsonField = JsonMissing.of(), @JsonProperty("cardholder_authentication") @ExcludeMissing - cardholderAuthentication: JsonField = - JsonMissing.of(), + cardholderAuthentication: JsonField = JsonMissing.of(), @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), @@ -1793,7 +1792,7 @@ private constructor( status: JsonField = JsonMissing.of(), @JsonProperty("token_info") @ExcludeMissing - tokenInfo: JsonField = JsonMissing.of(), + tokenInfo: JsonField = JsonMissing.of(), @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), @@ -1954,7 +1953,7 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cardholderAuthentication(): Optional = + fun cardholderAuthentication(): Optional = cardholderAuthentication.getOptional("cardholder_authentication") /** @@ -2059,7 +2058,7 @@ private constructor( * @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") + fun tokenInfo(): Optional = tokenInfo.getOptional("token_info") /** * Date and time when the transaction last updated. UTC time zone. @@ -2182,7 +2181,7 @@ private constructor( */ @JsonProperty("cardholder_authentication") @ExcludeMissing - fun _cardholderAuthentication(): JsonField = + fun _cardholderAuthentication(): JsonField = cardholderAuthentication /** @@ -2304,7 +2303,7 @@ private constructor( */ @JsonProperty("token_info") @ExcludeMissing - fun _tokenInfo(): JsonField = tokenInfo + fun _tokenInfo(): JsonField = tokenInfo /** * Returns the raw JSON value of [updated]. @@ -2392,8 +2391,7 @@ private constructor( private var authorizationCode: JsonField? = null private var avs: JsonField? = null private var cardToken: JsonField? = null - private var cardholderAuthentication: JsonField? = - null + private var cardholderAuthentication: JsonField? = null private var created: JsonField? = null private var financialAccountToken: JsonField? = null private var merchant: JsonField? = null @@ -2406,7 +2404,7 @@ private constructor( private var result: JsonField? = null private var settledAmount: JsonField? = null private var status: JsonField? = null - private var tokenInfo: JsonField? = null + private var tokenInfo: JsonField? = null private var updated: JsonField? = null private var events: JsonField>? = null private var family: JsonField? = null @@ -2641,27 +2639,26 @@ private constructor( */ fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } - fun cardholderAuthentication( - cardholderAuthentication: Transaction.CardholderAuthentication? - ) = cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) + fun cardholderAuthentication(cardholderAuthentication: CardholderAuthentication?) = + cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) /** * Alias for calling [Builder.cardholderAuthentication] with * `cardholderAuthentication.orElse(null)`. */ fun cardholderAuthentication( - cardholderAuthentication: Optional + cardholderAuthentication: Optional ) = cardholderAuthentication(cardholderAuthentication.getOrNull()) /** * Sets [Builder.cardholderAuthentication] to an arbitrary JSON value. * * You should usually call [Builder.cardholderAuthentication] with a well-typed - * [Transaction.CardholderAuthentication] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * [CardholderAuthentication] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ fun cardholderAuthentication( - cardholderAuthentication: JsonField + cardholderAuthentication: JsonField ) = apply { this.cardholderAuthentication = cardholderAuthentication } /** Date and time when the transaction first occurred. UTC time zone. */ @@ -2893,23 +2890,19 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } - fun tokenInfo(tokenInfo: Transaction.TokenInfo?) = - tokenInfo(JsonField.ofNullable(tokenInfo)) + fun tokenInfo(tokenInfo: TokenInfo?) = tokenInfo(JsonField.ofNullable(tokenInfo)) /** Alias for calling [Builder.tokenInfo] with `tokenInfo.orElse(null)`. */ - fun tokenInfo(tokenInfo: Optional) = - tokenInfo(tokenInfo.getOrNull()) + fun tokenInfo(tokenInfo: Optional) = tokenInfo(tokenInfo.getOrNull()) /** * Sets [Builder.tokenInfo] to an arbitrary JSON value. * - * You should usually call [Builder.tokenInfo] with a well-typed [Transaction.TokenInfo] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * 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 - } + fun tokenInfo(tokenInfo: JsonField) = apply { this.tokenInfo = tokenInfo } /** Date and time when the transaction last updated. UTC time zone. */ fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt index 60c072c17..2990eb9af 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt @@ -1729,7 +1729,7 @@ private constructor( private val authorizationCode: JsonField, private val avs: JsonField, private val cardToken: JsonField, - private val cardholderAuthentication: JsonField, + private val cardholderAuthentication: JsonField, private val created: JsonField, private val financialAccountToken: JsonField, private val merchant: JsonField, @@ -1742,7 +1742,7 @@ private constructor( private val result: JsonField, private val settledAmount: JsonField, private val status: JsonField, - private val tokenInfo: JsonField, + private val tokenInfo: JsonField, private val updated: JsonField, private val events: JsonField>, private val family: JsonField, @@ -1777,8 +1777,7 @@ private constructor( cardToken: JsonField = JsonMissing.of(), @JsonProperty("cardholder_authentication") @ExcludeMissing - cardholderAuthentication: JsonField = - JsonMissing.of(), + cardholderAuthentication: JsonField = JsonMissing.of(), @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), @@ -1815,7 +1814,7 @@ private constructor( status: JsonField = JsonMissing.of(), @JsonProperty("token_info") @ExcludeMissing - tokenInfo: JsonField = JsonMissing.of(), + tokenInfo: JsonField = JsonMissing.of(), @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), @@ -1976,7 +1975,7 @@ private constructor( * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun cardholderAuthentication(): Optional = + fun cardholderAuthentication(): Optional = cardholderAuthentication.getOptional("cardholder_authentication") /** @@ -2081,7 +2080,7 @@ private constructor( * @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") + fun tokenInfo(): Optional = tokenInfo.getOptional("token_info") /** * Date and time when the transaction last updated. UTC time zone. @@ -2204,7 +2203,7 @@ private constructor( */ @JsonProperty("cardholder_authentication") @ExcludeMissing - fun _cardholderAuthentication(): JsonField = + fun _cardholderAuthentication(): JsonField = cardholderAuthentication /** @@ -2326,7 +2325,7 @@ private constructor( */ @JsonProperty("token_info") @ExcludeMissing - fun _tokenInfo(): JsonField = tokenInfo + fun _tokenInfo(): JsonField = tokenInfo /** * Returns the raw JSON value of [updated]. @@ -2414,8 +2413,7 @@ private constructor( private var authorizationCode: JsonField? = null private var avs: JsonField? = null private var cardToken: JsonField? = null - private var cardholderAuthentication: JsonField? = - null + private var cardholderAuthentication: JsonField? = null private var created: JsonField? = null private var financialAccountToken: JsonField? = null private var merchant: JsonField? = null @@ -2428,7 +2426,7 @@ private constructor( private var result: JsonField? = null private var settledAmount: JsonField? = null private var status: JsonField? = null - private var tokenInfo: JsonField? = null + private var tokenInfo: JsonField? = null private var updated: JsonField? = null private var events: JsonField>? = null private var family: JsonField? = null @@ -2663,27 +2661,26 @@ private constructor( */ fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } - fun cardholderAuthentication( - cardholderAuthentication: Transaction.CardholderAuthentication? - ) = cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) + fun cardholderAuthentication(cardholderAuthentication: CardholderAuthentication?) = + cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) /** * Alias for calling [Builder.cardholderAuthentication] with * `cardholderAuthentication.orElse(null)`. */ fun cardholderAuthentication( - cardholderAuthentication: Optional + cardholderAuthentication: Optional ) = cardholderAuthentication(cardholderAuthentication.getOrNull()) /** * Sets [Builder.cardholderAuthentication] to an arbitrary JSON value. * * You should usually call [Builder.cardholderAuthentication] with a well-typed - * [Transaction.CardholderAuthentication] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. + * [CardholderAuthentication] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ fun cardholderAuthentication( - cardholderAuthentication: JsonField + cardholderAuthentication: JsonField ) = apply { this.cardholderAuthentication = cardholderAuthentication } /** Date and time when the transaction first occurred. UTC time zone. */ @@ -2915,23 +2912,19 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } - fun tokenInfo(tokenInfo: Transaction.TokenInfo?) = - tokenInfo(JsonField.ofNullable(tokenInfo)) + fun tokenInfo(tokenInfo: TokenInfo?) = tokenInfo(JsonField.ofNullable(tokenInfo)) /** Alias for calling [Builder.tokenInfo] with `tokenInfo.orElse(null)`. */ - fun tokenInfo(tokenInfo: Optional) = - tokenInfo(tokenInfo.getOrNull()) + fun tokenInfo(tokenInfo: Optional) = tokenInfo(tokenInfo.getOrNull()) /** * Sets [Builder.tokenInfo] to an arbitrary JSON value. * - * You should usually call [Builder.tokenInfo] with a well-typed [Transaction.TokenInfo] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * 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 - } + fun tokenInfo(tokenInfo: JsonField) = apply { this.tokenInfo = tokenInfo } /** Date and time when the transaction last updated. UTC time zone. */ fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt index cda272781..086c5724d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Card.kt @@ -36,6 +36,7 @@ private constructor( private val state: JsonField, private val type: JsonField, private val authRuleTokens: JsonField>, + private val bulkOrderToken: JsonField, private val cardholderCurrency: JsonField, private val comment: JsonField, private val digitalCardArtToken: JsonField, @@ -83,6 +84,9 @@ private constructor( @JsonProperty("auth_rule_tokens") @ExcludeMissing authRuleTokens: JsonField> = JsonMissing.of(), + @JsonProperty("bulk_order_token") + @ExcludeMissing + bulkOrderToken: JsonField = JsonMissing.of(), @JsonProperty("cardholder_currency") @ExcludeMissing cardholderCurrency: JsonField = JsonMissing.of(), @@ -122,6 +126,7 @@ private constructor( state, type, authRuleTokens, + bulkOrderToken, cardholderCurrency, comment, digitalCardArtToken, @@ -153,6 +158,7 @@ private constructor( .state(state) .type(type) .authRuleTokens(authRuleTokens) + .bulkOrderToken(bulkOrderToken) .cardholderCurrency(cardholderCurrency) .comment(comment) .digitalCardArtToken(digitalCardArtToken) @@ -295,6 +301,15 @@ private constructor( @Deprecated("deprecated") fun authRuleTokens(): Optional> = authRuleTokens.getOptional("auth_rule_tokens") + /** + * Globally unique identifier for the bulk order associated with this card. Only applicable to + * physical cards that are part of a bulk shipment + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bulkOrderToken(): Optional = bulkOrderToken.getOptional("bulk_order_token") + /** * 3-character alphabetic ISO 4217 code for the currency of the cardholder. * @@ -534,6 +549,15 @@ private constructor( @ExcludeMissing fun _authRuleTokens(): JsonField> = authRuleTokens + /** + * Returns the raw JSON value of [bulkOrderToken]. + * + * Unlike [bulkOrderToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bulk_order_token") + @ExcludeMissing + fun _bulkOrderToken(): JsonField = bulkOrderToken + /** * Returns the raw JSON value of [cardholderCurrency]. * @@ -697,6 +721,7 @@ private constructor( private var state: JsonField? = null private var type: JsonField? = null private var authRuleTokens: JsonField>? = null + private var bulkOrderToken: JsonField = JsonMissing.of() private var cardholderCurrency: JsonField = JsonMissing.of() private var comment: JsonField = JsonMissing.of() private var digitalCardArtToken: JsonField = JsonMissing.of() @@ -727,6 +752,7 @@ private constructor( state = card.state type = card.type authRuleTokens = card.authRuleTokens.map { it.toMutableList() } + bulkOrderToken = card.bulkOrderToken cardholderCurrency = card.cardholderCurrency comment = card.comment digitalCardArtToken = card.digitalCardArtToken @@ -961,6 +987,28 @@ private constructor( } } + /** + * Globally unique identifier for the bulk order associated with this card. Only applicable + * to physical cards that are part of a bulk shipment + */ + fun bulkOrderToken(bulkOrderToken: String?) = + bulkOrderToken(JsonField.ofNullable(bulkOrderToken)) + + /** Alias for calling [Builder.bulkOrderToken] with `bulkOrderToken.orElse(null)`. */ + fun bulkOrderToken(bulkOrderToken: Optional) = + bulkOrderToken(bulkOrderToken.getOrNull()) + + /** + * Sets [Builder.bulkOrderToken] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkOrderToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bulkOrderToken(bulkOrderToken: JsonField) = apply { + this.bulkOrderToken = bulkOrderToken + } + /** 3-character alphabetic ISO 4217 code for the currency of the cardholder. */ fun cardholderCurrency(cardholderCurrency: String) = cardholderCurrency(JsonField.of(cardholderCurrency)) @@ -1258,6 +1306,7 @@ private constructor( checkRequired("state", state), checkRequired("type", type), (authRuleTokens ?: JsonMissing.of()).map { it.toImmutable() }, + bulkOrderToken, cardholderCurrency, comment, digitalCardArtToken, @@ -1295,6 +1344,7 @@ private constructor( state().validate() type().validate() authRuleTokens() + bulkOrderToken() cardholderCurrency() comment() digitalCardArtToken() @@ -1339,6 +1389,7 @@ private constructor( (state.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + (authRuleTokens.asKnown().getOrNull()?.size ?: 0) + + (if (bulkOrderToken.asKnown().isPresent) 1 else 0) + (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + (if (comment.asKnown().isPresent) 1 else 0) + (if (digitalCardArtToken.asKnown().isPresent) 1 else 0) + @@ -1372,6 +1423,7 @@ private constructor( state == other.state && type == other.type && authRuleTokens == other.authRuleTokens && + bulkOrderToken == other.bulkOrderToken && cardholderCurrency == other.cardholderCurrency && comment == other.comment && digitalCardArtToken == other.digitalCardArtToken && @@ -1403,6 +1455,7 @@ private constructor( state, type, authRuleTokens, + bulkOrderToken, cardholderCurrency, comment, digitalCardArtToken, @@ -1424,5 +1477,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Card{token=$token, accountToken=$accountToken, cardProgramToken=$cardProgramToken, created=$created, funding=$funding, lastFour=$lastFour, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, authRuleTokens=$authRuleTokens, cardholderCurrency=$cardholderCurrency, comment=$comment, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, hostname=$hostname, memo=$memo, networkProgramToken=$networkProgramToken, pendingCommands=$pendingCommands, productId=$productId, replacementFor=$replacementFor, substatus=$substatus, cvv=$cvv, pan=$pan, additionalProperties=$additionalProperties}" + "Card{token=$token, accountToken=$accountToken, cardProgramToken=$cardProgramToken, created=$created, funding=$funding, lastFour=$lastFour, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, authRuleTokens=$authRuleTokens, bulkOrderToken=$bulkOrderToken, cardholderCurrency=$cardholderCurrency, comment=$comment, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, hostname=$hostname, memo=$memo, networkProgramToken=$networkProgramToken, pendingCommands=$pendingCommands, productId=$productId, replacementFor=$replacementFor, substatus=$substatus, cvv=$cvv, pan=$pan, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPage.kt index 560f9bcfb..d91f7242c 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPage.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPage.kt @@ -16,14 +16,14 @@ private constructor( private val service: BalanceService, private val params: CardBalanceListParams, private val response: CardBalanceListPageResponse, -) : Page { +) : Page { /** * Delegates to [CardBalanceListPageResponse], but gracefully handles missing data. * * @see CardBalanceListPageResponse.data */ - fun data(): List = + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** @@ -33,7 +33,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = false @@ -42,7 +42,7 @@ private constructor( override fun nextPage(): CardBalanceListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CardBalanceListParams = params diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageAsync.kt index b9e6973bc..24c342666 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageAsync.kt @@ -19,14 +19,14 @@ private constructor( private val streamHandlerExecutor: Executor, private val params: CardBalanceListParams, private val response: CardBalanceListPageResponse, -) : PageAsync { +) : PageAsync { /** * Delegates to [CardBalanceListPageResponse], but gracefully handles missing data. * * @see CardBalanceListPageResponse.data */ - fun data(): List = + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** @@ -36,7 +36,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = false @@ -46,7 +46,7 @@ private constructor( override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPagerAsync = + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageResponse.kt index 592088fba..de66298c0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBalanceListPageResponse.kt @@ -21,7 +21,7 @@ import kotlin.jvm.optionals.getOrNull class CardBalanceListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val data: JsonField>, + private val data: JsonField>, private val hasMore: JsonField, private val additionalProperties: MutableMap, ) { @@ -30,7 +30,7 @@ private constructor( private constructor( @JsonProperty("data") @ExcludeMissing - data: JsonField> = JsonMissing.of(), + data: JsonField> = JsonMissing.of(), @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), ) : this(data, hasMore, mutableMapOf()) @@ -38,7 +38,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 data(): List = data.getRequired("data") + fun data(): List = data.getRequired("data") /** * More data exists. @@ -53,7 +53,9 @@ private constructor( * * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data /** * Returns the raw JSON value of [hasMore]. @@ -91,7 +93,7 @@ private constructor( /** A builder for [CardBalanceListPageResponse]. */ class Builder internal constructor() { - private var data: JsonField>? = null + private var data: JsonField>? = null private var hasMore: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -102,25 +104,25 @@ private constructor( additionalProperties = cardBalanceListPageResponse.additionalProperties.toMutableMap() } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) /** * Sets [Builder.data] to an arbitrary JSON value. * - * You should usually call [Builder.data] with a well-typed `List` + * You should usually call [Builder.data] with a well-typed `List` * value instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } /** - * Adds a single [BalanceListResponse] to [Builder.data]. + * Adds a single [FinancialAccountBalance] to [Builder.data]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addData(data: BalanceListResponse) = apply { + fun addData(data: FinancialAccountBalance) = apply { this.data = (this.data ?: JsonField.of(mutableListOf())).also { checkKnown("data", it).add(data) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrder.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrder.kt new file mode 100644 index 000000000..46e3f2d7e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrder.kt @@ -0,0 +1,747 @@ +// 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 + +/** Represents a bulk order for physical card shipments */ +class CardBulkOrder +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val cardTokens: JsonField>, + private val created: JsonField, + private val customerProductId: JsonField, + private val shippingAddress: JsonValue, + private val shippingMethod: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("card_tokens") + @ExcludeMissing + cardTokens: JsonField> = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("customer_product_id") + @ExcludeMissing + customerProductId: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + shippingAddress: JsonValue = JsonMissing.of(), + @JsonProperty("shipping_method") + @ExcludeMissing + shippingMethod: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + ) : this( + token, + cardTokens, + created, + customerProductId, + shippingAddress, + shippingMethod, + status, + updated, + mutableMapOf(), + ) + + /** + * Globally unique identifier for the bulk order + * + * @throws LithicInvalidDataException if 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") + + /** + * List of card tokens associated with this bulk order + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardTokens(): List = cardTokens.getRequired("card_tokens") + + /** + * An RFC 3339 timestamp for when the bulk order was created. UTC time zone + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * Customer-specified product configuration for physical card manufacturing. This must be + * configured with Lithic before use + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerProductId(): Optional = customerProductId.getOptional("customer_product_id") + + /** Shipping address for all cards in this bulk order */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonValue = shippingAddress + + /** + * Shipping method for all cards in this bulk order + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun shippingMethod(): ShippingMethod = shippingMethod.getRequired("shipping_method") + + /** + * Status of the bulk order. OPEN indicates the order is accepting cards. LOCKED indicates the + * order is finalized and no more cards can be added + * + * @throws LithicInvalidDataException if 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") + + /** + * An RFC 3339 timestamp for when the bulk order was last updated. UTC time zone + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * 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 [cardTokens]. + * + * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_tokens") + @ExcludeMissing + fun _cardTokens(): JsonField> = cardTokens + + /** + * 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 [customerProductId]. + * + * Unlike [customerProductId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_product_id") + @ExcludeMissing + fun _customerProductId(): JsonField = customerProductId + + /** + * Returns the raw JSON value of [shippingMethod]. + * + * Unlike [shippingMethod], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shipping_method") + @ExcludeMissing + fun _shippingMethod(): JsonField = shippingMethod + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardBulkOrder]. + * + * The following fields are required: + * ```java + * .token() + * .cardTokens() + * .created() + * .customerProductId() + * .shippingAddress() + * .shippingMethod() + * .status() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardBulkOrder]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var cardTokens: JsonField>? = null + private var created: JsonField? = null + private var customerProductId: JsonField? = null + private var shippingAddress: JsonValue? = null + private var shippingMethod: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardBulkOrder: CardBulkOrder) = apply { + token = cardBulkOrder.token + cardTokens = cardBulkOrder.cardTokens.map { it.toMutableList() } + created = cardBulkOrder.created + customerProductId = cardBulkOrder.customerProductId + shippingAddress = cardBulkOrder.shippingAddress + shippingMethod = cardBulkOrder.shippingMethod + status = cardBulkOrder.status + updated = cardBulkOrder.updated + additionalProperties = cardBulkOrder.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the bulk order */ + 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 } + + /** List of card tokens associated with this bulk order */ + fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens)) + + /** + * Sets [Builder.cardTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.cardTokens] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardTokens(cardTokens: JsonField>) = apply { + this.cardTokens = cardTokens.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [cardTokens]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCardToken(cardToken: String) = apply { + cardTokens = + (cardTokens ?: JsonField.of(mutableListOf())).also { + checkKnown("cardTokens", it).add(cardToken) + } + } + + /** An RFC 3339 timestamp for when the bulk order was created. UTC time zone */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** + * Customer-specified product configuration for physical card manufacturing. This must be + * configured with Lithic before use + */ + fun customerProductId(customerProductId: String?) = + customerProductId(JsonField.ofNullable(customerProductId)) + + /** Alias for calling [Builder.customerProductId] with `customerProductId.orElse(null)`. */ + fun customerProductId(customerProductId: Optional) = + customerProductId(customerProductId.getOrNull()) + + /** + * Sets [Builder.customerProductId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerProductId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerProductId(customerProductId: JsonField) = apply { + this.customerProductId = customerProductId + } + + /** Shipping address for all cards in this bulk order */ + fun shippingAddress(shippingAddress: JsonValue) = apply { + this.shippingAddress = shippingAddress + } + + /** Shipping method for all cards in this bulk order */ + fun shippingMethod(shippingMethod: ShippingMethod) = + shippingMethod(JsonField.of(shippingMethod)) + + /** + * Sets [Builder.shippingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingMethod] with a well-typed [ShippingMethod] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shippingMethod(shippingMethod: JsonField) = apply { + this.shippingMethod = shippingMethod + } + + /** + * Status of the bulk order. OPEN indicates the order is accepting cards. LOCKED indicates + * the order is finalized and no more cards can be added + */ + 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 } + + /** An RFC 3339 timestamp for when the bulk order was last updated. UTC time zone */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun 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 [CardBulkOrder]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .cardTokens() + * .created() + * .customerProductId() + * .shippingAddress() + * .shippingMethod() + * .status() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardBulkOrder = + CardBulkOrder( + checkRequired("token", token), + checkRequired("cardTokens", cardTokens).map { it.toImmutable() }, + checkRequired("created", created), + checkRequired("customerProductId", customerProductId), + checkRequired("shippingAddress", shippingAddress), + checkRequired("shippingMethod", shippingMethod), + checkRequired("status", status), + checkRequired("updated", updated), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardBulkOrder = apply { + if (validated) { + return@apply + } + + token() + cardTokens() + created() + customerProductId() + shippingMethod().validate() + status().validate() + updated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (cardTokens.asKnown().getOrNull()?.size ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (customerProductId.asKnown().isPresent) 1 else 0) + + (shippingMethod.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + /** Shipping method for all cards in this bulk order */ + class ShippingMethod @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 BULK_EXPEDITED = of("BULK_EXPEDITED") + + @JvmStatic fun of(value: String) = ShippingMethod(JsonField.of(value)) + } + + /** An enum containing [ShippingMethod]'s known values. */ + enum class Known { + BULK_EXPEDITED + } + + /** + * An enum containing [ShippingMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ShippingMethod] 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 { + BULK_EXPEDITED, + /** + * An enum member indicating that [ShippingMethod] 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) { + BULK_EXPEDITED -> Value.BULK_EXPEDITED + 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) { + BULK_EXPEDITED -> Known.BULK_EXPEDITED + else -> throw LithicInvalidDataException("Unknown ShippingMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): ShippingMethod = 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 ShippingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Status of the bulk order. OPEN indicates the order is accepting cards. LOCKED indicates the + * order is finalized and no more cards can be added + */ + 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 OPEN = of("OPEN") + + @JvmField val LOCKED = of("LOCKED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + OPEN, + LOCKED, + } + + /** + * 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 { + OPEN, + LOCKED, + /** 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) { + OPEN -> Value.OPEN + LOCKED -> Value.LOCKED + 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) { + OPEN -> Known.OPEN + LOCKED -> Known.LOCKED + else -> throw LithicInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return 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 CardBulkOrder && + token == other.token && + cardTokens == other.cardTokens && + created == other.created && + customerProductId == other.customerProductId && + shippingAddress == other.shippingAddress && + shippingMethod == other.shippingMethod && + status == other.status && + updated == other.updated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + cardTokens, + created, + customerProductId, + shippingAddress, + shippingMethod, + status, + updated, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardBulkOrder{token=$token, cardTokens=$cardTokens, created=$created, customerProductId=$customerProductId, shippingAddress=$shippingAddress, shippingMethod=$shippingMethod, status=$status, updated=$updated, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderCreateParams.kt new file mode 100644 index 000000000..d285b23c5 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderCreateParams.kt @@ -0,0 +1,691 @@ +// 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 kotlin.jvm.optionals.getOrNull + +/** + * Create a new bulk order for physical card shipments **[BETA]**. Cards can be added to the order + * via the POST /v1/cards endpoint by specifying the bulk_order_token. Lock the order via PATCH + * /v1/card_bulk_orders/{bulk_order_token} to prepare for shipment. Please work with your Customer + * Success Manager and card personalization bureau to ensure bulk shipping is supported for your + * program. + */ +class CardBulkOrderCreateParams +private constructor( + private val body: CreateBulkOrderRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Customer-specified product configuration for physical card manufacturing. This must be + * configured with Lithic before use + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customerProductId(): String = body.customerProductId() + + /** Shipping address for all cards in this bulk order */ + fun _shippingAddress(): JsonValue = body._shippingAddress() + + /** + * Shipping method for all cards in this bulk order + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun shippingMethod(): ShippingMethod = body.shippingMethod() + + /** + * Returns the raw JSON value of [customerProductId]. + * + * Unlike [customerProductId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _customerProductId(): JsonField = body._customerProductId() + + /** + * Returns the raw JSON value of [shippingMethod]. + * + * Unlike [shippingMethod], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _shippingMethod(): JsonField = body._shippingMethod() + + 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 [CardBulkOrderCreateParams]. + * + * The following fields are required: + * ```java + * .customerProductId() + * .shippingAddress() + * .shippingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardBulkOrderCreateParams]. */ + class Builder internal constructor() { + + private var body: CreateBulkOrderRequest.Builder = CreateBulkOrderRequest.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardBulkOrderCreateParams: CardBulkOrderCreateParams) = apply { + body = cardBulkOrderCreateParams.body.toBuilder() + additionalHeaders = cardBulkOrderCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = cardBulkOrderCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [customerProductId] + * - [shippingAddress] + * - [shippingMethod] + */ + fun body(body: CreateBulkOrderRequest) = apply { this.body = body.toBuilder() } + + /** + * Customer-specified product configuration for physical card manufacturing. This must be + * configured with Lithic before use + */ + fun customerProductId(customerProductId: String) = apply { + body.customerProductId(customerProductId) + } + + /** + * Sets [Builder.customerProductId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerProductId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerProductId(customerProductId: JsonField) = apply { + body.customerProductId(customerProductId) + } + + /** Shipping address for all cards in this bulk order */ + fun shippingAddress(shippingAddress: JsonValue) = apply { + body.shippingAddress(shippingAddress) + } + + /** Shipping method for all cards in this bulk order */ + fun shippingMethod(shippingMethod: ShippingMethod) = apply { + body.shippingMethod(shippingMethod) + } + + /** + * Sets [Builder.shippingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingMethod] with a well-typed [ShippingMethod] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shippingMethod(shippingMethod: JsonField) = apply { + body.shippingMethod(shippingMethod) + } + + 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 [CardBulkOrderCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customerProductId() + * .shippingAddress() + * .shippingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardBulkOrderCreateParams = + CardBulkOrderCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): CreateBulkOrderRequest = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** + * Request to create a new bulk order for physical card shipments. Please work with your + * Customer Success Manager and card personalization bureau to ensure bulk shipping is supported + * for your program. + */ + class CreateBulkOrderRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val customerProductId: JsonField, + private val shippingAddress: JsonValue, + private val shippingMethod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("customer_product_id") + @ExcludeMissing + customerProductId: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + shippingAddress: JsonValue = JsonMissing.of(), + @JsonProperty("shipping_method") + @ExcludeMissing + shippingMethod: JsonField = JsonMissing.of(), + ) : this(customerProductId, shippingAddress, shippingMethod, mutableMapOf()) + + /** + * Customer-specified product configuration for physical card manufacturing. This must be + * configured with Lithic before use + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun customerProductId(): String = customerProductId.getRequired("customer_product_id") + + /** Shipping address for all cards in this bulk order */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonValue = shippingAddress + + /** + * Shipping method for all cards in this bulk order + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun shippingMethod(): ShippingMethod = shippingMethod.getRequired("shipping_method") + + /** + * Returns the raw JSON value of [customerProductId]. + * + * Unlike [customerProductId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_product_id") + @ExcludeMissing + fun _customerProductId(): JsonField = customerProductId + + /** + * Returns the raw JSON value of [shippingMethod]. + * + * Unlike [shippingMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("shipping_method") + @ExcludeMissing + fun _shippingMethod(): JsonField = shippingMethod + + @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 [CreateBulkOrderRequest]. + * + * The following fields are required: + * ```java + * .customerProductId() + * .shippingAddress() + * .shippingMethod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateBulkOrderRequest]. */ + class Builder internal constructor() { + + private var customerProductId: JsonField? = null + private var shippingAddress: JsonValue? = null + private var shippingMethod: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createBulkOrderRequest: CreateBulkOrderRequest) = apply { + customerProductId = createBulkOrderRequest.customerProductId + shippingAddress = createBulkOrderRequest.shippingAddress + shippingMethod = createBulkOrderRequest.shippingMethod + additionalProperties = createBulkOrderRequest.additionalProperties.toMutableMap() + } + + /** + * Customer-specified product configuration for physical card manufacturing. This must + * be configured with Lithic before use + */ + fun customerProductId(customerProductId: String) = + customerProductId(JsonField.of(customerProductId)) + + /** + * Sets [Builder.customerProductId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerProductId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerProductId(customerProductId: JsonField) = apply { + this.customerProductId = customerProductId + } + + /** Shipping address for all cards in this bulk order */ + fun shippingAddress(shippingAddress: JsonValue) = apply { + this.shippingAddress = shippingAddress + } + + /** Shipping method for all cards in this bulk order */ + fun shippingMethod(shippingMethod: ShippingMethod) = + shippingMethod(JsonField.of(shippingMethod)) + + /** + * Sets [Builder.shippingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingMethod] with a well-typed [ShippingMethod] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun shippingMethod(shippingMethod: JsonField) = apply { + this.shippingMethod = shippingMethod + } + + 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 [CreateBulkOrderRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .customerProductId() + * .shippingAddress() + * .shippingMethod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreateBulkOrderRequest = + CreateBulkOrderRequest( + checkRequired("customerProductId", customerProductId), + checkRequired("shippingAddress", shippingAddress), + checkRequired("shippingMethod", shippingMethod), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreateBulkOrderRequest = apply { + if (validated) { + return@apply + } + + customerProductId() + shippingMethod().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 (customerProductId.asKnown().isPresent) 1 else 0) + + (shippingMethod.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateBulkOrderRequest && + customerProductId == other.customerProductId && + shippingAddress == other.shippingAddress && + shippingMethod == other.shippingMethod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(customerProductId, shippingAddress, shippingMethod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateBulkOrderRequest{customerProductId=$customerProductId, shippingAddress=$shippingAddress, shippingMethod=$shippingMethod, additionalProperties=$additionalProperties}" + } + + /** Shipping method for all cards in this bulk order */ + class ShippingMethod @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 BULK_EXPEDITED = of("BULK_EXPEDITED") + + @JvmStatic fun of(value: String) = ShippingMethod(JsonField.of(value)) + } + + /** An enum containing [ShippingMethod]'s known values. */ + enum class Known { + BULK_EXPEDITED + } + + /** + * An enum containing [ShippingMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ShippingMethod] 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 { + BULK_EXPEDITED, + /** + * An enum member indicating that [ShippingMethod] 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) { + BULK_EXPEDITED -> Value.BULK_EXPEDITED + 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) { + BULK_EXPEDITED -> Known.BULK_EXPEDITED + else -> throw LithicInvalidDataException("Unknown ShippingMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): ShippingMethod = 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 ShippingMethod && 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 CardBulkOrderCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardBulkOrderCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPage.kt new file mode 100644 index 000000000..6290853ae --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPage.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.AutoPager +import com.lithic.api.core.Page +import com.lithic.api.core.checkRequired +import com.lithic.api.services.blocking.CardBulkOrderService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see CardBulkOrderService.list */ +class CardBulkOrderListPage +private constructor( + private val service: CardBulkOrderService, + private val params: CardBulkOrderListParams, + private val response: CardBulkOrderListPageResponse, +) : Page { + + /** + * Delegates to [CardBulkOrderListPageResponse], but gracefully handles missing data. + * + * @see CardBulkOrderListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardBulkOrderListPageResponse], but gracefully handles missing data. + * + * @see CardBulkOrderListPageResponse.hasMore + */ + fun hasMore(): Optional = response._hasMore().getOptional("has_more") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() + + fun nextPageParams(): CardBulkOrderListParams = + if (params.endingBefore().isPresent) { + params.toBuilder().endingBefore(items().first()._token().getOptional("token")).build() + } else { + params.toBuilder().startingAfter(items().last()._token().getOptional("token")).build() + } + + override fun nextPage(): CardBulkOrderListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): CardBulkOrderListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardBulkOrderListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardBulkOrderListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardBulkOrderListPage]. */ + class Builder internal constructor() { + + private var service: CardBulkOrderService? = null + private var params: CardBulkOrderListParams? = null + private var response: CardBulkOrderListPageResponse? = null + + @JvmSynthetic + internal fun from(cardBulkOrderListPage: CardBulkOrderListPage) = apply { + service = cardBulkOrderListPage.service + params = cardBulkOrderListPage.params + response = cardBulkOrderListPage.response + } + + fun service(service: CardBulkOrderService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CardBulkOrderListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardBulkOrderListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CardBulkOrderListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardBulkOrderListPage = + CardBulkOrderListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardBulkOrderListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "CardBulkOrderListPage{service=$service, params=$params, response=$response}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPageAsync.kt new file mode 100644 index 000000000..ababdfe3b --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPageAsync.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.AutoPagerAsync +import com.lithic.api.core.PageAsync +import com.lithic.api.core.checkRequired +import com.lithic.api.services.async.CardBulkOrderServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see CardBulkOrderServiceAsync.list */ +class CardBulkOrderListPageAsync +private constructor( + private val service: CardBulkOrderServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: CardBulkOrderListParams, + private val response: CardBulkOrderListPageResponse, +) : PageAsync { + + /** + * Delegates to [CardBulkOrderListPageResponse], but gracefully handles missing data. + * + * @see CardBulkOrderListPageResponse.data + */ + fun data(): List = + response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardBulkOrderListPageResponse], but gracefully handles missing data. + * + * @see CardBulkOrderListPageResponse.hasMore + */ + fun hasMore(): Optional = response._hasMore().getOptional("has_more") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() + + fun nextPageParams(): CardBulkOrderListParams = + if (params.endingBefore().isPresent) { + params.toBuilder().endingBefore(items().first()._token().getOptional("token")).build() + } else { + params.toBuilder().startingAfter(items().last()._token().getOptional("token")).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): CardBulkOrderListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardBulkOrderListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardBulkOrderListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardBulkOrderListPageAsync]. */ + class Builder internal constructor() { + + private var service: CardBulkOrderServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: CardBulkOrderListParams? = null + private var response: CardBulkOrderListPageResponse? = null + + @JvmSynthetic + internal fun from(cardBulkOrderListPageAsync: CardBulkOrderListPageAsync) = apply { + service = cardBulkOrderListPageAsync.service + streamHandlerExecutor = cardBulkOrderListPageAsync.streamHandlerExecutor + params = cardBulkOrderListPageAsync.params + response = cardBulkOrderListPageAsync.response + } + + fun service(service: CardBulkOrderServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: CardBulkOrderListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardBulkOrderListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CardBulkOrderListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardBulkOrderListPageAsync = + CardBulkOrderListPageAsync( + checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardBulkOrderListPageAsync && + service == other.service && + streamHandlerExecutor == other.streamHandlerExecutor && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, streamHandlerExecutor, params, response) + + override fun toString() = + "CardBulkOrderListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPageResponse.kt new file mode 100644 index 000000000..2d10152ee --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListPageResponse.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CardBulkOrderListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val hasMore: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), + ) : this(data, hasMore, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * More data exists. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [hasMore]. + * + * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CardBulkOrderListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .hasMore() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardBulkOrderListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var hasMore: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardBulkOrderListPageResponse: CardBulkOrderListPageResponse) = apply { + data = cardBulkOrderListPageResponse.data.map { it.toMutableList() } + hasMore = cardBulkOrderListPageResponse.hasMore + additionalProperties = cardBulkOrderListPageResponse.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [CardBulkOrder] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: CardBulkOrder) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** More data exists. */ + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + /** + * Sets [Builder.hasMore] to an arbitrary JSON value. + * + * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CardBulkOrderListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .hasMore() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardBulkOrderListPageResponse = + CardBulkOrderListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("hasMore", hasMore), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardBulkOrderListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + hasMore() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasMore.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardBulkOrderListPageResponse && + data == other.data && + hasMore == other.hasMore && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, hasMore, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardBulkOrderListPageResponse{data=$data, hasMore=$hasMore, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListParams.kt new file mode 100644 index 000000000..48db021ea --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderListParams.kt @@ -0,0 +1,298 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.Params +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List bulk orders for physical card shipments **[BETA]** */ +class CardBulkOrderListParams +private constructor( + private val begin: OffsetDateTime?, + private val end: OffsetDateTime?, + private val endingBefore: String?, + private val pageSize: Long?, + private val startingAfter: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Date string in RFC 3339 format. Only entries created after the specified time will be + * included. UTC time zone. + */ + fun begin(): Optional = Optional.ofNullable(begin) + + /** + * Date string in RFC 3339 format. Only entries created before the specified time will be + * included. UTC time zone. + */ + fun end(): Optional = Optional.ofNullable(end) + + /** + * A cursor representing an item's token before which a page of results should end. Used to + * retrieve the previous page of results before this item. + */ + fun endingBefore(): Optional = Optional.ofNullable(endingBefore) + + /** Page size (for pagination). */ + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + /** + * A cursor representing an item's token after which a page of results should begin. Used to + * retrieve the next page of results after this item. + */ + fun startingAfter(): Optional = Optional.ofNullable(startingAfter) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardBulkOrderListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CardBulkOrderListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardBulkOrderListParams]. */ + class Builder internal constructor() { + + private var begin: OffsetDateTime? = null + private var end: OffsetDateTime? = null + private var endingBefore: String? = null + private var pageSize: Long? = null + private var startingAfter: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardBulkOrderListParams: CardBulkOrderListParams) = apply { + begin = cardBulkOrderListParams.begin + end = cardBulkOrderListParams.end + endingBefore = cardBulkOrderListParams.endingBefore + pageSize = cardBulkOrderListParams.pageSize + startingAfter = cardBulkOrderListParams.startingAfter + additionalHeaders = cardBulkOrderListParams.additionalHeaders.toBuilder() + additionalQueryParams = cardBulkOrderListParams.additionalQueryParams.toBuilder() + } + + /** + * Date string in RFC 3339 format. Only entries created after the specified time will be + * included. UTC time zone. + */ + fun begin(begin: OffsetDateTime?) = apply { this.begin = begin } + + /** Alias for calling [Builder.begin] with `begin.orElse(null)`. */ + fun begin(begin: Optional) = begin(begin.getOrNull()) + + /** + * Date string in RFC 3339 format. Only entries created before the specified time will be + * included. UTC time zone. + */ + fun end(end: OffsetDateTime?) = apply { this.end = end } + + /** Alias for calling [Builder.end] with `end.orElse(null)`. */ + fun end(end: Optional) = end(end.getOrNull()) + + /** + * A cursor representing an item's token before which a page of results should end. Used to + * retrieve the previous page of results before this item. + */ + fun endingBefore(endingBefore: String?) = apply { this.endingBefore = endingBefore } + + /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ + fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) + + /** Page size (for pagination). */ + fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } + + /** + * Alias for [Builder.pageSize]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageSize(pageSize: Long) = pageSize(pageSize as Long?) + + /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ + fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + + /** + * A cursor representing an item's token after which a page of results should begin. Used to + * retrieve the next page of results after this item. + */ + fun startingAfter(startingAfter: String?) = apply { this.startingAfter = startingAfter } + + /** Alias for calling [Builder.startingAfter] with `startingAfter.orElse(null)`. */ + fun startingAfter(startingAfter: Optional) = + startingAfter(startingAfter.getOrNull()) + + 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 [CardBulkOrderListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardBulkOrderListParams = + CardBulkOrderListParams( + begin, + end, + endingBefore, + pageSize, + startingAfter, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + begin?.let { put("begin", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + end?.let { put("end", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } + endingBefore?.let { put("ending_before", it) } + pageSize?.let { put("page_size", it.toString()) } + startingAfter?.let { put("starting_after", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardBulkOrderListParams && + begin == other.begin && + end == other.end && + endingBefore == other.endingBefore && + pageSize == other.pageSize && + startingAfter == other.startingAfter && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + begin, + end, + endingBefore, + pageSize, + startingAfter, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "CardBulkOrderListParams{begin=$begin, end=$end, endingBefore=$endingBefore, pageSize=$pageSize, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderRetrieveParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderRetrieveParams.kt new file mode 100644 index 000000000..554c19d68 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderRetrieveParams.kt @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.Params +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a specific bulk order by token **[BETA]** */ +class CardBulkOrderRetrieveParams +private constructor( + private val bulkOrderToken: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun bulkOrderToken(): Optional = Optional.ofNullable(bulkOrderToken) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardBulkOrderRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CardBulkOrderRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardBulkOrderRetrieveParams]. */ + class Builder internal constructor() { + + private var bulkOrderToken: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardBulkOrderRetrieveParams: CardBulkOrderRetrieveParams) = apply { + bulkOrderToken = cardBulkOrderRetrieveParams.bulkOrderToken + additionalHeaders = cardBulkOrderRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = cardBulkOrderRetrieveParams.additionalQueryParams.toBuilder() + } + + fun bulkOrderToken(bulkOrderToken: String?) = apply { this.bulkOrderToken = bulkOrderToken } + + /** Alias for calling [Builder.bulkOrderToken] with `bulkOrderToken.orElse(null)`. */ + fun bulkOrderToken(bulkOrderToken: Optional) = + bulkOrderToken(bulkOrderToken.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardBulkOrderRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardBulkOrderRetrieveParams = + CardBulkOrderRetrieveParams( + bulkOrderToken, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> bulkOrderToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardBulkOrderRetrieveParams && + bulkOrderToken == other.bulkOrderToken && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(bulkOrderToken, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardBulkOrderRetrieveParams{bulkOrderToken=$bulkOrderToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderUpdateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderUpdateParams.kt new file mode 100644 index 000000000..c495aa146 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardBulkOrderUpdateParams.kt @@ -0,0 +1,565 @@ +// 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 + +/** + * Update a bulk order **[BETA]**. Primarily used to lock the order, preventing additional cards + * from being added + */ +class CardBulkOrderUpdateParams +private constructor( + private val bulkOrderToken: String?, + private val body: UpdateBulkOrderRequest, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun bulkOrderToken(): Optional = Optional.ofNullable(bulkOrderToken) + + /** + * Status to update the bulk order to. Use LOCKED to finalize the order + * + * @throws LithicInvalidDataException if 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 = body.status() + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _status(): JsonField = body._status() + + 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 [CardBulkOrderUpdateParams]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardBulkOrderUpdateParams]. */ + class Builder internal constructor() { + + private var bulkOrderToken: String? = null + private var body: UpdateBulkOrderRequest.Builder = UpdateBulkOrderRequest.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardBulkOrderUpdateParams: CardBulkOrderUpdateParams) = apply { + bulkOrderToken = cardBulkOrderUpdateParams.bulkOrderToken + body = cardBulkOrderUpdateParams.body.toBuilder() + additionalHeaders = cardBulkOrderUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = cardBulkOrderUpdateParams.additionalQueryParams.toBuilder() + } + + fun bulkOrderToken(bulkOrderToken: String?) = apply { this.bulkOrderToken = bulkOrderToken } + + /** Alias for calling [Builder.bulkOrderToken] with `bulkOrderToken.orElse(null)`. */ + fun bulkOrderToken(bulkOrderToken: Optional) = + bulkOrderToken(bulkOrderToken.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: + * - [status] + */ + fun body(body: UpdateBulkOrderRequest) = apply { this.body = body.toBuilder() } + + /** Status to update the bulk order to. Use LOCKED to finalize the order */ + fun status(status: Status) = apply { body.status(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 { body.status(status) } + + 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 [CardBulkOrderUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardBulkOrderUpdateParams = + CardBulkOrderUpdateParams( + bulkOrderToken, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): UpdateBulkOrderRequest = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> bulkOrderToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + /** Request to update a bulk order, primarily to lock it */ + class UpdateBulkOrderRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() + ) : this(status, mutableMapOf()) + + /** + * Status to update the bulk order to. Use LOCKED to finalize the order + * + * @throws LithicInvalidDataException if 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") + + /** + * 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 + + @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 [UpdateBulkOrderRequest]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateBulkOrderRequest]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateBulkOrderRequest: UpdateBulkOrderRequest) = apply { + status = updateBulkOrderRequest.status + additionalProperties = updateBulkOrderRequest.additionalProperties.toMutableMap() + } + + /** Status to update the bulk order to. Use LOCKED to finalize the order */ + 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 } + + 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 [UpdateBulkOrderRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UpdateBulkOrderRequest = + UpdateBulkOrderRequest( + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UpdateBulkOrderRequest = apply { + if (validated) { + return@apply + } + + status().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 = (status.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateBulkOrderRequest && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateBulkOrderRequest{status=$status, additionalProperties=$additionalProperties}" + } + + /** Status to update the bulk order to. Use LOCKED to finalize the order */ + 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 LOCKED = of("LOCKED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + LOCKED + } + + /** + * 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 { + LOCKED, + /** 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) { + LOCKED -> Value.LOCKED + 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) { + LOCKED -> Known.LOCKED + else -> throw LithicInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return 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 CardBulkOrderUpdateParams && + bulkOrderToken == other.bulkOrderToken && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(bulkOrderToken, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardBulkOrderUpdateParams{bulkOrderToken=$bulkOrderToken, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardConvertPhysicalParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardConvertPhysicalParams.kt index 7fdf2d1e6..a593b9c26 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardConvertPhysicalParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardConvertPhysicalParams.kt @@ -78,6 +78,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or similar * international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -223,6 +224,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ fun shippingMethod(shippingMethod: ShippingMethod) = apply { body.shippingMethod(shippingMethod) @@ -451,6 +453,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -591,6 +594,7 @@ private constructor( * tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ fun shippingMethod(shippingMethod: ShippingMethod) = shippingMethod(JsonField.of(shippingMethod)) @@ -716,6 +720,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or similar * international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ class ShippingMethod @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -734,6 +739,8 @@ private constructor( @JvmField val _2_DAY = of("2_DAY") + @JvmField val BULK_EXPEDITED = of("BULK_EXPEDITED") + @JvmField val EXPEDITED = of("EXPEDITED") @JvmField val EXPRESS = of("EXPRESS") @@ -750,6 +757,7 @@ private constructor( /** An enum containing [ShippingMethod]'s known values. */ enum class Known { _2_DAY, + BULK_EXPEDITED, EXPEDITED, EXPRESS, PRIORITY, @@ -768,6 +776,7 @@ private constructor( */ enum class Value { _2_DAY, + BULK_EXPEDITED, EXPEDITED, EXPRESS, PRIORITY, @@ -790,6 +799,7 @@ private constructor( fun value(): Value = when (this) { _2_DAY -> Value._2_DAY + BULK_EXPEDITED -> Value.BULK_EXPEDITED EXPEDITED -> Value.EXPEDITED EXPRESS -> Value.EXPRESS PRIORITY -> Value.PRIORITY @@ -810,6 +820,7 @@ private constructor( fun known(): Known = when (this) { _2_DAY -> Known._2_DAY + BULK_EXPEDITED -> Known.BULK_EXPEDITED EXPEDITED -> Known.EXPEDITED EXPRESS -> Known.EXPRESS PRIORITY -> Known.PRIORITY diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt index 81ccfcf09..dfb0bfaa2 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreateParams.kt @@ -62,6 +62,16 @@ private constructor( */ fun accountToken(): Optional = body.accountToken() + /** + * Globally unique identifier for an existing bulk order to associate this card with. When + * specified, the card will be added to the bulk order for batch shipment. Only applicable to + * cards of type PHYSICAL + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bulkOrderToken(): Optional = body.bulkOrderToken() + /** * For card programs with more than one BIN range. This must be configured with Lithic before * use. Identifies the card program/BIN range under which to create the card. If omitted, will @@ -211,6 +221,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or similar * international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -268,6 +279,13 @@ private constructor( */ fun _accountToken(): JsonField = body._accountToken() + /** + * Returns the raw JSON value of [bulkOrderToken]. + * + * Unlike [bulkOrderToken], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _bulkOrderToken(): JsonField = body._bulkOrderToken() + /** * Returns the raw JSON value of [cardProgramToken]. * @@ -437,9 +455,9 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [type] * - [accountToken] + * - [bulkOrderToken] * - [cardProgramToken] * - [carrier] - * - [digitalCardArtToken] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -488,6 +506,24 @@ private constructor( body.accountToken(accountToken) } + /** + * Globally unique identifier for an existing bulk order to associate this card with. When + * specified, the card will be added to the bulk order for batch shipment. Only applicable + * to cards of type PHYSICAL + */ + fun bulkOrderToken(bulkOrderToken: String) = apply { body.bulkOrderToken(bulkOrderToken) } + + /** + * Sets [Builder.bulkOrderToken] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkOrderToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bulkOrderToken(bulkOrderToken: JsonField) = apply { + body.bulkOrderToken(bulkOrderToken) + } + /** * For card programs with more than one BIN range. This must be configured with Lithic * before use. Identifies the card program/BIN range under which to create the card. If @@ -732,6 +768,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ fun shippingMethod(shippingMethod: ShippingMethod) = apply { body.shippingMethod(shippingMethod) @@ -951,6 +988,7 @@ private constructor( private constructor( private val type: JsonField, private val accountToken: JsonField, + private val bulkOrderToken: JsonField, private val cardProgramToken: JsonField, private val carrier: JsonField, private val digitalCardArtToken: JsonField, @@ -977,6 +1015,9 @@ private constructor( @JsonProperty("account_token") @ExcludeMissing accountToken: JsonField = JsonMissing.of(), + @JsonProperty("bulk_order_token") + @ExcludeMissing + bulkOrderToken: JsonField = JsonMissing.of(), @JsonProperty("card_program_token") @ExcludeMissing cardProgramToken: JsonField = JsonMissing.of(), @@ -1021,6 +1062,7 @@ private constructor( ) : this( type, accountToken, + bulkOrderToken, cardProgramToken, carrier, digitalCardArtToken, @@ -1072,6 +1114,16 @@ private constructor( */ fun accountToken(): Optional = accountToken.getOptional("account_token") + /** + * Globally unique identifier for an existing bulk order to associate this card with. When + * specified, the card will be added to the bulk order for batch shipment. Only applicable + * to cards of type PHYSICAL + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bulkOrderToken(): Optional = bulkOrderToken.getOptional("bulk_order_token") + /** * For card programs with more than one BIN range. This must be configured with Lithic * before use. Identifies the card program/BIN range under which to create the card. If @@ -1229,6 +1281,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1293,6 +1346,16 @@ private constructor( @ExcludeMissing fun _accountToken(): JsonField = accountToken + /** + * Returns the raw JSON value of [bulkOrderToken]. + * + * Unlike [bulkOrderToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("bulk_order_token") + @ExcludeMissing + fun _bulkOrderToken(): JsonField = bulkOrderToken + /** * Returns the raw JSON value of [cardProgramToken]. * @@ -1469,6 +1532,7 @@ private constructor( private var type: JsonField? = null private var accountToken: JsonField = JsonMissing.of() + private var bulkOrderToken: JsonField = JsonMissing.of() private var cardProgramToken: JsonField = JsonMissing.of() private var carrier: JsonField = JsonMissing.of() private var digitalCardArtToken: JsonField = JsonMissing.of() @@ -1492,6 +1556,7 @@ private constructor( internal fun from(body: Body) = apply { type = body.type accountToken = body.accountToken + bulkOrderToken = body.bulkOrderToken cardProgramToken = body.cardProgramToken carrier = body.carrier digitalCardArtToken = body.digitalCardArtToken @@ -1558,6 +1623,25 @@ private constructor( this.accountToken = accountToken } + /** + * Globally unique identifier for an existing bulk order to associate this card with. + * When specified, the card will be added to the bulk order for batch shipment. Only + * applicable to cards of type PHYSICAL + */ + fun bulkOrderToken(bulkOrderToken: String) = + bulkOrderToken(JsonField.of(bulkOrderToken)) + + /** + * Sets [Builder.bulkOrderToken] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkOrderToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bulkOrderToken(bulkOrderToken: JsonField) = apply { + this.bulkOrderToken = bulkOrderToken + } + /** * For card programs with more than one BIN range. This must be configured with Lithic * before use. Identifies the card program/BIN range under which to create the card. If @@ -1809,6 +1893,7 @@ private constructor( * tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ fun shippingMethod(shippingMethod: ShippingMethod) = shippingMethod(JsonField.of(shippingMethod)) @@ -1921,6 +2006,7 @@ private constructor( Body( checkRequired("type", type), accountToken, + bulkOrderToken, cardProgramToken, carrier, digitalCardArtToken, @@ -1951,6 +2037,7 @@ private constructor( type().validate() accountToken() + bulkOrderToken() cardProgramToken() carrier().ifPresent { it.validate() } digitalCardArtToken() @@ -1989,6 +2076,7 @@ private constructor( internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (bulkOrderToken.asKnown().isPresent) 1 else 0) + (if (cardProgramToken.asKnown().isPresent) 1 else 0) + (carrier.asKnown().getOrNull()?.validity() ?: 0) + (if (digitalCardArtToken.asKnown().isPresent) 1 else 0) + @@ -2015,6 +2103,7 @@ private constructor( return other is Body && type == other.type && accountToken == other.accountToken && + bulkOrderToken == other.bulkOrderToken && cardProgramToken == other.cardProgramToken && carrier == other.carrier && digitalCardArtToken == other.digitalCardArtToken && @@ -2039,6 +2128,7 @@ private constructor( Objects.hash( type, accountToken, + bulkOrderToken, cardProgramToken, carrier, digitalCardArtToken, @@ -2063,7 +2153,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{type=$type, accountToken=$accountToken, cardProgramToken=$cardProgramToken, carrier=$carrier, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, memo=$memo, pin=$pin, productId=$productId, replacementAccountToken=$replacementAccountToken, replacementComment=$replacementComment, replacementFor=$replacementFor, replacementSubstatus=$replacementSubstatus, shippingAddress=$shippingAddress, shippingMethod=$shippingMethod, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, additionalProperties=$additionalProperties}" + "Body{type=$type, accountToken=$accountToken, bulkOrderToken=$bulkOrderToken, cardProgramToken=$cardProgramToken, carrier=$carrier, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, memo=$memo, pin=$pin, productId=$productId, replacementAccountToken=$replacementAccountToken, replacementComment=$replacementComment, replacementFor=$replacementFor, replacementSubstatus=$replacementSubstatus, shippingAddress=$shippingAddress, shippingMethod=$shippingMethod, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, additionalProperties=$additionalProperties}" } /** @@ -2448,6 +2538,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or similar * international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ class ShippingMethod @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2466,6 +2557,8 @@ private constructor( @JvmField val _2_DAY = of("2_DAY") + @JvmField val BULK_EXPEDITED = of("BULK_EXPEDITED") + @JvmField val EXPEDITED = of("EXPEDITED") @JvmField val EXPRESS = of("EXPRESS") @@ -2482,6 +2575,7 @@ private constructor( /** An enum containing [ShippingMethod]'s known values. */ enum class Known { _2_DAY, + BULK_EXPEDITED, EXPEDITED, EXPRESS, PRIORITY, @@ -2500,6 +2594,7 @@ private constructor( */ enum class Value { _2_DAY, + BULK_EXPEDITED, EXPEDITED, EXPRESS, PRIORITY, @@ -2522,6 +2617,7 @@ private constructor( fun value(): Value = when (this) { _2_DAY -> Value._2_DAY + BULK_EXPEDITED -> Value.BULK_EXPEDITED EXPEDITED -> Value.EXPEDITED EXPRESS -> Value.EXPRESS PRIORITY -> Value.PRIORITY @@ -2542,6 +2638,7 @@ private constructor( fun known(): Known = when (this) { _2_DAY -> Known._2_DAY + BULK_EXPEDITED -> Known.BULK_EXPEDITED EXPEDITED -> Known.EXPEDITED EXPRESS -> Known.EXPRESS PRIORITY -> Known.PRIORITY diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardReissueParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardReissueParams.kt index f11b1b47a..9bdc4068e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardReissueParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardReissueParams.kt @@ -73,6 +73,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or similar * international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -213,6 +214,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ fun shippingMethod(shippingMethod: ShippingMethod) = apply { body.shippingMethod(shippingMethod) @@ -435,6 +437,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -568,6 +571,7 @@ private constructor( * tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ fun shippingMethod(shippingMethod: ShippingMethod) = shippingMethod(JsonField.of(shippingMethod)) @@ -686,6 +690,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or similar * international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ class ShippingMethod @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -704,6 +709,8 @@ private constructor( @JvmField val _2_DAY = of("2_DAY") + @JvmField val BULK_EXPEDITED = of("BULK_EXPEDITED") + @JvmField val EXPEDITED = of("EXPEDITED") @JvmField val EXPRESS = of("EXPRESS") @@ -720,6 +727,7 @@ private constructor( /** An enum containing [ShippingMethod]'s known values. */ enum class Known { _2_DAY, + BULK_EXPEDITED, EXPEDITED, EXPRESS, PRIORITY, @@ -738,6 +746,7 @@ private constructor( */ enum class Value { _2_DAY, + BULK_EXPEDITED, EXPEDITED, EXPRESS, PRIORITY, @@ -760,6 +769,7 @@ private constructor( fun value(): Value = when (this) { _2_DAY -> Value._2_DAY + BULK_EXPEDITED -> Value.BULK_EXPEDITED EXPEDITED -> Value.EXPEDITED EXPRESS -> Value.EXPRESS PRIORITY -> Value.PRIORITY @@ -780,6 +790,7 @@ private constructor( fun known(): Known = when (this) { _2_DAY -> Known._2_DAY + BULK_EXPEDITED -> Known.BULK_EXPEDITED EXPEDITED -> Known.EXPEDITED EXPRESS -> Known.EXPRESS PRIORITY -> Known.PRIORITY diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardRenewParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardRenewParams.kt index 74602deb2..cffea8f5a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardRenewParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardRenewParams.kt @@ -95,6 +95,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or similar * international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -284,6 +285,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ fun shippingMethod(shippingMethod: ShippingMethod) = apply { body.shippingMethod(shippingMethod) @@ -544,6 +546,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -732,6 +735,7 @@ private constructor( * tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or * similar international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ fun shippingMethod(shippingMethod: ShippingMethod) = shippingMethod(JsonField.of(shippingMethod)) @@ -873,6 +877,7 @@ private constructor( * * `2_DAY` - FedEx or UPS depending on card manufacturer, 2-day shipping, with tracking * * `EXPEDITED` - FedEx or UPS depending on card manufacturer, Standard Overnight or similar * international option, with tracking + * * `BULK_EXPEDITED` - Bulk shipment with Expedited shipping */ class ShippingMethod @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -891,6 +896,8 @@ private constructor( @JvmField val _2_DAY = of("2_DAY") + @JvmField val BULK_EXPEDITED = of("BULK_EXPEDITED") + @JvmField val EXPEDITED = of("EXPEDITED") @JvmField val EXPRESS = of("EXPRESS") @@ -907,6 +914,7 @@ private constructor( /** An enum containing [ShippingMethod]'s known values. */ enum class Known { _2_DAY, + BULK_EXPEDITED, EXPEDITED, EXPRESS, PRIORITY, @@ -925,6 +933,7 @@ private constructor( */ enum class Value { _2_DAY, + BULK_EXPEDITED, EXPEDITED, EXPRESS, PRIORITY, @@ -947,6 +956,7 @@ private constructor( fun value(): Value = when (this) { _2_DAY -> Value._2_DAY + BULK_EXPEDITED -> Value.BULK_EXPEDITED EXPEDITED -> Value.EXPEDITED EXPRESS -> Value.EXPRESS PRIORITY -> Value.PRIORITY @@ -967,6 +977,7 @@ private constructor( fun known(): Known = when (this) { _2_DAY -> Known._2_DAY + BULK_EXPEDITED -> Known.BULK_EXPEDITED EXPEDITED -> Known.EXPEDITED EXPRESS -> Known.EXPRESS PRIORITY -> Known.PRIORITY diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardholderAuthentication.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardholderAuthentication.kt new file mode 100644 index 000000000..a36a944e3 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardholderAuthentication.kt @@ -0,0 +1,996 @@ +// 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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CardholderAuthentication +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val authenticationMethod: JsonField, + private val authenticationResult: JsonField, + private val decisionMadeBy: JsonField, + private val liabilityShift: JsonField, + private val threeDSAuthenticationToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("authentication_method") + @ExcludeMissing + authenticationMethod: JsonField = JsonMissing.of(), + @JsonProperty("authentication_result") + @ExcludeMissing + authenticationResult: JsonField = JsonMissing.of(), + @JsonProperty("decision_made_by") + @ExcludeMissing + decisionMadeBy: JsonField = JsonMissing.of(), + @JsonProperty("liability_shift") + @ExcludeMissing + liabilityShift: JsonField = JsonMissing.of(), + @JsonProperty("three_ds_authentication_token") + @ExcludeMissing + threeDSAuthenticationToken: JsonField = JsonMissing.of(), + ) : this( + authenticationMethod, + authenticationResult, + decisionMadeBy, + liabilityShift, + threeDSAuthenticationToken, + mutableMapOf(), + ) + + /** + * Indicates the method used to authenticate 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). + */ + fun authenticationMethod(): AuthenticationMethod = + authenticationMethod.getRequired("authentication_method") + + /** + * Indicates the outcome of the 3DS authentication process. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun authenticationResult(): AuthenticationResult = + authenticationResult.getRequired("authentication_result") + + /** + * Indicates which party made the 3DS authentication decision. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun decisionMadeBy(): DecisionMadeBy = decisionMadeBy.getRequired("decision_made_by") + + /** + * Indicates whether chargeback liability shift applies to the transaction. Possible enum + * values: + * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, + * chargeback liability shift applies. + * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is + * liable. + * * `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated cryptography, + * possibly recurring. Chargeback liability shift to the issuer applies. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun liabilityShift(): LiabilityShift = liabilityShift.getRequired("liability_shift") + + /** + * Unique identifier you can use to match a given 3DS authentication (available via the + * three_ds_authentication.created event webhook) and the transaction. Note that in cases where + * liability shift does not occur, this token is matched to the transaction on a best-effort + * basis. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun threeDSAuthenticationToken(): Optional = + threeDSAuthenticationToken.getOptional("three_ds_authentication_token") + + /** + * Returns the raw JSON value of [authenticationMethod]. + * + * Unlike [authenticationMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_method") + @ExcludeMissing + fun _authenticationMethod(): JsonField = authenticationMethod + + /** + * Returns the raw JSON value of [authenticationResult]. + * + * Unlike [authenticationResult], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_result") + @ExcludeMissing + fun _authenticationResult(): JsonField = authenticationResult + + /** + * Returns the raw JSON value of [decisionMadeBy]. + * + * Unlike [decisionMadeBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("decision_made_by") + @ExcludeMissing + fun _decisionMadeBy(): JsonField = decisionMadeBy + + /** + * Returns the raw JSON value of [liabilityShift]. + * + * Unlike [liabilityShift], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("liability_shift") + @ExcludeMissing + fun _liabilityShift(): JsonField = liabilityShift + + /** + * Returns the raw JSON value of [threeDSAuthenticationToken]. + * + * Unlike [threeDSAuthenticationToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("three_ds_authentication_token") + @ExcludeMissing + fun _threeDSAuthenticationToken(): JsonField = threeDSAuthenticationToken + + @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 [CardholderAuthentication]. + * + * The following fields are required: + * ```java + * .authenticationMethod() + * .authenticationResult() + * .decisionMadeBy() + * .liabilityShift() + * .threeDSAuthenticationToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderAuthentication]. */ + class Builder internal constructor() { + + private var authenticationMethod: JsonField? = null + private var authenticationResult: JsonField? = null + private var decisionMadeBy: JsonField? = null + private var liabilityShift: JsonField? = null + private var threeDSAuthenticationToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderAuthentication: CardholderAuthentication) = apply { + authenticationMethod = cardholderAuthentication.authenticationMethod + authenticationResult = cardholderAuthentication.authenticationResult + decisionMadeBy = cardholderAuthentication.decisionMadeBy + liabilityShift = cardholderAuthentication.liabilityShift + threeDSAuthenticationToken = cardholderAuthentication.threeDSAuthenticationToken + additionalProperties = cardholderAuthentication.additionalProperties.toMutableMap() + } + + /** Indicates the method used to authenticate the cardholder. */ + fun authenticationMethod(authenticationMethod: AuthenticationMethod) = + authenticationMethod(JsonField.of(authenticationMethod)) + + /** + * Sets [Builder.authenticationMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationMethod] with a well-typed + * [AuthenticationMethod] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authenticationMethod(authenticationMethod: JsonField) = apply { + this.authenticationMethod = authenticationMethod + } + + /** Indicates the outcome of the 3DS authentication process. */ + fun authenticationResult(authenticationResult: AuthenticationResult) = + authenticationResult(JsonField.of(authenticationResult)) + + /** + * Sets [Builder.authenticationResult] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationResult] with a well-typed + * [AuthenticationResult] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authenticationResult(authenticationResult: JsonField) = apply { + this.authenticationResult = authenticationResult + } + + /** Indicates which party made the 3DS authentication decision. */ + fun decisionMadeBy(decisionMadeBy: DecisionMadeBy) = + decisionMadeBy(JsonField.of(decisionMadeBy)) + + /** + * Sets [Builder.decisionMadeBy] to an arbitrary JSON value. + * + * You should usually call [Builder.decisionMadeBy] with a well-typed [DecisionMadeBy] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun decisionMadeBy(decisionMadeBy: JsonField) = apply { + this.decisionMadeBy = decisionMadeBy + } + + /** + * Indicates whether chargeback liability shift applies to the transaction. Possible enum + * values: + * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, + * chargeback liability shift applies. + * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is + * liable. + * * `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated + * cryptography, possibly recurring. Chargeback liability shift to the issuer applies. + */ + fun liabilityShift(liabilityShift: LiabilityShift) = + liabilityShift(JsonField.of(liabilityShift)) + + /** + * Sets [Builder.liabilityShift] to an arbitrary JSON value. + * + * You should usually call [Builder.liabilityShift] with a well-typed [LiabilityShift] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun liabilityShift(liabilityShift: JsonField) = apply { + this.liabilityShift = liabilityShift + } + + /** + * Unique identifier you can use to match a given 3DS authentication (available via the + * three_ds_authentication.created event webhook) and the transaction. Note that in cases + * where liability shift does not occur, this token is matched to the transaction on a + * best-effort basis. + */ + fun threeDSAuthenticationToken(threeDSAuthenticationToken: String?) = + threeDSAuthenticationToken(JsonField.ofNullable(threeDSAuthenticationToken)) + + /** + * Alias for calling [Builder.threeDSAuthenticationToken] with + * `threeDSAuthenticationToken.orElse(null)`. + */ + fun threeDSAuthenticationToken(threeDSAuthenticationToken: Optional) = + threeDSAuthenticationToken(threeDSAuthenticationToken.getOrNull()) + + /** + * Sets [Builder.threeDSAuthenticationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.threeDSAuthenticationToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun threeDSAuthenticationToken(threeDSAuthenticationToken: JsonField) = apply { + this.threeDSAuthenticationToken = threeDSAuthenticationToken + } + + 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 [CardholderAuthentication]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .authenticationMethod() + * .authenticationResult() + * .decisionMadeBy() + * .liabilityShift() + * .threeDSAuthenticationToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderAuthentication = + CardholderAuthentication( + checkRequired("authenticationMethod", authenticationMethod), + checkRequired("authenticationResult", authenticationResult), + checkRequired("decisionMadeBy", decisionMadeBy), + checkRequired("liabilityShift", liabilityShift), + checkRequired("threeDSAuthenticationToken", threeDSAuthenticationToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderAuthentication = apply { + if (validated) { + return@apply + } + + authenticationMethod().validate() + authenticationResult().validate() + decisionMadeBy().validate() + liabilityShift().validate() + threeDSAuthenticationToken() + 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 = + (authenticationMethod.asKnown().getOrNull()?.validity() ?: 0) + + (authenticationResult.asKnown().getOrNull()?.validity() ?: 0) + + (decisionMadeBy.asKnown().getOrNull()?.validity() ?: 0) + + (liabilityShift.asKnown().getOrNull()?.validity() ?: 0) + + (if (threeDSAuthenticationToken.asKnown().isPresent) 1 else 0) + + /** Indicates the method used to authenticate the cardholder. */ + class AuthenticationMethod + @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 FRICTIONLESS = of("FRICTIONLESS") + + @JvmField val CHALLENGE = of("CHALLENGE") + + @JvmField val NONE = of("NONE") + + @JvmStatic fun of(value: String) = AuthenticationMethod(JsonField.of(value)) + } + + /** An enum containing [AuthenticationMethod]'s known values. */ + enum class Known { + FRICTIONLESS, + CHALLENGE, + NONE, + } + + /** + * An enum containing [AuthenticationMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AuthenticationMethod] 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 { + FRICTIONLESS, + CHALLENGE, + NONE, + /** + * An enum member indicating that [AuthenticationMethod] 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) { + FRICTIONLESS -> Value.FRICTIONLESS + CHALLENGE -> Value.CHALLENGE + NONE -> Value.NONE + 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) { + FRICTIONLESS -> Known.FRICTIONLESS + CHALLENGE -> Known.CHALLENGE + NONE -> Known.NONE + else -> throw LithicInvalidDataException("Unknown AuthenticationMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): AuthenticationMethod = 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 AuthenticationMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Indicates the outcome of the 3DS authentication process. */ + class AuthenticationResult + @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 ATTEMPTS = of("ATTEMPTS") + + @JvmField val DECLINE = of("DECLINE") + + @JvmField val NONE = of("NONE") + + @JvmField val SUCCESS = of("SUCCESS") + + @JvmStatic fun of(value: String) = AuthenticationResult(JsonField.of(value)) + } + + /** An enum containing [AuthenticationResult]'s known values. */ + enum class Known { + ATTEMPTS, + DECLINE, + NONE, + SUCCESS, + } + + /** + * An enum containing [AuthenticationResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AuthenticationResult] 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 { + ATTEMPTS, + DECLINE, + NONE, + SUCCESS, + /** + * An enum member indicating that [AuthenticationResult] 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) { + ATTEMPTS -> Value.ATTEMPTS + DECLINE -> Value.DECLINE + NONE -> Value.NONE + SUCCESS -> Value.SUCCESS + 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) { + ATTEMPTS -> Known.ATTEMPTS + DECLINE -> Known.DECLINE + NONE -> Known.NONE + SUCCESS -> Known.SUCCESS + else -> throw LithicInvalidDataException("Unknown AuthenticationResult: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): AuthenticationResult = 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 AuthenticationResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Indicates which party made the 3DS authentication decision. */ + class DecisionMadeBy @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 CUSTOMER_RULES = of("CUSTOMER_RULES") + + @JvmField val CUSTOMER_ENDPOINT = of("CUSTOMER_ENDPOINT") + + @JvmField val LITHIC_DEFAULT = of("LITHIC_DEFAULT") + + @JvmField val LITHIC_RULES = of("LITHIC_RULES") + + @JvmField val NETWORK = of("NETWORK") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = DecisionMadeBy(JsonField.of(value)) + } + + /** An enum containing [DecisionMadeBy]'s known values. */ + enum class Known { + CUSTOMER_RULES, + CUSTOMER_ENDPOINT, + LITHIC_DEFAULT, + LITHIC_RULES, + NETWORK, + UNKNOWN, + } + + /** + * An enum containing [DecisionMadeBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DecisionMadeBy] 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 { + CUSTOMER_RULES, + CUSTOMER_ENDPOINT, + LITHIC_DEFAULT, + LITHIC_RULES, + NETWORK, + UNKNOWN, + /** + * An enum member indicating that [DecisionMadeBy] 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) { + CUSTOMER_RULES -> Value.CUSTOMER_RULES + CUSTOMER_ENDPOINT -> Value.CUSTOMER_ENDPOINT + LITHIC_DEFAULT -> Value.LITHIC_DEFAULT + LITHIC_RULES -> Value.LITHIC_RULES + NETWORK -> Value.NETWORK + 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) { + CUSTOMER_RULES -> Known.CUSTOMER_RULES + CUSTOMER_ENDPOINT -> Known.CUSTOMER_ENDPOINT + LITHIC_DEFAULT -> Known.LITHIC_DEFAULT + LITHIC_RULES -> Known.LITHIC_RULES + NETWORK -> Known.NETWORK + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown DecisionMadeBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): DecisionMadeBy = 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 DecisionMadeBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Indicates whether chargeback liability shift applies to the transaction. Possible enum + * values: + * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, + * chargeback liability shift applies. + * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is + * liable. + * * `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated cryptography, + * possibly recurring. Chargeback liability shift to the issuer applies. + */ + class LiabilityShift @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 _3DS_AUTHENTICATED = of("3DS_AUTHENTICATED") + + @JvmField val TOKEN_AUTHENTICATED = of("TOKEN_AUTHENTICATED") + + @JvmField val NONE = of("NONE") + + @JvmStatic fun of(value: String) = LiabilityShift(JsonField.of(value)) + } + + /** An enum containing [LiabilityShift]'s known values. */ + enum class Known { + _3DS_AUTHENTICATED, + TOKEN_AUTHENTICATED, + NONE, + } + + /** + * An enum containing [LiabilityShift]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [LiabilityShift] 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 { + _3DS_AUTHENTICATED, + TOKEN_AUTHENTICATED, + NONE, + /** + * An enum member indicating that [LiabilityShift] 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) { + _3DS_AUTHENTICATED -> Value._3DS_AUTHENTICATED + TOKEN_AUTHENTICATED -> Value.TOKEN_AUTHENTICATED + NONE -> Value.NONE + 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) { + _3DS_AUTHENTICATED -> Known._3DS_AUTHENTICATED + TOKEN_AUTHENTICATED -> Known.TOKEN_AUTHENTICATED + NONE -> Known.NONE + else -> throw LithicInvalidDataException("Unknown LiabilityShift: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): LiabilityShift = 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 LiabilityShift && 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 CardholderAuthentication && + authenticationMethod == other.authenticationMethod && + authenticationResult == other.authenticationResult && + decisionMadeBy == other.decisionMadeBy && + liabilityShift == other.liabilityShift && + threeDSAuthenticationToken == other.threeDSAuthenticationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + authenticationMethod, + authenticationResult, + decisionMadeBy, + liabilityShift, + threeDSAuthenticationToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderAuthentication{authenticationMethod=$authenticationMethod, authenticationResult=$authenticationResult, decisionMadeBy=$decisionMadeBy, liabilityShift=$liabilityShift, threeDSAuthenticationToken=$threeDSAuthenticationToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Device.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Device.kt new file mode 100644 index 000000000..8cd755d75 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Device.kt @@ -0,0 +1,265 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkRequired +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Device +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val imei: JsonField, + private val ipAddress: JsonField, + private val location: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("imei") @ExcludeMissing imei: JsonField = JsonMissing.of(), + @JsonProperty("ip_address") @ExcludeMissing ipAddress: JsonField = JsonMissing.of(), + @JsonProperty("location") @ExcludeMissing location: JsonField = JsonMissing.of(), + ) : this(imei, ipAddress, location, mutableMapOf()) + + /** + * The IMEI number of the device being provisioned. For Amex, this field contains device ID + * instead as IMEI is not provided + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun imei(): Optional = imei.getOptional("imei") + + /** + * The IP address of the device initiating the request + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ipAddress(): Optional = ipAddress.getOptional("ip_address") + + /** + * Latitude and longitude where the device is located during the authorization attempt + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun location(): Optional = location.getOptional("location") + + /** + * Returns the raw JSON value of [imei]. + * + * Unlike [imei], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("imei") @ExcludeMissing fun _imei(): JsonField = imei + + /** + * Returns the raw JSON value of [ipAddress]. + * + * Unlike [ipAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ip_address") @ExcludeMissing fun _ipAddress(): JsonField = ipAddress + + /** + * Returns the raw JSON value of [location]. + * + * Unlike [location], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location + + @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 [Device]. + * + * The following fields are required: + * ```java + * .imei() + * .ipAddress() + * .location() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Device]. */ + class Builder internal constructor() { + + private var imei: JsonField? = null + private var ipAddress: JsonField? = null + private var location: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(device: Device) = apply { + imei = device.imei + ipAddress = device.ipAddress + location = device.location + additionalProperties = device.additionalProperties.toMutableMap() + } + + /** + * The IMEI number of the device being provisioned. For Amex, this field contains device ID + * instead as IMEI is not provided + */ + fun imei(imei: String?) = imei(JsonField.ofNullable(imei)) + + /** Alias for calling [Builder.imei] with `imei.orElse(null)`. */ + fun imei(imei: Optional) = imei(imei.getOrNull()) + + /** + * Sets [Builder.imei] to an arbitrary JSON value. + * + * You should usually call [Builder.imei] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun imei(imei: JsonField) = apply { this.imei = imei } + + /** The IP address of the device initiating the request */ + fun ipAddress(ipAddress: String?) = ipAddress(JsonField.ofNullable(ipAddress)) + + /** Alias for calling [Builder.ipAddress] with `ipAddress.orElse(null)`. */ + fun ipAddress(ipAddress: Optional) = ipAddress(ipAddress.getOrNull()) + + /** + * Sets [Builder.ipAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.ipAddress] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ipAddress(ipAddress: JsonField) = apply { this.ipAddress = ipAddress } + + /** Latitude and longitude where the device is located during the authorization attempt */ + fun location(location: String?) = location(JsonField.ofNullable(location)) + + /** Alias for calling [Builder.location] with `location.orElse(null)`. */ + fun location(location: Optional) = location(location.getOrNull()) + + /** + * Sets [Builder.location] to an arbitrary JSON value. + * + * You should usually call [Builder.location] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun location(location: JsonField) = apply { this.location = location } + + 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 [Device]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .imei() + * .ipAddress() + * .location() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Device = + Device( + checkRequired("imei", imei), + checkRequired("ipAddress", ipAddress), + checkRequired("location", location), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Device = apply { + if (validated) { + return@apply + } + + imei() + ipAddress() + location() + 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 (imei.asKnown().isPresent) 1 else 0) + + (if (ipAddress.asKnown().isPresent) 1 else 0) + + (if (location.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Device && + imei == other.imei && + ipAddress == other.ipAddress && + location == other.location && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(imei, ipAddress, location, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Device{imei=$imei, ipAddress=$ipAddress, location=$location, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenMetadata.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenMetadata.kt new file mode 100644 index 000000000..4438ef0b5 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenMetadata.kt @@ -0,0 +1,1082 @@ +// 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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Contains the metadata for the digital wallet being tokenized. */ +class DigitalWalletTokenMetadata +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val paymentAccountInfo: JsonField, + private val status: JsonField, + private val paymentAppInstanceId: JsonField, + private val tokenRequestorId: JsonField, + private val tokenRequestorName: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("payment_account_info") + @ExcludeMissing + paymentAccountInfo: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("payment_app_instance_id") + @ExcludeMissing + paymentAppInstanceId: JsonField = JsonMissing.of(), + @JsonProperty("token_requestor_id") + @ExcludeMissing + tokenRequestorId: JsonField = JsonMissing.of(), + @JsonProperty("token_requestor_name") + @ExcludeMissing + tokenRequestorName: JsonField = JsonMissing.of(), + ) : this( + paymentAccountInfo, + status, + paymentAppInstanceId, + tokenRequestorId, + tokenRequestorName, + mutableMapOf(), + ) + + /** + * Contains the information of the account responsible for the payment. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paymentAccountInfo(): PaymentAccountInfo = + paymentAccountInfo.getRequired("payment_account_info") + + /** + * The current status of the digital wallet token. Pending or declined. + * + * @throws LithicInvalidDataException if 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(): String = status.getRequired("status") + + /** + * The identifier of the Payment App instance within a device that will be provisioned with a + * token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentAppInstanceId(): Optional = + paymentAppInstanceId.getOptional("payment_app_instance_id") + + /** + * The party that requested the digitization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenRequestorId(): Optional = tokenRequestorId.getOptional("token_requestor_id") + + /** + * Human-readable name of the wallet that the token_requestor_id maps to. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenRequestorName(): Optional = + tokenRequestorName.getOptional("token_requestor_name") + + /** + * Returns the raw JSON value of [paymentAccountInfo]. + * + * Unlike [paymentAccountInfo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_account_info") + @ExcludeMissing + fun _paymentAccountInfo(): JsonField = paymentAccountInfo + + /** + * 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 [paymentAppInstanceId]. + * + * Unlike [paymentAppInstanceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_app_instance_id") + @ExcludeMissing + fun _paymentAppInstanceId(): JsonField = paymentAppInstanceId + + /** + * Returns the raw JSON value of [tokenRequestorId]. + * + * Unlike [tokenRequestorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("token_requestor_id") + @ExcludeMissing + fun _tokenRequestorId(): JsonField = tokenRequestorId + + /** + * Returns the raw JSON value of [tokenRequestorName]. + * + * Unlike [tokenRequestorName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("token_requestor_name") + @ExcludeMissing + fun _tokenRequestorName(): JsonField = tokenRequestorName + + @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 [DigitalWalletTokenMetadata]. + * + * The following fields are required: + * ```java + * .paymentAccountInfo() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DigitalWalletTokenMetadata]. */ + class Builder internal constructor() { + + private var paymentAccountInfo: JsonField? = null + private var status: JsonField? = null + private var paymentAppInstanceId: JsonField = JsonMissing.of() + private var tokenRequestorId: JsonField = JsonMissing.of() + private var tokenRequestorName: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(digitalWalletTokenMetadata: DigitalWalletTokenMetadata) = apply { + paymentAccountInfo = digitalWalletTokenMetadata.paymentAccountInfo + status = digitalWalletTokenMetadata.status + paymentAppInstanceId = digitalWalletTokenMetadata.paymentAppInstanceId + tokenRequestorId = digitalWalletTokenMetadata.tokenRequestorId + tokenRequestorName = digitalWalletTokenMetadata.tokenRequestorName + additionalProperties = digitalWalletTokenMetadata.additionalProperties.toMutableMap() + } + + /** Contains the information of the account responsible for the payment. */ + fun paymentAccountInfo(paymentAccountInfo: PaymentAccountInfo) = + paymentAccountInfo(JsonField.of(paymentAccountInfo)) + + /** + * Sets [Builder.paymentAccountInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAccountInfo] with a well-typed + * [PaymentAccountInfo] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun paymentAccountInfo(paymentAccountInfo: JsonField) = apply { + this.paymentAccountInfo = paymentAccountInfo + } + + /** The current status of the digital wallet token. Pending or declined. */ + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] 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 identifier of the Payment App instance within a device that will be provisioned with + * a token + */ + fun paymentAppInstanceId(paymentAppInstanceId: String?) = + paymentAppInstanceId(JsonField.ofNullable(paymentAppInstanceId)) + + /** + * Alias for calling [Builder.paymentAppInstanceId] with + * `paymentAppInstanceId.orElse(null)`. + */ + fun paymentAppInstanceId(paymentAppInstanceId: Optional) = + paymentAppInstanceId(paymentAppInstanceId.getOrNull()) + + /** + * Sets [Builder.paymentAppInstanceId] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAppInstanceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentAppInstanceId(paymentAppInstanceId: JsonField) = apply { + this.paymentAppInstanceId = paymentAppInstanceId + } + + /** The party that requested the digitization */ + fun tokenRequestorId(tokenRequestorId: String) = + tokenRequestorId(JsonField.of(tokenRequestorId)) + + /** + * Sets [Builder.tokenRequestorId] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenRequestorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenRequestorId(tokenRequestorId: JsonField) = apply { + this.tokenRequestorId = tokenRequestorId + } + + /** Human-readable name of the wallet that the token_requestor_id maps to. */ + fun tokenRequestorName(tokenRequestorName: TokenRequestorName) = + tokenRequestorName(JsonField.of(tokenRequestorName)) + + /** + * Sets [Builder.tokenRequestorName] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenRequestorName] with a well-typed + * [TokenRequestorName] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenRequestorName(tokenRequestorName: JsonField) = apply { + this.tokenRequestorName = tokenRequestorName + } + + 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 [DigitalWalletTokenMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .paymentAccountInfo() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DigitalWalletTokenMetadata = + DigitalWalletTokenMetadata( + checkRequired("paymentAccountInfo", paymentAccountInfo), + checkRequired("status", status), + paymentAppInstanceId, + tokenRequestorId, + tokenRequestorName, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DigitalWalletTokenMetadata = apply { + if (validated) { + return@apply + } + + paymentAccountInfo().validate() + status() + paymentAppInstanceId() + tokenRequestorId() + tokenRequestorName().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 = + (paymentAccountInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (paymentAppInstanceId.asKnown().isPresent) 1 else 0) + + (if (tokenRequestorId.asKnown().isPresent) 1 else 0) + + (tokenRequestorName.asKnown().getOrNull()?.validity() ?: 0) + + /** Contains the information of the account responsible for the payment. */ + class PaymentAccountInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accountHolderData: JsonField, + private val panUniqueReference: JsonField, + private val paymentAccountReference: JsonField, + private val tokenUniqueReference: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_holder_data") + @ExcludeMissing + accountHolderData: JsonField = JsonMissing.of(), + @JsonProperty("pan_unique_reference") + @ExcludeMissing + panUniqueReference: JsonField = JsonMissing.of(), + @JsonProperty("payment_account_reference") + @ExcludeMissing + paymentAccountReference: JsonField = JsonMissing.of(), + @JsonProperty("token_unique_reference") + @ExcludeMissing + tokenUniqueReference: JsonField = JsonMissing.of(), + ) : this( + accountHolderData, + panUniqueReference, + paymentAccountReference, + tokenUniqueReference, + mutableMapOf(), + ) + + /** + * Additional information that can be used to identify the account holder, such as name, + * address, etc + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountHolderData(): AccountHolderData = + accountHolderData.getRequired("account_holder_data") + + /** + * Reference to the PAN that is unique per Wallet Provider + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun panUniqueReference(): Optional = + panUniqueReference.getOptional("pan_unique_reference") + + /** + * The unique account reference assigned to the PAN + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentAccountReference(): Optional = + paymentAccountReference.getOptional("payment_account_reference") + + /** + * A unique reference assigned following the allocation of a token used to identify the + * token for the duration of its lifetime. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenUniqueReference(): Optional = + tokenUniqueReference.getOptional("token_unique_reference") + + /** + * Returns the raw JSON value of [accountHolderData]. + * + * Unlike [accountHolderData], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_holder_data") + @ExcludeMissing + fun _accountHolderData(): JsonField = accountHolderData + + /** + * Returns the raw JSON value of [panUniqueReference]. + * + * Unlike [panUniqueReference], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pan_unique_reference") + @ExcludeMissing + fun _panUniqueReference(): JsonField = panUniqueReference + + /** + * Returns the raw JSON value of [paymentAccountReference]. + * + * Unlike [paymentAccountReference], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("payment_account_reference") + @ExcludeMissing + fun _paymentAccountReference(): JsonField = paymentAccountReference + + /** + * Returns the raw JSON value of [tokenUniqueReference]. + * + * Unlike [tokenUniqueReference], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("token_unique_reference") + @ExcludeMissing + fun _tokenUniqueReference(): JsonField = tokenUniqueReference + + @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 [PaymentAccountInfo]. + * + * The following fields are required: + * ```java + * .accountHolderData() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentAccountInfo]. */ + class Builder internal constructor() { + + private var accountHolderData: JsonField? = null + private var panUniqueReference: JsonField = JsonMissing.of() + private var paymentAccountReference: JsonField = JsonMissing.of() + private var tokenUniqueReference: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paymentAccountInfo: PaymentAccountInfo) = apply { + accountHolderData = paymentAccountInfo.accountHolderData + panUniqueReference = paymentAccountInfo.panUniqueReference + paymentAccountReference = paymentAccountInfo.paymentAccountReference + tokenUniqueReference = paymentAccountInfo.tokenUniqueReference + additionalProperties = paymentAccountInfo.additionalProperties.toMutableMap() + } + + /** + * Additional information that can be used to identify the account holder, such as name, + * address, etc + */ + fun accountHolderData(accountHolderData: AccountHolderData) = + accountHolderData(JsonField.of(accountHolderData)) + + /** + * Sets [Builder.accountHolderData] to an arbitrary JSON value. + * + * You should usually call [Builder.accountHolderData] with a well-typed + * [AccountHolderData] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun accountHolderData(accountHolderData: JsonField) = apply { + this.accountHolderData = accountHolderData + } + + /** Reference to the PAN that is unique per Wallet Provider */ + fun panUniqueReference(panUniqueReference: String?) = + panUniqueReference(JsonField.ofNullable(panUniqueReference)) + + /** + * Alias for calling [Builder.panUniqueReference] with + * `panUniqueReference.orElse(null)`. + */ + fun panUniqueReference(panUniqueReference: Optional) = + panUniqueReference(panUniqueReference.getOrNull()) + + /** + * Sets [Builder.panUniqueReference] to an arbitrary JSON value. + * + * You should usually call [Builder.panUniqueReference] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun panUniqueReference(panUniqueReference: JsonField) = apply { + this.panUniqueReference = panUniqueReference + } + + /** The unique account reference assigned to the PAN */ + fun paymentAccountReference(paymentAccountReference: String?) = + paymentAccountReference(JsonField.ofNullable(paymentAccountReference)) + + /** + * Alias for calling [Builder.paymentAccountReference] with + * `paymentAccountReference.orElse(null)`. + */ + fun paymentAccountReference(paymentAccountReference: Optional) = + paymentAccountReference(paymentAccountReference.getOrNull()) + + /** + * Sets [Builder.paymentAccountReference] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAccountReference] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun paymentAccountReference(paymentAccountReference: JsonField) = apply { + this.paymentAccountReference = paymentAccountReference + } + + /** + * A unique reference assigned following the allocation of a token used to identify the + * token for the duration of its lifetime. + */ + fun tokenUniqueReference(tokenUniqueReference: String?) = + tokenUniqueReference(JsonField.ofNullable(tokenUniqueReference)) + + /** + * Alias for calling [Builder.tokenUniqueReference] with + * `tokenUniqueReference.orElse(null)`. + */ + fun tokenUniqueReference(tokenUniqueReference: Optional) = + tokenUniqueReference(tokenUniqueReference.getOrNull()) + + /** + * Sets [Builder.tokenUniqueReference] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenUniqueReference] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tokenUniqueReference(tokenUniqueReference: JsonField) = apply { + this.tokenUniqueReference = tokenUniqueReference + } + + 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 [PaymentAccountInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountHolderData() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentAccountInfo = + PaymentAccountInfo( + checkRequired("accountHolderData", accountHolderData), + panUniqueReference, + paymentAccountReference, + tokenUniqueReference, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentAccountInfo = apply { + if (validated) { + return@apply + } + + accountHolderData().validate() + panUniqueReference() + paymentAccountReference() + tokenUniqueReference() + 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 = + (accountHolderData.asKnown().getOrNull()?.validity() ?: 0) + + (if (panUniqueReference.asKnown().isPresent) 1 else 0) + + (if (paymentAccountReference.asKnown().isPresent) 1 else 0) + + (if (tokenUniqueReference.asKnown().isPresent) 1 else 0) + + /** + * Additional information that can be used to identify the account holder, such as name, + * address, etc + */ + class AccountHolderData + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of() + ) : this(phoneNumber, mutableMapOf()) + + /** + * The phone number, may contain country code along with phone number when + * countryDialInCode is not present + * + * @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") + + /** + * 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 + + @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 [AccountHolderData]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountHolderData]. */ + class Builder internal constructor() { + + private var phoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accountHolderData: AccountHolderData) = apply { + phoneNumber = accountHolderData.phoneNumber + additionalProperties = accountHolderData.additionalProperties.toMutableMap() + } + + /** + * The phone number, may contain country code along with phone number when + * countryDialInCode is not present + */ + 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 + } + + 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 [AccountHolderData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccountHolderData = + AccountHolderData(phoneNumber, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AccountHolderData = apply { + if (validated) { + return@apply + } + + phoneNumber() + 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) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountHolderData && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(phoneNumber, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccountHolderData{phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PaymentAccountInfo && + accountHolderData == other.accountHolderData && + panUniqueReference == other.panUniqueReference && + paymentAccountReference == other.paymentAccountReference && + tokenUniqueReference == other.tokenUniqueReference && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountHolderData, + panUniqueReference, + paymentAccountReference, + tokenUniqueReference, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentAccountInfo{accountHolderData=$accountHolderData, panUniqueReference=$panUniqueReference, paymentAccountReference=$paymentAccountReference, tokenUniqueReference=$tokenUniqueReference, additionalProperties=$additionalProperties}" + } + + /** Human-readable name of the wallet that the token_requestor_id maps to. */ + class TokenRequestorName + @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 AMAZON_ONE = of("AMAZON_ONE") + + @JvmField val ANDROID_PAY = of("ANDROID_PAY") + + @JvmField val APPLE_PAY = of("APPLE_PAY") + + @JvmField val FACEBOOK = of("FACEBOOK") + + @JvmField val FITBIT_PAY = of("FITBIT_PAY") + + @JvmField val GARMIN_PAY = of("GARMIN_PAY") + + @JvmField val MICROSOFT_PAY = of("MICROSOFT_PAY") + + @JvmField val NETFLIX = of("NETFLIX") + + @JvmField val SAMSUNG_PAY = of("SAMSUNG_PAY") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmField val VISA_CHECKOUT = of("VISA_CHECKOUT") + + @JvmStatic fun of(value: String) = TokenRequestorName(JsonField.of(value)) + } + + /** An enum containing [TokenRequestorName]'s known values. */ + enum class Known { + AMAZON_ONE, + ANDROID_PAY, + APPLE_PAY, + FACEBOOK, + FITBIT_PAY, + GARMIN_PAY, + MICROSOFT_PAY, + NETFLIX, + SAMSUNG_PAY, + UNKNOWN, + VISA_CHECKOUT, + } + + /** + * An enum containing [TokenRequestorName]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TokenRequestorName] 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 { + AMAZON_ONE, + ANDROID_PAY, + APPLE_PAY, + FACEBOOK, + FITBIT_PAY, + GARMIN_PAY, + MICROSOFT_PAY, + NETFLIX, + SAMSUNG_PAY, + UNKNOWN, + VISA_CHECKOUT, + /** + * An enum member indicating that [TokenRequestorName] 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) { + AMAZON_ONE -> Value.AMAZON_ONE + ANDROID_PAY -> Value.ANDROID_PAY + APPLE_PAY -> Value.APPLE_PAY + FACEBOOK -> Value.FACEBOOK + FITBIT_PAY -> Value.FITBIT_PAY + GARMIN_PAY -> Value.GARMIN_PAY + MICROSOFT_PAY -> Value.MICROSOFT_PAY + NETFLIX -> Value.NETFLIX + SAMSUNG_PAY -> Value.SAMSUNG_PAY + UNKNOWN -> Value.UNKNOWN + VISA_CHECKOUT -> Value.VISA_CHECKOUT + 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) { + AMAZON_ONE -> Known.AMAZON_ONE + ANDROID_PAY -> Known.ANDROID_PAY + APPLE_PAY -> Known.APPLE_PAY + FACEBOOK -> Known.FACEBOOK + FITBIT_PAY -> Known.FITBIT_PAY + GARMIN_PAY -> Known.GARMIN_PAY + MICROSOFT_PAY -> Known.MICROSOFT_PAY + NETFLIX -> Known.NETFLIX + SAMSUNG_PAY -> Known.SAMSUNG_PAY + UNKNOWN -> Known.UNKNOWN + VISA_CHECKOUT -> Known.VISA_CHECKOUT + else -> throw LithicInvalidDataException("Unknown TokenRequestorName: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenRequestorName = 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 TokenRequestorName && 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 DigitalWalletTokenMetadata && + paymentAccountInfo == other.paymentAccountInfo && + status == other.status && + paymentAppInstanceId == other.paymentAppInstanceId && + tokenRequestorId == other.tokenRequestorId && + tokenRequestorName == other.tokenRequestorName && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + paymentAccountInfo, + status, + paymentAppInstanceId, + tokenRequestorId, + tokenRequestorName, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DigitalWalletTokenMetadata{paymentAccountInfo=$paymentAccountInfo, status=$status, paymentAppInstanceId=$paymentAppInstanceId, tokenRequestorId=$tokenRequestorId, tokenRequestorName=$tokenRequestorName, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUnpauseResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccount.kt similarity index 95% rename from lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUnpauseResponse.kt rename to lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccount.kt index 0c50e93c4..e5d21dcb9 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUnpauseResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccount.kt @@ -20,7 +20,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class ExternalBankAccountUnpauseResponse +class ExternalBankAccount @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, @@ -502,8 +502,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExternalBankAccountUnpauseResponse]. + * Returns a mutable builder for constructing an instance of [ExternalBankAccount]. * * The following fields are required: * ```java @@ -525,7 +524,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExternalBankAccountUnpauseResponse]. */ + /** A builder for [ExternalBankAccount]. */ class Builder internal constructor() { private var token: JsonField? = null @@ -553,34 +552,31 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(externalBankAccountUnpauseResponse: ExternalBankAccountUnpauseResponse) = - apply { - token = externalBankAccountUnpauseResponse.token - country = externalBankAccountUnpauseResponse.country - created = externalBankAccountUnpauseResponse.created - currency = externalBankAccountUnpauseResponse.currency - lastFour = externalBankAccountUnpauseResponse.lastFour - owner = externalBankAccountUnpauseResponse.owner - ownerType = externalBankAccountUnpauseResponse.ownerType - routingNumber = externalBankAccountUnpauseResponse.routingNumber - state = externalBankAccountUnpauseResponse.state - type = externalBankAccountUnpauseResponse.type - verificationAttempts = externalBankAccountUnpauseResponse.verificationAttempts - verificationMethod = externalBankAccountUnpauseResponse.verificationMethod - verificationState = externalBankAccountUnpauseResponse.verificationState - accountToken = externalBankAccountUnpauseResponse.accountToken - address = externalBankAccountUnpauseResponse.address - companyId = externalBankAccountUnpauseResponse.companyId - dob = externalBankAccountUnpauseResponse.dob - doingBusinessAs = externalBankAccountUnpauseResponse.doingBusinessAs - financialAccountToken = externalBankAccountUnpauseResponse.financialAccountToken - name = externalBankAccountUnpauseResponse.name - userDefinedId = externalBankAccountUnpauseResponse.userDefinedId - verificationFailedReason = - externalBankAccountUnpauseResponse.verificationFailedReason - additionalProperties = - externalBankAccountUnpauseResponse.additionalProperties.toMutableMap() - } + internal fun from(externalBankAccount: ExternalBankAccount) = apply { + token = externalBankAccount.token + country = externalBankAccount.country + created = externalBankAccount.created + currency = externalBankAccount.currency + lastFour = externalBankAccount.lastFour + owner = externalBankAccount.owner + ownerType = externalBankAccount.ownerType + routingNumber = externalBankAccount.routingNumber + state = externalBankAccount.state + type = externalBankAccount.type + verificationAttempts = externalBankAccount.verificationAttempts + verificationMethod = externalBankAccount.verificationMethod + verificationState = externalBankAccount.verificationState + accountToken = externalBankAccount.accountToken + address = externalBankAccount.address + companyId = externalBankAccount.companyId + dob = externalBankAccount.dob + doingBusinessAs = externalBankAccount.doingBusinessAs + financialAccountToken = externalBankAccount.financialAccountToken + name = externalBankAccount.name + userDefinedId = externalBankAccount.userDefinedId + verificationFailedReason = externalBankAccount.verificationFailedReason + additionalProperties = externalBankAccount.additionalProperties.toMutableMap() + } /** * A globally unique identifier for this record of an external bank account association. If @@ -943,7 +939,7 @@ private constructor( } /** - * Returns an immutable instance of [ExternalBankAccountUnpauseResponse]. + * Returns an immutable instance of [ExternalBankAccount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -966,8 +962,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ExternalBankAccountUnpauseResponse = - ExternalBankAccountUnpauseResponse( + fun build(): ExternalBankAccount = + ExternalBankAccount( checkRequired("token", token), checkRequired("country", country), checkRequired("created", created), @@ -996,7 +992,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExternalBankAccountUnpauseResponse = apply { + fun validate(): ExternalBankAccount = apply { if (validated) { return@apply } @@ -1472,7 +1468,7 @@ private constructor( return true } - return other is ExternalBankAccountUnpauseResponse && + return other is ExternalBankAccount && token == other.token && country == other.country && created == other.created && @@ -1529,5 +1525,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExternalBankAccountUnpauseResponse{token=$token, country=$country, created=$created, currency=$currency, lastFour=$lastFour, owner=$owner, ownerType=$ownerType, routingNumber=$routingNumber, state=$state, type=$type, verificationAttempts=$verificationAttempts, verificationMethod=$verificationMethod, verificationState=$verificationState, accountToken=$accountToken, address=$address, companyId=$companyId, dob=$dob, doingBusinessAs=$doingBusinessAs, financialAccountToken=$financialAccountToken, name=$name, userDefinedId=$userDefinedId, verificationFailedReason=$verificationFailedReason, additionalProperties=$additionalProperties}" + "ExternalBankAccount{token=$token, country=$country, created=$created, currency=$currency, lastFour=$lastFour, owner=$owner, ownerType=$ownerType, routingNumber=$routingNumber, state=$state, type=$type, verificationAttempts=$verificationAttempts, verificationMethod=$verificationMethod, verificationState=$verificationState, accountToken=$accountToken, address=$address, companyId=$companyId, dob=$dob, doingBusinessAs=$doingBusinessAs, financialAccountToken=$financialAccountToken, name=$name, userDefinedId=$userDefinedId, verificationFailedReason=$verificationFailedReason, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponse.kt deleted file mode 100644 index c1c3ed88c..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponse.kt +++ /dev/null @@ -1,1534 +0,0 @@ -// 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.LocalDate -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ExternalBankAccountRetryPrenoteResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val country: JsonField, - private val created: JsonField, - private val currency: JsonField, - private val lastFour: JsonField, - private val owner: JsonField, - private val ownerType: JsonField, - private val routingNumber: JsonField, - private val state: JsonField, - private val type: JsonField, - private val verificationAttempts: JsonField, - private val verificationMethod: JsonField, - private val verificationState: JsonField, - private val accountToken: JsonField, - private val address: JsonField, - private val companyId: JsonField, - private val dob: JsonField, - private val doingBusinessAs: JsonField, - private val financialAccountToken: JsonField, - private val name: JsonField, - private val userDefinedId: JsonField, - private val verificationFailedReason: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - created: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("last_four") @ExcludeMissing lastFour: JsonField = JsonMissing.of(), - @JsonProperty("owner") @ExcludeMissing owner: JsonField = JsonMissing.of(), - @JsonProperty("owner_type") - @ExcludeMissing - ownerType: JsonField = JsonMissing.of(), - @JsonProperty("routing_number") - @ExcludeMissing - routingNumber: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("verification_attempts") - @ExcludeMissing - verificationAttempts: JsonField = JsonMissing.of(), - @JsonProperty("verification_method") - @ExcludeMissing - verificationMethod: JsonField = JsonMissing.of(), - @JsonProperty("verification_state") - @ExcludeMissing - verificationState: JsonField = JsonMissing.of(), - @JsonProperty("account_token") - @ExcludeMissing - accountToken: JsonField = JsonMissing.of(), - @JsonProperty("address") - @ExcludeMissing - address: JsonField = JsonMissing.of(), - @JsonProperty("company_id") @ExcludeMissing companyId: JsonField = JsonMissing.of(), - @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), - @JsonProperty("doing_business_as") - @ExcludeMissing - doingBusinessAs: JsonField = JsonMissing.of(), - @JsonProperty("financial_account_token") - @ExcludeMissing - financialAccountToken: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("user_defined_id") - @ExcludeMissing - userDefinedId: JsonField = JsonMissing.of(), - @JsonProperty("verification_failed_reason") - @ExcludeMissing - verificationFailedReason: JsonField = JsonMissing.of(), - ) : this( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, - accountToken, - address, - companyId, - dob, - doingBusinessAs, - financialAccountToken, - name, - userDefinedId, - verificationFailedReason, - mutableMapOf(), - ) - - /** - * A globally unique identifier for this record of an external bank account association. If a - * program links an external bank account to more than one end-user or to both the program and - * the end-user, then Lithic will return each record of the association - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun token(): String = token.getRequired("token") - - /** - * The country that the bank account is located in using ISO 3166-1. We will only accept USA - * bank accounts e.g., USA - * - * @throws LithicInvalidDataException if 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") - - /** - * An ISO 8601 string representing when this funding source was added to the Lithic account. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun created(): OffsetDateTime = created.getRequired("created") - - /** - * currency of the external account 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") - - /** - * The last 4 digits of the bank account. Derived by Lithic from the account number passed - * - * @throws LithicInvalidDataException if 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") - - /** - * Legal Name of the business or individual who owns the external account. This will appear in - * statements - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun owner(): String = owner.getRequired("owner") - - /** - * Owner 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 ownerType(): OwnerType = ownerType.getRequired("owner_type") - - /** - * Routing 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 routingNumber(): String = routingNumber.getRequired("routing_number") - - /** - * Account 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 state(): State = state.getRequired("state") - - /** - * Account 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(): AccountType = type.getRequired("type") - - /** - * The number of attempts at verification - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun verificationAttempts(): Long = verificationAttempts.getRequired("verification_attempts") - - /** - * Verification Method - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun verificationMethod(): VerificationMethod = - verificationMethod.getRequired("verification_method") - - /** - * Verification 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 verificationState(): VerificationState = verificationState.getRequired("verification_state") - - /** - * Indicates which Lithic account the external account is associated with. For external accounts - * that are associated with the program, account_token field returned will be null - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun accountToken(): Optional = accountToken.getOptional("account_token") - - /** - * Address - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun address(): Optional = address.getOptional("address") - - /** - * Optional field that helps identify bank accounts in receipts - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun companyId(): Optional = companyId.getOptional("company_id") - - /** - * Date of Birth of the Individual that owns the external bank account - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun dob(): Optional = dob.getOptional("dob") - - /** - * Doing Business As - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun doingBusinessAs(): Optional = doingBusinessAs.getOptional("doing_business_as") - - /** - * The financial account token of the operating account to fund the micro deposits - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun financialAccountToken(): Optional = - financialAccountToken.getOptional("financial_account_token") - - /** - * The nickname for this External Bank Account - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * User Defined ID - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") - - /** - * Optional free text description of the reason for the failed verification. For ACH - * micro-deposits returned, this field will display the reason return code sent by the ACH - * network - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun verificationFailedReason(): Optional = - verificationFailedReason.getOptional("verification_failed_reason") - - /** - * 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 [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 [created]. - * - * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [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 [owner]. - * - * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner - - /** - * Returns the raw JSON value of [ownerType]. - * - * Unlike [ownerType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType - - /** - * Returns the raw JSON value of [routingNumber]. - * - * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("routing_number") - @ExcludeMissing - fun _routingNumber(): JsonField = routingNumber - - /** - * Returns the raw JSON value of [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 - - /** - * Returns the raw JSON value of [verificationAttempts]. - * - * Unlike [verificationAttempts], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("verification_attempts") - @ExcludeMissing - fun _verificationAttempts(): JsonField = verificationAttempts - - /** - * Returns the raw JSON value of [verificationMethod]. - * - * Unlike [verificationMethod], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("verification_method") - @ExcludeMissing - fun _verificationMethod(): JsonField = verificationMethod - - /** - * Returns the raw JSON value of [verificationState]. - * - * Unlike [verificationState], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("verification_state") - @ExcludeMissing - fun _verificationState(): JsonField = verificationState - - /** - * Returns the raw JSON value of [accountToken]. - * - * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account_token") - @ExcludeMissing - fun _accountToken(): JsonField = accountToken - - /** - * Returns the raw JSON value of [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 [companyId]. - * - * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId - - /** - * Returns the raw JSON value of [dob]. - * - * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob - - /** - * Returns the raw JSON value of [doingBusinessAs]. - * - * Unlike [doingBusinessAs], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("doing_business_as") - @ExcludeMissing - fun _doingBusinessAs(): JsonField = doingBusinessAs - - /** - * Returns the raw JSON value of [financialAccountToken]. - * - * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("financial_account_token") - @ExcludeMissing - fun _financialAccountToken(): JsonField = financialAccountToken - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [userDefinedId]. - * - * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_defined_id") - @ExcludeMissing - fun _userDefinedId(): JsonField = userDefinedId - - /** - * Returns the raw JSON value of [verificationFailedReason]. - * - * Unlike [verificationFailedReason], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("verification_failed_reason") - @ExcludeMissing - fun _verificationFailedReason(): JsonField = verificationFailedReason - - @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 - * [ExternalBankAccountRetryPrenoteResponse]. - * - * The following fields are required: - * ```java - * .token() - * .country() - * .created() - * .currency() - * .lastFour() - * .owner() - * .ownerType() - * .routingNumber() - * .state() - * .type() - * .verificationAttempts() - * .verificationMethod() - * .verificationState() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ExternalBankAccountRetryPrenoteResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var country: JsonField? = null - private var created: JsonField? = null - private var currency: JsonField? = null - private var lastFour: JsonField? = null - private var owner: JsonField? = null - private var ownerType: JsonField? = null - private var routingNumber: JsonField? = null - private var state: JsonField? = null - private var type: JsonField? = null - private var verificationAttempts: JsonField? = null - private var verificationMethod: JsonField? = null - private var verificationState: JsonField? = null - private var accountToken: JsonField = JsonMissing.of() - private var address: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() - private var dob: JsonField = JsonMissing.of() - private var doingBusinessAs: JsonField = JsonMissing.of() - private var financialAccountToken: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var userDefinedId: JsonField = JsonMissing.of() - private var verificationFailedReason: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - externalBankAccountRetryPrenoteResponse: ExternalBankAccountRetryPrenoteResponse - ) = apply { - token = externalBankAccountRetryPrenoteResponse.token - country = externalBankAccountRetryPrenoteResponse.country - created = externalBankAccountRetryPrenoteResponse.created - currency = externalBankAccountRetryPrenoteResponse.currency - lastFour = externalBankAccountRetryPrenoteResponse.lastFour - owner = externalBankAccountRetryPrenoteResponse.owner - ownerType = externalBankAccountRetryPrenoteResponse.ownerType - routingNumber = externalBankAccountRetryPrenoteResponse.routingNumber - state = externalBankAccountRetryPrenoteResponse.state - type = externalBankAccountRetryPrenoteResponse.type - verificationAttempts = externalBankAccountRetryPrenoteResponse.verificationAttempts - verificationMethod = externalBankAccountRetryPrenoteResponse.verificationMethod - verificationState = externalBankAccountRetryPrenoteResponse.verificationState - accountToken = externalBankAccountRetryPrenoteResponse.accountToken - address = externalBankAccountRetryPrenoteResponse.address - companyId = externalBankAccountRetryPrenoteResponse.companyId - dob = externalBankAccountRetryPrenoteResponse.dob - doingBusinessAs = externalBankAccountRetryPrenoteResponse.doingBusinessAs - financialAccountToken = externalBankAccountRetryPrenoteResponse.financialAccountToken - name = externalBankAccountRetryPrenoteResponse.name - userDefinedId = externalBankAccountRetryPrenoteResponse.userDefinedId - verificationFailedReason = - externalBankAccountRetryPrenoteResponse.verificationFailedReason - additionalProperties = - externalBankAccountRetryPrenoteResponse.additionalProperties.toMutableMap() - } - - /** - * A globally unique identifier for this record of an external bank account association. If - * a program links an external bank account to more than one end-user or to both the program - * and the end-user, then Lithic will return each record of the association - */ - fun token(token: String) = token(JsonField.of(token)) - - /** - * Sets [Builder.token] to an arbitrary JSON value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun token(token: JsonField) = apply { this.token = token } - - /** - * The country that the bank account is located in using ISO 3166-1. We will only accept USA - * bank accounts e.g., USA - */ - 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 } - - /** - * An ISO 8601 string representing when this funding source was added to the Lithic account. - */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** - * Sets [Builder.created] to an arbitrary JSON value. - * - * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun created(created: JsonField) = apply { this.created = created } - - /** currency of the external account 3-character alphabetic ISO 4217 code */ - 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 } - - /** - * The last 4 digits of the bank account. Derived by Lithic from the account number passed - */ - 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 } - - /** - * Legal Name of the business or individual who owns the external account. This will appear - * in statements - */ - fun owner(owner: String) = owner(JsonField.of(owner)) - - /** - * Sets [Builder.owner] to an arbitrary JSON value. - * - * You should usually call [Builder.owner] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun owner(owner: JsonField) = apply { this.owner = owner } - - /** Owner Type */ - fun ownerType(ownerType: OwnerType) = ownerType(JsonField.of(ownerType)) - - /** - * Sets [Builder.ownerType] to an arbitrary JSON value. - * - * You should usually call [Builder.ownerType] with a well-typed [OwnerType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ownerType(ownerType: JsonField) = apply { this.ownerType = ownerType } - - /** Routing Number */ - fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) - - /** - * Sets [Builder.routingNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.routingNumber] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun routingNumber(routingNumber: JsonField) = apply { - this.routingNumber = routingNumber - } - - /** Account State */ - 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 } - - /** Account Type */ - fun type(type: AccountType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [AccountType] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** The number of attempts at verification */ - fun verificationAttempts(verificationAttempts: Long) = - verificationAttempts(JsonField.of(verificationAttempts)) - - /** - * Sets [Builder.verificationAttempts] to an arbitrary JSON value. - * - * You should usually call [Builder.verificationAttempts] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun verificationAttempts(verificationAttempts: JsonField) = apply { - this.verificationAttempts = verificationAttempts - } - - /** Verification Method */ - fun verificationMethod(verificationMethod: VerificationMethod) = - verificationMethod(JsonField.of(verificationMethod)) - - /** - * Sets [Builder.verificationMethod] to an arbitrary JSON value. - * - * You should usually call [Builder.verificationMethod] with a well-typed - * [VerificationMethod] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun verificationMethod(verificationMethod: JsonField) = apply { - this.verificationMethod = verificationMethod - } - - /** Verification State */ - fun verificationState(verificationState: VerificationState) = - verificationState(JsonField.of(verificationState)) - - /** - * Sets [Builder.verificationState] to an arbitrary JSON value. - * - * You should usually call [Builder.verificationState] with a well-typed [VerificationState] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun verificationState(verificationState: JsonField) = apply { - this.verificationState = verificationState - } - - /** - * Indicates which Lithic account the external account is associated with. For external - * accounts that are associated with the program, account_token field returned will be null - */ - fun accountToken(accountToken: String?) = accountToken(JsonField.ofNullable(accountToken)) - - /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ - fun accountToken(accountToken: Optional) = accountToken(accountToken.getOrNull()) - - /** - * Sets [Builder.accountToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accountToken] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun accountToken(accountToken: JsonField) = apply { - this.accountToken = accountToken - } - - /** Address */ - fun address(address: ExternalBankAccountAddress?) = address(JsonField.ofNullable(address)) - - /** Alias for calling [Builder.address] with `address.orElse(null)`. */ - fun address(address: Optional) = address(address.getOrNull()) - - /** - * Sets [Builder.address] to an arbitrary JSON value. - * - * You should usually call [Builder.address] with a well-typed [ExternalBankAccountAddress] - * 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 - } - - /** Optional field that helps identify bank accounts in receipts */ - fun companyId(companyId: String?) = companyId(JsonField.ofNullable(companyId)) - - /** Alias for calling [Builder.companyId] with `companyId.orElse(null)`. */ - fun companyId(companyId: Optional) = companyId(companyId.getOrNull()) - - /** - * Sets [Builder.companyId] to an arbitrary JSON value. - * - * You should usually call [Builder.companyId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun companyId(companyId: JsonField) = apply { this.companyId = companyId } - - /** Date of Birth of the Individual that owns the external bank account */ - fun dob(dob: LocalDate?) = dob(JsonField.ofNullable(dob)) - - /** Alias for calling [Builder.dob] with `dob.orElse(null)`. */ - fun dob(dob: Optional) = dob(dob.getOrNull()) - - /** - * Sets [Builder.dob] to an arbitrary JSON value. - * - * You should usually call [Builder.dob] with a well-typed [LocalDate] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun dob(dob: JsonField) = apply { this.dob = dob } - - /** Doing Business As */ - fun doingBusinessAs(doingBusinessAs: String?) = - doingBusinessAs(JsonField.ofNullable(doingBusinessAs)) - - /** Alias for calling [Builder.doingBusinessAs] with `doingBusinessAs.orElse(null)`. */ - fun doingBusinessAs(doingBusinessAs: Optional) = - doingBusinessAs(doingBusinessAs.getOrNull()) - - /** - * Sets [Builder.doingBusinessAs] to an arbitrary JSON value. - * - * You should usually call [Builder.doingBusinessAs] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun doingBusinessAs(doingBusinessAs: JsonField) = apply { - this.doingBusinessAs = doingBusinessAs - } - - /** The financial account token of the operating account to fund the micro deposits */ - fun financialAccountToken(financialAccountToken: String?) = - financialAccountToken(JsonField.ofNullable(financialAccountToken)) - - /** - * Alias for calling [Builder.financialAccountToken] with - * `financialAccountToken.orElse(null)`. - */ - fun financialAccountToken(financialAccountToken: Optional) = - financialAccountToken(financialAccountToken.getOrNull()) - - /** - * Sets [Builder.financialAccountToken] to an arbitrary JSON value. - * - * You should usually call [Builder.financialAccountToken] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun financialAccountToken(financialAccountToken: JsonField) = apply { - this.financialAccountToken = financialAccountToken - } - - /** The nickname for this External Bank Account */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** User Defined ID */ - fun userDefinedId(userDefinedId: String?) = - userDefinedId(JsonField.ofNullable(userDefinedId)) - - /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ - fun userDefinedId(userDefinedId: Optional) = - userDefinedId(userDefinedId.getOrNull()) - - /** - * Sets [Builder.userDefinedId] to an arbitrary JSON value. - * - * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun userDefinedId(userDefinedId: JsonField) = apply { - this.userDefinedId = userDefinedId - } - - /** - * Optional free text description of the reason for the failed verification. For ACH - * micro-deposits returned, this field will display the reason return code sent by the ACH - * network - */ - fun verificationFailedReason(verificationFailedReason: String?) = - verificationFailedReason(JsonField.ofNullable(verificationFailedReason)) - - /** - * Alias for calling [Builder.verificationFailedReason] with - * `verificationFailedReason.orElse(null)`. - */ - fun verificationFailedReason(verificationFailedReason: Optional) = - verificationFailedReason(verificationFailedReason.getOrNull()) - - /** - * Sets [Builder.verificationFailedReason] to an arbitrary JSON value. - * - * You should usually call [Builder.verificationFailedReason] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun verificationFailedReason(verificationFailedReason: JsonField) = apply { - this.verificationFailedReason = verificationFailedReason - } - - 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 [ExternalBankAccountRetryPrenoteResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .country() - * .created() - * .currency() - * .lastFour() - * .owner() - * .ownerType() - * .routingNumber() - * .state() - * .type() - * .verificationAttempts() - * .verificationMethod() - * .verificationState() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ExternalBankAccountRetryPrenoteResponse = - ExternalBankAccountRetryPrenoteResponse( - checkRequired("token", token), - checkRequired("country", country), - checkRequired("created", created), - checkRequired("currency", currency), - checkRequired("lastFour", lastFour), - checkRequired("owner", owner), - checkRequired("ownerType", ownerType), - checkRequired("routingNumber", routingNumber), - checkRequired("state", state), - checkRequired("type", type), - checkRequired("verificationAttempts", verificationAttempts), - checkRequired("verificationMethod", verificationMethod), - checkRequired("verificationState", verificationState), - accountToken, - address, - companyId, - dob, - doingBusinessAs, - financialAccountToken, - name, - userDefinedId, - verificationFailedReason, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ExternalBankAccountRetryPrenoteResponse = apply { - if (validated) { - return@apply - } - - token() - country() - created() - currency() - lastFour() - owner() - ownerType().validate() - routingNumber() - state().validate() - type().validate() - verificationAttempts() - verificationMethod().validate() - verificationState().validate() - accountToken() - address().ifPresent { it.validate() } - companyId() - dob() - doingBusinessAs() - financialAccountToken() - name() - userDefinedId() - verificationFailedReason() - 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 (country.asKnown().isPresent) 1 else 0) + - (if (created.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (lastFour.asKnown().isPresent) 1 else 0) + - (if (owner.asKnown().isPresent) 1 else 0) + - (ownerType.asKnown().getOrNull()?.validity() ?: 0) + - (if (routingNumber.asKnown().isPresent) 1 else 0) + - (state.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (verificationAttempts.asKnown().isPresent) 1 else 0) + - (verificationMethod.asKnown().getOrNull()?.validity() ?: 0) + - (verificationState.asKnown().getOrNull()?.validity() ?: 0) + - (if (accountToken.asKnown().isPresent) 1 else 0) + - (address.asKnown().getOrNull()?.validity() ?: 0) + - (if (companyId.asKnown().isPresent) 1 else 0) + - (if (dob.asKnown().isPresent) 1 else 0) + - (if (doingBusinessAs.asKnown().isPresent) 1 else 0) + - (if (financialAccountToken.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (userDefinedId.asKnown().isPresent) 1 else 0) + - (if (verificationFailedReason.asKnown().isPresent) 1 else 0) - - /** Account State */ - 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 ENABLED = of("ENABLED") - - @JvmField val CLOSED = of("CLOSED") - - @JvmField val PAUSED = of("PAUSED") - - @JvmStatic fun of(value: String) = State(JsonField.of(value)) - } - - /** An enum containing [State]'s known values. */ - enum class Known { - ENABLED, - CLOSED, - PAUSED, - } - - /** - * 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 { - ENABLED, - CLOSED, - PAUSED, - /** 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) { - ENABLED -> Value.ENABLED - CLOSED -> Value.CLOSED - PAUSED -> Value.PAUSED - 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) { - ENABLED -> Known.ENABLED - CLOSED -> Known.CLOSED - PAUSED -> Known.PAUSED - 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 - - 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() - } - - /** Account Type */ - 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 - - 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() - } - - /** Verification State */ - class VerificationState @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PENDING = of("PENDING") - - @JvmField val ENABLED = of("ENABLED") - - @JvmField val FAILED_VERIFICATION = of("FAILED_VERIFICATION") - - @JvmField val INSUFFICIENT_FUNDS = of("INSUFFICIENT_FUNDS") - - @JvmStatic fun of(value: String) = VerificationState(JsonField.of(value)) - } - - /** An enum containing [VerificationState]'s known values. */ - enum class Known { - PENDING, - ENABLED, - FAILED_VERIFICATION, - INSUFFICIENT_FUNDS, - } - - /** - * An enum containing [VerificationState]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [VerificationState] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PENDING, - ENABLED, - FAILED_VERIFICATION, - INSUFFICIENT_FUNDS, - /** - * An enum member indicating that [VerificationState] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PENDING -> Value.PENDING - ENABLED -> Value.ENABLED - FAILED_VERIFICATION -> Value.FAILED_VERIFICATION - INSUFFICIENT_FUNDS -> Value.INSUFFICIENT_FUNDS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PENDING -> Known.PENDING - ENABLED -> Known.ENABLED - FAILED_VERIFICATION -> Known.FAILED_VERIFICATION - INSUFFICIENT_FUNDS -> Known.INSUFFICIENT_FUNDS - else -> throw LithicInvalidDataException("Unknown VerificationState: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): VerificationState = 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 VerificationState && 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 ExternalBankAccountRetryPrenoteResponse && - token == other.token && - country == other.country && - created == other.created && - currency == other.currency && - lastFour == other.lastFour && - owner == other.owner && - ownerType == other.ownerType && - routingNumber == other.routingNumber && - state == other.state && - type == other.type && - verificationAttempts == other.verificationAttempts && - verificationMethod == other.verificationMethod && - verificationState == other.verificationState && - accountToken == other.accountToken && - address == other.address && - companyId == other.companyId && - dob == other.dob && - doingBusinessAs == other.doingBusinessAs && - financialAccountToken == other.financialAccountToken && - name == other.name && - userDefinedId == other.userDefinedId && - verificationFailedReason == other.verificationFailedReason && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - country, - created, - currency, - lastFour, - owner, - ownerType, - routingNumber, - state, - type, - verificationAttempts, - verificationMethod, - verificationState, - accountToken, - address, - companyId, - dob, - doingBusinessAs, - financialAccountToken, - name, - userDefinedId, - verificationFailedReason, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ExternalBankAccountRetryPrenoteResponse{token=$token, country=$country, created=$created, currency=$currency, lastFour=$lastFour, owner=$owner, ownerType=$ownerType, routingNumber=$routingNumber, state=$state, type=$type, verificationAttempts=$verificationAttempts, verificationMethod=$verificationMethod, verificationState=$verificationState, accountToken=$accountToken, address=$address, companyId=$companyId, dob=$dob, doingBusinessAs=$doingBusinessAs, financialAccountToken=$financialAccountToken, name=$name, userDefinedId=$userDefinedId, verificationFailedReason=$verificationFailedReason, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalance.kt similarity index 94% rename from lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt rename to lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalance.kt index 15cd9c923..1ad665cfa 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceListResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalance.kt @@ -19,7 +19,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Balance of a Financial Account */ -class BalanceListResponse +class FinancialAccountBalance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, @@ -254,7 +254,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BalanceListResponse]. + * Returns a mutable builder for constructing an instance of [FinancialAccountBalance]. * * The following fields are required: * ```java @@ -273,7 +273,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BalanceListResponse]. */ + /** A builder for [FinancialAccountBalance]. */ class Builder internal constructor() { private var token: JsonField? = null @@ -289,18 +289,18 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(balanceListResponse: BalanceListResponse) = apply { - token = balanceListResponse.token - availableAmount = balanceListResponse.availableAmount - created = balanceListResponse.created - currency = balanceListResponse.currency - lastTransactionEventToken = balanceListResponse.lastTransactionEventToken - lastTransactionToken = balanceListResponse.lastTransactionToken - pendingAmount = balanceListResponse.pendingAmount - totalAmount = balanceListResponse.totalAmount - type = balanceListResponse.type - updated = balanceListResponse.updated - additionalProperties = balanceListResponse.additionalProperties.toMutableMap() + internal fun from(financialAccountBalance: FinancialAccountBalance) = apply { + token = financialAccountBalance.token + availableAmount = financialAccountBalance.availableAmount + created = financialAccountBalance.created + currency = financialAccountBalance.currency + lastTransactionEventToken = financialAccountBalance.lastTransactionEventToken + lastTransactionToken = financialAccountBalance.lastTransactionToken + pendingAmount = financialAccountBalance.pendingAmount + totalAmount = financialAccountBalance.totalAmount + type = financialAccountBalance.type + updated = financialAccountBalance.updated + additionalProperties = financialAccountBalance.additionalProperties.toMutableMap() } /** Globally unique identifier for the financial account that holds this balance. */ @@ -461,7 +461,7 @@ private constructor( } /** - * Returns an immutable instance of [BalanceListResponse]. + * Returns an immutable instance of [FinancialAccountBalance]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -481,8 +481,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BalanceListResponse = - BalanceListResponse( + fun build(): FinancialAccountBalance = + FinancialAccountBalance( checkRequired("token", token), checkRequired("availableAmount", availableAmount), checkRequired("created", created), @@ -499,7 +499,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BalanceListResponse = apply { + fun validate(): FinancialAccountBalance = apply { if (validated) { return@apply } @@ -686,7 +686,7 @@ private constructor( return true } - return other is BalanceListResponse && + return other is FinancialAccountBalance && token == other.token && availableAmount == other.availableAmount && created == other.created && @@ -719,5 +719,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BalanceListResponse{token=$token, availableAmount=$availableAmount, created=$created, currency=$currency, lastTransactionEventToken=$lastTransactionEventToken, lastTransactionToken=$lastTransactionToken, pendingAmount=$pendingAmount, totalAmount=$totalAmount, type=$type, updated=$updated, additionalProperties=$additionalProperties}" + "FinancialAccountBalance{token=$token, availableAmount=$availableAmount, created=$created, currency=$currency, lastTransactionEventToken=$lastTransactionEventToken, lastTransactionToken=$lastTransactionToken, pendingAmount=$pendingAmount, totalAmount=$totalAmount, type=$type, updated=$updated, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPage.kt index 1b348b85d..600345f90 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPage.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPage.kt @@ -16,14 +16,14 @@ private constructor( private val service: BalanceService, private val params: FinancialAccountBalanceListParams, private val response: FinancialAccountBalanceListPageResponse, -) : Page { +) : Page { /** * Delegates to [FinancialAccountBalanceListPageResponse], but gracefully handles missing data. * * @see FinancialAccountBalanceListPageResponse.data */ - fun data(): List = + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** @@ -33,7 +33,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = false @@ -42,7 +42,7 @@ private constructor( override fun nextPage(): FinancialAccountBalanceListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): FinancialAccountBalanceListParams = params diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageAsync.kt index 6e4bee5aa..0440502df 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageAsync.kt @@ -19,14 +19,14 @@ private constructor( private val streamHandlerExecutor: Executor, private val params: FinancialAccountBalanceListParams, private val response: FinancialAccountBalanceListPageResponse, -) : PageAsync { +) : PageAsync { /** * Delegates to [FinancialAccountBalanceListPageResponse], but gracefully handles missing data. * * @see FinancialAccountBalanceListPageResponse.data */ - fun data(): List = + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** @@ -36,7 +36,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = false @@ -46,7 +46,7 @@ private constructor( override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPagerAsync = + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageResponse.kt index 5542bd63b..375727917 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageResponse.kt @@ -21,7 +21,7 @@ import kotlin.jvm.optionals.getOrNull class FinancialAccountBalanceListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val data: JsonField>, + private val data: JsonField>, private val hasMore: JsonField, private val additionalProperties: MutableMap, ) { @@ -30,7 +30,7 @@ private constructor( private constructor( @JsonProperty("data") @ExcludeMissing - data: JsonField> = JsonMissing.of(), + data: JsonField> = JsonMissing.of(), @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), ) : this(data, hasMore, mutableMapOf()) @@ -38,7 +38,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 data(): List = data.getRequired("data") + fun data(): List = data.getRequired("data") /** * More data exists. @@ -53,7 +53,9 @@ private constructor( * * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data /** * Returns the raw JSON value of [hasMore]. @@ -92,7 +94,7 @@ private constructor( /** A builder for [FinancialAccountBalanceListPageResponse]. */ class Builder internal constructor() { - private var data: JsonField>? = null + private var data: JsonField>? = null private var hasMore: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -106,25 +108,25 @@ private constructor( financialAccountBalanceListPageResponse.additionalProperties.toMutableMap() } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) /** * Sets [Builder.data] to an arbitrary JSON value. * - * You should usually call [Builder.data] with a well-typed `List` + * You should usually call [Builder.data] with a well-typed `List` * value instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } /** - * Adds a single [BalanceListResponse] to [Builder.data]. + * Adds a single [FinancialAccountBalance] to [Builder.data]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addData(data: BalanceListResponse) = apply { + fun addData(data: FinancialAccountBalance) = apply { this.data = (this.data ?: JsonField.of(mutableListOf())).also { checkKnown("data", it).add(data) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEvent.kt similarity index 95% rename from lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListResponse.kt rename to lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEvent.kt index b539aab81..cdaf22447 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEvent.kt @@ -21,7 +21,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull -class FundingEventListResponse +class FundingEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, @@ -225,7 +225,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [FundingEventListResponse]. + * Returns a mutable builder for constructing an instance of [FundingEvent]. * * The following fields are required: * ```java @@ -242,7 +242,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [FundingEventListResponse]. */ + /** A builder for [FundingEvent]. */ class Builder internal constructor() { private var token: JsonField? = null @@ -256,17 +256,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(fundingEventListResponse: FundingEventListResponse) = apply { - token = fundingEventListResponse.token - collectionResourceType = fundingEventListResponse.collectionResourceType - collectionTokens = fundingEventListResponse.collectionTokens.map { it.toMutableList() } - created = fundingEventListResponse.created - highWatermark = fundingEventListResponse.highWatermark + internal fun from(fundingEvent: FundingEvent) = apply { + token = fundingEvent.token + collectionResourceType = fundingEvent.collectionResourceType + collectionTokens = fundingEvent.collectionTokens.map { it.toMutableList() } + created = fundingEvent.created + highWatermark = fundingEvent.highWatermark networkSettlementSummary = - fundingEventListResponse.networkSettlementSummary.map { it.toMutableList() } - previousHighWatermark = fundingEventListResponse.previousHighWatermark - updated = fundingEventListResponse.updated - additionalProperties = fundingEventListResponse.additionalProperties.toMutableMap() + fundingEvent.networkSettlementSummary.map { it.toMutableList() } + previousHighWatermark = fundingEvent.previousHighWatermark + updated = fundingEvent.updated + additionalProperties = fundingEvent.additionalProperties.toMutableMap() } /** Unique token ID */ @@ -429,7 +429,7 @@ private constructor( } /** - * Returns an immutable instance of [FundingEventListResponse]. + * Returns an immutable instance of [FundingEvent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -447,8 +447,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): FundingEventListResponse = - FundingEventListResponse( + fun build(): FundingEvent = + FundingEvent( checkRequired("token", token), checkRequired("collectionResourceType", collectionResourceType), checkRequired("collectionTokens", collectionTokens).map { it.toImmutable() }, @@ -465,7 +465,7 @@ private constructor( private var validated: Boolean = false - fun validate(): FundingEventListResponse = apply { + fun validate(): FundingEvent = apply { if (validated) { return@apply } @@ -854,7 +854,7 @@ private constructor( return true } - return other is FundingEventListResponse && + return other is FundingEvent && token == other.token && collectionResourceType == other.collectionResourceType && collectionTokens == other.collectionTokens && @@ -883,5 +883,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "FundingEventListResponse{token=$token, collectionResourceType=$collectionResourceType, collectionTokens=$collectionTokens, created=$created, highWatermark=$highWatermark, networkSettlementSummary=$networkSettlementSummary, previousHighWatermark=$previousHighWatermark, updated=$updated, additionalProperties=$additionalProperties}" + "FundingEvent{token=$token, collectionResourceType=$collectionResourceType, collectionTokens=$collectionTokens, created=$created, highWatermark=$highWatermark, networkSettlementSummary=$networkSettlementSummary, previousHighWatermark=$previousHighWatermark, updated=$updated, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPage.kt index 367d6364c..db9b976e3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPage.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPage.kt @@ -16,15 +16,14 @@ private constructor( private val service: FundingEventService, private val params: FundingEventListParams, private val response: FundingEventListPageResponse, -) : Page { +) : Page { /** * Delegates to [FundingEventListPageResponse], but gracefully handles missing data. * * @see FundingEventListPageResponse.data */ - fun data(): List = - response._data().getOptional("data").getOrNull() ?: emptyList() + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** * Delegates to [FundingEventListPageResponse], but gracefully handles missing data. @@ -33,7 +32,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = items().isNotEmpty() @@ -46,7 +45,7 @@ private constructor( override fun nextPage(): FundingEventListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): FundingEventListParams = params diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPageAsync.kt index 7fd8db0a0..92c3d15c2 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPageAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPageAsync.kt @@ -19,15 +19,14 @@ private constructor( private val streamHandlerExecutor: Executor, private val params: FundingEventListParams, private val response: FundingEventListPageResponse, -) : PageAsync { +) : PageAsync { /** * Delegates to [FundingEventListPageResponse], but gracefully handles missing data. * * @see FundingEventListPageResponse.data */ - fun data(): List = - response._data().getOptional("data").getOrNull() ?: emptyList() + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** * Delegates to [FundingEventListPageResponse], but gracefully handles missing data. @@ -36,7 +35,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = items().isNotEmpty() @@ -50,8 +49,7 @@ private constructor( override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPagerAsync = - AutoPagerAsync.from(this, streamHandlerExecutor) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): FundingEventListParams = params diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPageResponse.kt index 5c416ca06..959c50dd8 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPageResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventListPageResponse.kt @@ -21,7 +21,7 @@ import kotlin.jvm.optionals.getOrNull class FundingEventListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val data: JsonField>, + private val data: JsonField>, private val hasMore: JsonField, private val additionalProperties: MutableMap, ) { @@ -30,7 +30,7 @@ private constructor( private constructor( @JsonProperty("data") @ExcludeMissing - data: JsonField> = JsonMissing.of(), + data: JsonField> = JsonMissing.of(), @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), ) : this(data, hasMore, mutableMapOf()) @@ -40,7 +40,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 data(): List = data.getRequired("data") + fun data(): List = data.getRequired("data") /** * @throws LithicInvalidDataException if the JSON field has an unexpected type or is @@ -53,9 +53,7 @@ private constructor( * * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("data") - @ExcludeMissing - fun _data(): JsonField> = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data /** * Returns the raw JSON value of [hasMore]. @@ -93,7 +91,7 @@ private constructor( /** A builder for [FundingEventListPageResponse]. */ class Builder internal constructor() { - private var data: JsonField>? = null + private var data: JsonField>? = null private var hasMore: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -105,25 +103,25 @@ private constructor( } /** Funding Event Response */ - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) /** * Sets [Builder.data] to an arbitrary JSON value. * - * You should usually call [Builder.data] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } /** - * Adds a single [FundingEventListResponse] to [Builder.data]. + * Adds a single [FundingEvent] to [Builder.data]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addData(data: FundingEventListResponse) = apply { + fun addData(data: FundingEvent) = apply { this.data = (this.data ?: JsonField.of(mutableListOf())).also { checkKnown("data", it).add(data) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventRetrieveResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventRetrieveResponse.kt deleted file mode 100644 index 72696dcdd..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventRetrieveResponse.kt +++ /dev/null @@ -1,888 +0,0 @@ -// 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.LocalDate -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class FundingEventRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val collectionResourceType: JsonField, - private val collectionTokens: JsonField>, - private val created: JsonField, - private val highWatermark: JsonField, - private val networkSettlementSummary: JsonField>, - private val previousHighWatermark: JsonField, - private val updated: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("collection_resource_type") - @ExcludeMissing - collectionResourceType: JsonField = JsonMissing.of(), - @JsonProperty("collection_tokens") - @ExcludeMissing - collectionTokens: JsonField> = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - created: JsonField = JsonMissing.of(), - @JsonProperty("high_watermark") - @ExcludeMissing - highWatermark: JsonField = JsonMissing.of(), - @JsonProperty("network_settlement_summary") - @ExcludeMissing - networkSettlementSummary: JsonField> = JsonMissing.of(), - @JsonProperty("previous_high_watermark") - @ExcludeMissing - previousHighWatermark: JsonField = JsonMissing.of(), - @JsonProperty("updated") - @ExcludeMissing - updated: JsonField = JsonMissing.of(), - ) : this( - token, - collectionResourceType, - collectionTokens, - created, - highWatermark, - networkSettlementSummary, - previousHighWatermark, - updated, - mutableMapOf(), - ) - - /** - * Unique token ID - * - * @throws LithicInvalidDataException if 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") - - /** - * Collection resource 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 collectionResourceType(): CollectionResourceType = - collectionResourceType.getRequired("collection_resource_type") - - /** - * IDs of collections, further information can be gathered from the appropriate collection API - * based on collection_resource_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 collectionTokens(): List = collectionTokens.getRequired("collection_tokens") - - /** - * Time of the creation - * - * @throws LithicInvalidDataException if 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") - - /** - * Time of the high watermark - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun highWatermark(): OffsetDateTime = highWatermark.getRequired("high_watermark") - - /** - * Network settlement summary breakdown by network settlement date - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun networkSettlementSummary(): List = - networkSettlementSummary.getRequired("network_settlement_summary") - - /** - * Time of the previous high watermark - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun previousHighWatermark(): OffsetDateTime = - previousHighWatermark.getRequired("previous_high_watermark") - - /** - * Time of the update - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updated(): OffsetDateTime = updated.getRequired("updated") - - /** - * Returns the raw JSON value of [token]. - * - * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - - /** - * Returns the raw JSON value of [collectionResourceType]. - * - * Unlike [collectionResourceType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("collection_resource_type") - @ExcludeMissing - fun _collectionResourceType(): JsonField = collectionResourceType - - /** - * Returns the raw JSON value of [collectionTokens]. - * - * Unlike [collectionTokens], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("collection_tokens") - @ExcludeMissing - fun _collectionTokens(): JsonField> = collectionTokens - - /** - * 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 [highWatermark]. - * - * Unlike [highWatermark], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("high_watermark") - @ExcludeMissing - fun _highWatermark(): JsonField = highWatermark - - /** - * Returns the raw JSON value of [networkSettlementSummary]. - * - * Unlike [networkSettlementSummary], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("network_settlement_summary") - @ExcludeMissing - fun _networkSettlementSummary(): JsonField> = - networkSettlementSummary - - /** - * Returns the raw JSON value of [previousHighWatermark]. - * - * Unlike [previousHighWatermark], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("previous_high_watermark") - @ExcludeMissing - fun _previousHighWatermark(): JsonField = previousHighWatermark - - /** - * Returns the raw JSON value of [updated]. - * - * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [FundingEventRetrieveResponse]. - * - * The following fields are required: - * ```java - * .token() - * .collectionResourceType() - * .collectionTokens() - * .created() - * .highWatermark() - * .networkSettlementSummary() - * .previousHighWatermark() - * .updated() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FundingEventRetrieveResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var collectionResourceType: JsonField? = null - private var collectionTokens: JsonField>? = null - private var created: JsonField? = null - private var highWatermark: JsonField? = null - private var networkSettlementSummary: JsonField>? = null - private var previousHighWatermark: JsonField? = null - private var updated: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fundingEventRetrieveResponse: FundingEventRetrieveResponse) = apply { - token = fundingEventRetrieveResponse.token - collectionResourceType = fundingEventRetrieveResponse.collectionResourceType - collectionTokens = - fundingEventRetrieveResponse.collectionTokens.map { it.toMutableList() } - created = fundingEventRetrieveResponse.created - highWatermark = fundingEventRetrieveResponse.highWatermark - networkSettlementSummary = - fundingEventRetrieveResponse.networkSettlementSummary.map { it.toMutableList() } - previousHighWatermark = fundingEventRetrieveResponse.previousHighWatermark - updated = fundingEventRetrieveResponse.updated - additionalProperties = fundingEventRetrieveResponse.additionalProperties.toMutableMap() - } - - /** Unique token ID */ - 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 } - - /** Collection resource type */ - fun collectionResourceType(collectionResourceType: CollectionResourceType) = - collectionResourceType(JsonField.of(collectionResourceType)) - - /** - * Sets [Builder.collectionResourceType] to an arbitrary JSON value. - * - * You should usually call [Builder.collectionResourceType] with a well-typed - * [CollectionResourceType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun collectionResourceType(collectionResourceType: JsonField) = - apply { - this.collectionResourceType = collectionResourceType - } - - /** - * IDs of collections, further information can be gathered from the appropriate collection - * API based on collection_resource_type - */ - fun collectionTokens(collectionTokens: List) = - collectionTokens(JsonField.of(collectionTokens)) - - /** - * Sets [Builder.collectionTokens] to an arbitrary JSON value. - * - * You should usually call [Builder.collectionTokens] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun collectionTokens(collectionTokens: JsonField>) = apply { - this.collectionTokens = collectionTokens.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [collectionTokens]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCollectionToken(collectionToken: String) = apply { - collectionTokens = - (collectionTokens ?: JsonField.of(mutableListOf())).also { - checkKnown("collectionTokens", it).add(collectionToken) - } - } - - /** Time of the creation */ - 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 } - - /** Time of the high watermark */ - fun highWatermark(highWatermark: OffsetDateTime) = - highWatermark(JsonField.of(highWatermark)) - - /** - * Sets [Builder.highWatermark] to an arbitrary JSON value. - * - * You should usually call [Builder.highWatermark] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun highWatermark(highWatermark: JsonField) = apply { - this.highWatermark = highWatermark - } - - /** Network settlement summary breakdown by network settlement date */ - fun networkSettlementSummary(networkSettlementSummary: List) = - networkSettlementSummary(JsonField.of(networkSettlementSummary)) - - /** - * Sets [Builder.networkSettlementSummary] to an arbitrary JSON value. - * - * You should usually call [Builder.networkSettlementSummary] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun networkSettlementSummary( - networkSettlementSummary: JsonField> - ) = apply { - this.networkSettlementSummary = networkSettlementSummary.map { it.toMutableList() } - } - - /** - * Adds a single [FundingEventSettlement] to [Builder.networkSettlementSummary]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addNetworkSettlementSummary(networkSettlementSummary: FundingEventSettlement) = apply { - this.networkSettlementSummary = - (this.networkSettlementSummary ?: JsonField.of(mutableListOf())).also { - checkKnown("networkSettlementSummary", it).add(networkSettlementSummary) - } - } - - /** Time of the previous high watermark */ - fun previousHighWatermark(previousHighWatermark: OffsetDateTime) = - previousHighWatermark(JsonField.of(previousHighWatermark)) - - /** - * Sets [Builder.previousHighWatermark] to an arbitrary JSON value. - * - * You should usually call [Builder.previousHighWatermark] with a well-typed - * [OffsetDateTime] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun previousHighWatermark(previousHighWatermark: JsonField) = apply { - this.previousHighWatermark = previousHighWatermark - } - - /** Time of the update */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) - - /** - * Sets [Builder.updated] to an arbitrary JSON value. - * - * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun updated(updated: JsonField) = apply { this.updated = updated } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [FundingEventRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .collectionResourceType() - * .collectionTokens() - * .created() - * .highWatermark() - * .networkSettlementSummary() - * .previousHighWatermark() - * .updated() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): FundingEventRetrieveResponse = - FundingEventRetrieveResponse( - checkRequired("token", token), - checkRequired("collectionResourceType", collectionResourceType), - checkRequired("collectionTokens", collectionTokens).map { it.toImmutable() }, - checkRequired("created", created), - checkRequired("highWatermark", highWatermark), - checkRequired("networkSettlementSummary", networkSettlementSummary).map { - it.toImmutable() - }, - checkRequired("previousHighWatermark", previousHighWatermark), - checkRequired("updated", updated), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): FundingEventRetrieveResponse = apply { - if (validated) { - return@apply - } - - token() - collectionResourceType().validate() - collectionTokens() - created() - highWatermark() - networkSettlementSummary().forEach { it.validate() } - previousHighWatermark() - updated() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (token.asKnown().isPresent) 1 else 0) + - (collectionResourceType.asKnown().getOrNull()?.validity() ?: 0) + - (collectionTokens.asKnown().getOrNull()?.size ?: 0) + - (if (created.asKnown().isPresent) 1 else 0) + - (if (highWatermark.asKnown().isPresent) 1 else 0) + - (networkSettlementSummary.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (previousHighWatermark.asKnown().isPresent) 1 else 0) + - (if (updated.asKnown().isPresent) 1 else 0) - - /** Collection resource type */ - class CollectionResourceType - @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 BOOK_TRANSFER = of("BOOK_TRANSFER") - - @JvmField val PAYMENT = of("PAYMENT") - - @JvmStatic fun of(value: String) = CollectionResourceType(JsonField.of(value)) - } - - /** An enum containing [CollectionResourceType]'s known values. */ - enum class Known { - BOOK_TRANSFER, - PAYMENT, - } - - /** - * An enum containing [CollectionResourceType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [CollectionResourceType] 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 { - BOOK_TRANSFER, - PAYMENT, - /** - * An enum member indicating that [CollectionResourceType] 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) { - BOOK_TRANSFER -> Value.BOOK_TRANSFER - PAYMENT -> Value.PAYMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws LithicInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BOOK_TRANSFER -> Known.BOOK_TRANSFER - PAYMENT -> Known.PAYMENT - else -> throw LithicInvalidDataException("Unknown CollectionResourceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): CollectionResourceType = 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 CollectionResourceType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class FundingEventSettlement - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val networkSettlementDate: JsonField, - private val settledGrossAmount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("network_settlement_date") - @ExcludeMissing - networkSettlementDate: JsonField = JsonMissing.of(), - @JsonProperty("settled_gross_amount") - @ExcludeMissing - settledGrossAmount: JsonField = JsonMissing.of(), - ) : this(networkSettlementDate, settledGrossAmount, 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 networkSettlementDate(): LocalDate = - networkSettlementDate.getRequired("network_settlement_date") - - /** - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun settledGrossAmount(): Long = settledGrossAmount.getRequired("settled_gross_amount") - - /** - * Returns the raw JSON value of [networkSettlementDate]. - * - * Unlike [networkSettlementDate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("network_settlement_date") - @ExcludeMissing - fun _networkSettlementDate(): JsonField = networkSettlementDate - - /** - * Returns the raw JSON value of [settledGrossAmount]. - * - * Unlike [settledGrossAmount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("settled_gross_amount") - @ExcludeMissing - fun _settledGrossAmount(): JsonField = settledGrossAmount - - @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 [FundingEventSettlement]. - * - * The following fields are required: - * ```java - * .networkSettlementDate() - * .settledGrossAmount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [FundingEventSettlement]. */ - class Builder internal constructor() { - - private var networkSettlementDate: JsonField? = null - private var settledGrossAmount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(fundingEventSettlement: FundingEventSettlement) = apply { - networkSettlementDate = fundingEventSettlement.networkSettlementDate - settledGrossAmount = fundingEventSettlement.settledGrossAmount - additionalProperties = fundingEventSettlement.additionalProperties.toMutableMap() - } - - fun networkSettlementDate(networkSettlementDate: LocalDate) = - networkSettlementDate(JsonField.of(networkSettlementDate)) - - /** - * Sets [Builder.networkSettlementDate] to an arbitrary JSON value. - * - * You should usually call [Builder.networkSettlementDate] with a well-typed [LocalDate] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun networkSettlementDate(networkSettlementDate: JsonField) = apply { - this.networkSettlementDate = networkSettlementDate - } - - fun settledGrossAmount(settledGrossAmount: Long) = - settledGrossAmount(JsonField.of(settledGrossAmount)) - - /** - * Sets [Builder.settledGrossAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.settledGrossAmount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun settledGrossAmount(settledGrossAmount: JsonField) = apply { - this.settledGrossAmount = settledGrossAmount - } - - 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 [FundingEventSettlement]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .networkSettlementDate() - * .settledGrossAmount() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): FundingEventSettlement = - FundingEventSettlement( - checkRequired("networkSettlementDate", networkSettlementDate), - checkRequired("settledGrossAmount", settledGrossAmount), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): FundingEventSettlement = apply { - if (validated) { - return@apply - } - - networkSettlementDate() - settledGrossAmount() - 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 (networkSettlementDate.asKnown().isPresent) 1 else 0) + - (if (settledGrossAmount.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FundingEventSettlement && - networkSettlementDate == other.networkSettlementDate && - settledGrossAmount == other.settledGrossAmount && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(networkSettlementDate, settledGrossAmount, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FundingEventSettlement{networkSettlementDate=$networkSettlementDate, settledGrossAmount=$settledGrossAmount, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FundingEventRetrieveResponse && - token == other.token && - collectionResourceType == other.collectionResourceType && - collectionTokens == other.collectionTokens && - created == other.created && - highWatermark == other.highWatermark && - networkSettlementSummary == other.networkSettlementSummary && - previousHighWatermark == other.previousHighWatermark && - updated == other.updated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - collectionResourceType, - collectionTokens, - created, - highWatermark, - networkSettlementSummary, - previousHighWatermark, - updated, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "FundingEventRetrieveResponse{token=$token, collectionResourceType=$collectionResourceType, collectionTokens=$collectionTokens, created=$created, highWatermark=$highWatermark, networkSettlementSummary=$networkSettlementSummary, previousHighWatermark=$previousHighWatermark, updated=$updated, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransaction.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransaction.kt new file mode 100644 index 000000000..ca7c7903a --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransaction.kt @@ -0,0 +1,1539 @@ +// 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 kotlin.jvm.optionals.getOrNull + +class InternalTransaction +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val descriptor: JsonField, + private val events: JsonField>, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") @ExcludeMissing category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + descriptor, + events, + pendingAmount, + result, + settledAmount, + status, + updated, + 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 token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): Category = category.getRequired("category") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun 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 currency(): String = currency.getRequired("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 descriptor(): String = descriptor.getRequired("descriptor") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): TransactionResult = result.getRequired("result") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): TransactionStatus = status.getRequired("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InternalTransaction]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalTransaction]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var events: JsonField>? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(internalTransaction: InternalTransaction) = apply { + token = internalTransaction.token + category = internalTransaction.category + created = internalTransaction.created + currency = internalTransaction.currency + descriptor = internalTransaction.descriptor + events = internalTransaction.events.map { it.toMutableList() } + pendingAmount = internalTransaction.pendingAmount + result = internalTransaction.result + settledAmount = internalTransaction.settledAmount + status = internalTransaction.status + updated = internalTransaction.updated + additionalProperties = internalTransaction.additionalProperties.toMutableMap() + } + + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun category(category: Category) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [Category] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun category(category: JsonField) = apply { this.category = category } + + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun 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 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 } + + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [InternalAdjustmentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: InternalAdjustmentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [TransactionResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + fun status(status: TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [TransactionStatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InternalTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalTransaction = + InternalTransaction( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("descriptor", descriptor), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("updated", updated), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InternalTransaction = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + descriptor() + events().forEach { it.validate() } + pendingAmount() + result().validate() + settledAmount() + status().validate() + updated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + class Category @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val INTERNAL = of("INTERNAL") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + INTERNAL + } + + /** + * An enum containing [Category]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Category] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INTERNAL, + /** An enum member indicating that [Category] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INTERNAL -> Value.INTERNAL + 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) { + INTERNAL -> Known.INTERNAL + else -> throw LithicInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Category = 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 Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class InternalAdjustmentEvent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val amount: JsonField, + private val created: JsonField, + private val result: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(token, amount, created, result, type, mutableMapOf()) + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amount(): Long = amount.getRequired("amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun 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 result(): TransactionResult = result.getRequired("result") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = 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 [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 [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 [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [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 [InternalAdjustmentEvent]. + * + * The following fields are required: + * ```java + * .token() + * .amount() + * .created() + * .result() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalAdjustmentEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var amount: JsonField? = null + private var created: JsonField? = null + private var result: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(internalAdjustmentEvent: InternalAdjustmentEvent) = apply { + token = internalAdjustmentEvent.token + amount = internalAdjustmentEvent.amount + created = internalAdjustmentEvent.created + result = internalAdjustmentEvent.result + type = internalAdjustmentEvent.type + additionalProperties = internalAdjustmentEvent.additionalProperties.toMutableMap() + } + + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun 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 } + + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun result(result: TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [TransactionResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InternalAdjustmentEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .amount() + * .created() + * .result() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalAdjustmentEvent = + InternalAdjustmentEvent( + checkRequired("token", token), + checkRequired("amount", amount), + checkRequired("created", created), + checkRequired("result", result), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InternalAdjustmentEvent = apply { + if (validated) { + return@apply + } + + token() + amount() + created() + result().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 (amount.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class TransactionResult + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TransactionResult] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + 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 INTERNAL_ADJUSTMENT = of("INTERNAL_ADJUSTMENT") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + INTERNAL_ADJUSTMENT + } + + /** + * 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 { + INTERNAL_ADJUSTMENT, + /** 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) { + INTERNAL_ADJUSTMENT -> Value.INTERNAL_ADJUSTMENT + 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) { + INTERNAL_ADJUSTMENT -> Known.INTERNAL_ADJUSTMENT + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 InternalAdjustmentEvent && + token == other.token && + amount == other.amount && + created == other.created && + result == other.result && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(token, amount, created, result, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InternalAdjustmentEvent{token=$token, amount=$amount, created=$created, result=$result, type=$type, additionalProperties=$additionalProperties}" + } + + class TransactionResult @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmStatic fun of(value: String) = TransactionResult(JsonField.of(value)) + } + + /** An enum containing [TransactionResult]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + } + + /** + * An enum containing [TransactionResult]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TransactionResult] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPROVED, + DECLINED, + /** + * An enum member indicating that [TransactionResult] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + else -> throw LithicInvalidDataException("Unknown TransactionResult: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TransactionResult = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionResult && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TransactionStatus @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("PENDING") + + @JvmField val SETTLED = of("SETTLED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REVERSED = of("REVERSED") + + @JvmField val CANCELED = of("CANCELED") + + @JvmField val RETURNED = of("RETURNED") + + @JvmStatic fun of(value: String) = TransactionStatus(JsonField.of(value)) + } + + /** An enum containing [TransactionStatus]'s known values. */ + enum class Known { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + RETURNED, + } + + /** + * An enum containing [TransactionStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TransactionStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + SETTLED, + DECLINED, + REVERSED, + CANCELED, + RETURNED, + /** + * An enum member indicating that [TransactionStatus] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + SETTLED -> Value.SETTLED + DECLINED -> Value.DECLINED + REVERSED -> Value.REVERSED + CANCELED -> Value.CANCELED + RETURNED -> Value.RETURNED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + SETTLED -> Known.SETTLED + DECLINED -> Known.DECLINED + REVERSED -> Known.REVERSED + CANCELED -> Known.CANCELED + RETURNED -> Known.RETURNED + else -> throw LithicInvalidDataException("Unknown TransactionStatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TransactionStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InternalTransaction && + token == other.token && + category == other.category && + created == other.created && + currency == other.currency && + descriptor == other.descriptor && + events == other.events && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + status == other.status && + updated == other.updated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + currency, + descriptor, + events, + pendingAmount, + result, + settledAmount, + status, + updated, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InternalTransaction{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, events=$events, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, updated=$updated, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotal.kt similarity index 96% rename from lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalListResponse.kt rename to lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotal.kt index fdf024340..2fe079c17 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalListResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotal.kt @@ -20,7 +20,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class NetworkTotalListResponse +class NetworkTotal @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, @@ -289,7 +289,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NetworkTotalListResponse]. + * Returns a mutable builder for constructing an instance of [NetworkTotal]. * * The following fields are required: * ```java @@ -309,7 +309,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NetworkTotalListResponse]. */ + /** A builder for [NetworkTotal]. */ class Builder internal constructor() { private var token: JsonField? = null @@ -327,20 +327,20 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(networkTotalListResponse: NetworkTotalListResponse) = apply { - token = networkTotalListResponse.token - amounts = networkTotalListResponse.amounts - created = networkTotalListResponse.created - currency = networkTotalListResponse.currency - institutionId = networkTotalListResponse.institutionId - isComplete = networkTotalListResponse.isComplete - network = networkTotalListResponse.network - reportDate = networkTotalListResponse.reportDate - settlementInstitutionId = networkTotalListResponse.settlementInstitutionId - settlementService = networkTotalListResponse.settlementService - updated = networkTotalListResponse.updated - cycle = networkTotalListResponse.cycle - additionalProperties = networkTotalListResponse.additionalProperties.toMutableMap() + internal fun from(networkTotal: NetworkTotal) = apply { + token = networkTotal.token + amounts = networkTotal.amounts + created = networkTotal.created + currency = networkTotal.currency + institutionId = networkTotal.institutionId + isComplete = networkTotal.isComplete + network = networkTotal.network + reportDate = networkTotal.reportDate + settlementInstitutionId = networkTotal.settlementInstitutionId + settlementService = networkTotal.settlementService + updated = networkTotal.updated + cycle = networkTotal.cycle + additionalProperties = networkTotal.additionalProperties.toMutableMap() } /** Globally unique identifier. */ @@ -522,7 +522,7 @@ private constructor( } /** - * Returns an immutable instance of [NetworkTotalListResponse]. + * Returns an immutable instance of [NetworkTotal]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -543,8 +543,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): NetworkTotalListResponse = - NetworkTotalListResponse( + fun build(): NetworkTotal = + NetworkTotal( checkRequired("token", token), checkRequired("amounts", amounts), checkRequired("created", created), @@ -563,7 +563,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NetworkTotalListResponse = apply { + fun validate(): NetworkTotal = apply { if (validated) { return@apply } @@ -1071,7 +1071,7 @@ private constructor( return true } - return other is NetworkTotalListResponse && + return other is NetworkTotal && token == other.token && amounts == other.amounts && created == other.created && @@ -1108,5 +1108,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NetworkTotalListResponse{token=$token, amounts=$amounts, created=$created, currency=$currency, institutionId=$institutionId, isComplete=$isComplete, network=$network, reportDate=$reportDate, settlementInstitutionId=$settlementInstitutionId, settlementService=$settlementService, updated=$updated, cycle=$cycle, additionalProperties=$additionalProperties}" + "NetworkTotal{token=$token, amounts=$amounts, created=$created, currency=$currency, institutionId=$institutionId, isComplete=$isComplete, network=$network, reportDate=$reportDate, settlementInstitutionId=$settlementInstitutionId, settlementService=$settlementService, updated=$updated, cycle=$cycle, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalRetrieveResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalRetrieveResponse.kt deleted file mode 100644 index 3a9660a5e..000000000 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalRetrieveResponse.kt +++ /dev/null @@ -1,1112 +0,0 @@ -// 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.LocalDate -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class NetworkTotalRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val amounts: JsonField, - private val created: JsonField, - private val currency: JsonField, - private val institutionId: JsonField, - private val isComplete: JsonField, - private val network: JsonField, - private val reportDate: JsonField, - private val settlementInstitutionId: JsonField, - private val settlementService: JsonField, - private val updated: JsonField, - private val cycle: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("amounts") @ExcludeMissing amounts: JsonField = JsonMissing.of(), - @JsonProperty("created") - @ExcludeMissing - created: JsonField = JsonMissing.of(), - @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), - @JsonProperty("institution_id") - @ExcludeMissing - institutionId: JsonField = JsonMissing.of(), - @JsonProperty("is_complete") - @ExcludeMissing - isComplete: JsonField = JsonMissing.of(), - @JsonProperty("network") @ExcludeMissing network: JsonField = JsonMissing.of(), - @JsonProperty("report_date") - @ExcludeMissing - reportDate: JsonField = JsonMissing.of(), - @JsonProperty("settlement_institution_id") - @ExcludeMissing - settlementInstitutionId: JsonField = JsonMissing.of(), - @JsonProperty("settlement_service") - @ExcludeMissing - settlementService: JsonField = JsonMissing.of(), - @JsonProperty("updated") - @ExcludeMissing - updated: JsonField = JsonMissing.of(), - @JsonProperty("cycle") @ExcludeMissing cycle: JsonField = JsonMissing.of(), - ) : this( - token, - amounts, - created, - currency, - institutionId, - isComplete, - network, - reportDate, - settlementInstitutionId, - settlementService, - updated, - cycle, - mutableMapOf(), - ) - - /** - * Globally unique identifier. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun token(): String = token.getRequired("token") - - /** - * @throws LithicInvalidDataException if 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") - - /** - * RFC 3339 timestamp for when the record was created. UTC time zone. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun created(): OffsetDateTime = created.getRequired("created") - - /** - * 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") - - /** - * The institution that activity occurred on. For Mastercard: ICA (Interbank Card Association). - * For Maestro: institution ID. For Visa: lowest level SRE (Settlement Reporting Entity). - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun institutionId(): String = institutionId.getRequired("institution_id") - - /** - * Indicates that all settlement records related to this Network Total are available in the - * details 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 isComplete(): Boolean = isComplete.getRequired("is_complete") - - /** - * Card network where the transaction took place. AMEX, VISA, MASTERCARD, MAESTRO, or INTERLINK. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun network(): Network = network.getRequired("network") - - /** - * Date that the network total record applies to. YYYY-MM-DD format. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun reportDate(): LocalDate = reportDate.getRequired("report_date") - - /** - * The institution responsible for settlement. For Mastercard: same as `institution_id`. For - * Maestro: billing ICA. For Visa: Funds Transfer SRE (FTSRE). - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun settlementInstitutionId(): String = - settlementInstitutionId.getRequired("settlement_institution_id") - - /** - * Settlement service. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun settlementService(): String = settlementService.getRequired("settlement_service") - - /** - * RFC 3339 timestamp for when the record was last updated. UTC time zone. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updated(): OffsetDateTime = updated.getRequired("updated") - - /** - * The clearing cycle that the network total record applies to. Mastercard only. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun cycle(): Optional = cycle.getOptional("cycle") - - /** - * 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 [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 [created]. - * - * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [institutionId]. - * - * Unlike [institutionId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("institution_id") - @ExcludeMissing - fun _institutionId(): JsonField = institutionId - - /** - * Returns the raw JSON value of [isComplete]. - * - * Unlike [isComplete], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("is_complete") @ExcludeMissing fun _isComplete(): JsonField = isComplete - - /** - * 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 [reportDate]. - * - * Unlike [reportDate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("report_date") - @ExcludeMissing - fun _reportDate(): JsonField = reportDate - - /** - * Returns the raw JSON value of [settlementInstitutionId]. - * - * Unlike [settlementInstitutionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("settlement_institution_id") - @ExcludeMissing - fun _settlementInstitutionId(): JsonField = settlementInstitutionId - - /** - * Returns the raw JSON value of [settlementService]. - * - * Unlike [settlementService], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("settlement_service") - @ExcludeMissing - fun _settlementService(): JsonField = settlementService - - /** - * Returns the raw JSON value of [updated]. - * - * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - - /** - * Returns the raw JSON value of [cycle]. - * - * Unlike [cycle], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cycle") @ExcludeMissing fun _cycle(): JsonField = cycle - - @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 [NetworkTotalRetrieveResponse]. - * - * The following fields are required: - * ```java - * .token() - * .amounts() - * .created() - * .currency() - * .institutionId() - * .isComplete() - * .network() - * .reportDate() - * .settlementInstitutionId() - * .settlementService() - * .updated() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NetworkTotalRetrieveResponse]. */ - class Builder internal constructor() { - - private var token: JsonField? = null - private var amounts: JsonField? = null - private var created: JsonField? = null - private var currency: JsonField? = null - private var institutionId: JsonField? = null - private var isComplete: JsonField? = null - private var network: JsonField? = null - private var reportDate: JsonField? = null - private var settlementInstitutionId: JsonField? = null - private var settlementService: JsonField? = null - private var updated: JsonField? = null - private var cycle: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(networkTotalRetrieveResponse: NetworkTotalRetrieveResponse) = apply { - token = networkTotalRetrieveResponse.token - amounts = networkTotalRetrieveResponse.amounts - created = networkTotalRetrieveResponse.created - currency = networkTotalRetrieveResponse.currency - institutionId = networkTotalRetrieveResponse.institutionId - isComplete = networkTotalRetrieveResponse.isComplete - network = networkTotalRetrieveResponse.network - reportDate = networkTotalRetrieveResponse.reportDate - settlementInstitutionId = networkTotalRetrieveResponse.settlementInstitutionId - settlementService = networkTotalRetrieveResponse.settlementService - updated = networkTotalRetrieveResponse.updated - cycle = networkTotalRetrieveResponse.cycle - additionalProperties = networkTotalRetrieveResponse.additionalProperties.toMutableMap() - } - - /** Globally unique identifier. */ - fun token(token: String) = token(JsonField.of(token)) - - /** - * Sets [Builder.token] to an arbitrary JSON value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun token(token: JsonField) = apply { this.token = token } - - 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 } - - /** RFC 3339 timestamp for when the record was created. UTC time zone. */ - fun created(created: OffsetDateTime) = created(JsonField.of(created)) - - /** - * Sets [Builder.created] to an arbitrary JSON value. - * - * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun created(created: JsonField) = apply { this.created = created } - - /** 3-character alphabetic ISO 4217 code. */ - 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 } - - /** - * The institution that activity occurred on. For Mastercard: ICA (Interbank Card - * Association). For Maestro: institution ID. For Visa: lowest level SRE (Settlement - * Reporting Entity). - */ - fun institutionId(institutionId: String) = institutionId(JsonField.of(institutionId)) - - /** - * Sets [Builder.institutionId] to an arbitrary JSON value. - * - * You should usually call [Builder.institutionId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun institutionId(institutionId: JsonField) = apply { - this.institutionId = institutionId - } - - /** - * Indicates that all settlement records related to this Network Total are available in the - * details endpoint. - */ - fun isComplete(isComplete: Boolean) = isComplete(JsonField.of(isComplete)) - - /** - * Sets [Builder.isComplete] to an arbitrary JSON value. - * - * You should usually call [Builder.isComplete] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun isComplete(isComplete: JsonField) = apply { this.isComplete = isComplete } - - /** - * Card network where the transaction took place. AMEX, VISA, MASTERCARD, MAESTRO, or - * INTERLINK. - */ - 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 } - - /** Date that the network total record applies to. YYYY-MM-DD format. */ - fun reportDate(reportDate: LocalDate) = reportDate(JsonField.of(reportDate)) - - /** - * Sets [Builder.reportDate] to an arbitrary JSON value. - * - * You should usually call [Builder.reportDate] with a well-typed [LocalDate] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun reportDate(reportDate: JsonField) = apply { this.reportDate = reportDate } - - /** - * The institution responsible for settlement. For Mastercard: same as `institution_id`. For - * Maestro: billing ICA. For Visa: Funds Transfer SRE (FTSRE). - */ - fun settlementInstitutionId(settlementInstitutionId: String) = - settlementInstitutionId(JsonField.of(settlementInstitutionId)) - - /** - * Sets [Builder.settlementInstitutionId] to an arbitrary JSON value. - * - * You should usually call [Builder.settlementInstitutionId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun settlementInstitutionId(settlementInstitutionId: JsonField) = apply { - this.settlementInstitutionId = settlementInstitutionId - } - - /** Settlement service. */ - fun settlementService(settlementService: String) = - settlementService(JsonField.of(settlementService)) - - /** - * Sets [Builder.settlementService] to an arbitrary JSON value. - * - * You should usually call [Builder.settlementService] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun settlementService(settlementService: JsonField) = apply { - this.settlementService = settlementService - } - - /** RFC 3339 timestamp for when the record was last updated. UTC time zone. */ - fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) - - /** - * Sets [Builder.updated] to an arbitrary JSON value. - * - * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun updated(updated: JsonField) = apply { this.updated = updated } - - /** The clearing cycle that the network total record applies to. Mastercard only. */ - fun cycle(cycle: Long) = cycle(JsonField.of(cycle)) - - /** - * Sets [Builder.cycle] to an arbitrary JSON value. - * - * You should usually call [Builder.cycle] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cycle(cycle: JsonField) = apply { this.cycle = cycle } - - 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 [NetworkTotalRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .token() - * .amounts() - * .created() - * .currency() - * .institutionId() - * .isComplete() - * .network() - * .reportDate() - * .settlementInstitutionId() - * .settlementService() - * .updated() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NetworkTotalRetrieveResponse = - NetworkTotalRetrieveResponse( - checkRequired("token", token), - checkRequired("amounts", amounts), - checkRequired("created", created), - checkRequired("currency", currency), - checkRequired("institutionId", institutionId), - checkRequired("isComplete", isComplete), - checkRequired("network", network), - checkRequired("reportDate", reportDate), - checkRequired("settlementInstitutionId", settlementInstitutionId), - checkRequired("settlementService", settlementService), - checkRequired("updated", updated), - cycle, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NetworkTotalRetrieveResponse = apply { - if (validated) { - return@apply - } - - token() - amounts().validate() - created() - currency() - institutionId() - isComplete() - network().validate() - reportDate() - settlementInstitutionId() - settlementService() - updated() - cycle() - 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) + - (amounts.asKnown().getOrNull()?.validity() ?: 0) + - (if (created.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (institutionId.asKnown().isPresent) 1 else 0) + - (if (isComplete.asKnown().isPresent) 1 else 0) + - (network.asKnown().getOrNull()?.validity() ?: 0) + - (if (reportDate.asKnown().isPresent) 1 else 0) + - (if (settlementInstitutionId.asKnown().isPresent) 1 else 0) + - (if (settlementService.asKnown().isPresent) 1 else 0) + - (if (updated.asKnown().isPresent) 1 else 0) + - (if (cycle.asKnown().isPresent) 1 else 0) - - class Amounts - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val grossSettlement: JsonField, - private val interchangeFees: JsonField, - private val netSettlement: JsonField, - private val visaCharges: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("gross_settlement") - @ExcludeMissing - grossSettlement: JsonField = JsonMissing.of(), - @JsonProperty("interchange_fees") - @ExcludeMissing - interchangeFees: JsonField = JsonMissing.of(), - @JsonProperty("net_settlement") - @ExcludeMissing - netSettlement: JsonField = JsonMissing.of(), - @JsonProperty("visa_charges") - @ExcludeMissing - visaCharges: JsonField = JsonMissing.of(), - ) : this(grossSettlement, interchangeFees, netSettlement, visaCharges, mutableMapOf()) - - /** - * Total settlement amount excluding interchange, in currency's smallest unit. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun grossSettlement(): Long = grossSettlement.getRequired("gross_settlement") - - /** - * Interchange amount, in currency's smallest unit. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun interchangeFees(): Long = interchangeFees.getRequired("interchange_fees") - - /** - * `gross_settlement` net of `interchange_fees` and `visa_charges` (if applicable), in - * currency's smallest unit. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun netSettlement(): Long = netSettlement.getRequired("net_settlement") - - /** - * Charges specific to Visa/Interlink, in currency's smallest unit. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun visaCharges(): Optional = visaCharges.getOptional("visa_charges") - - /** - * Returns the raw JSON value of [grossSettlement]. - * - * Unlike [grossSettlement], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("gross_settlement") - @ExcludeMissing - fun _grossSettlement(): JsonField = grossSettlement - - /** - * Returns the raw JSON value of [interchangeFees]. - * - * Unlike [interchangeFees], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("interchange_fees") - @ExcludeMissing - fun _interchangeFees(): JsonField = interchangeFees - - /** - * Returns the raw JSON value of [netSettlement]. - * - * Unlike [netSettlement], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("net_settlement") - @ExcludeMissing - fun _netSettlement(): JsonField = netSettlement - - /** - * Returns the raw JSON value of [visaCharges]. - * - * Unlike [visaCharges], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("visa_charges") - @ExcludeMissing - fun _visaCharges(): JsonField = visaCharges - - @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 - * .grossSettlement() - * .interchangeFees() - * .netSettlement() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Amounts]. */ - class Builder internal constructor() { - - private var grossSettlement: JsonField? = null - private var interchangeFees: JsonField? = null - private var netSettlement: JsonField? = null - private var visaCharges: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(amounts: Amounts) = apply { - grossSettlement = amounts.grossSettlement - interchangeFees = amounts.interchangeFees - netSettlement = amounts.netSettlement - visaCharges = amounts.visaCharges - additionalProperties = amounts.additionalProperties.toMutableMap() - } - - /** Total settlement amount excluding interchange, in currency's smallest unit. */ - fun grossSettlement(grossSettlement: Long) = - grossSettlement(JsonField.of(grossSettlement)) - - /** - * Sets [Builder.grossSettlement] to an arbitrary JSON value. - * - * You should usually call [Builder.grossSettlement] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun grossSettlement(grossSettlement: JsonField) = apply { - this.grossSettlement = grossSettlement - } - - /** Interchange amount, in currency's smallest unit. */ - fun interchangeFees(interchangeFees: Long) = - interchangeFees(JsonField.of(interchangeFees)) - - /** - * Sets [Builder.interchangeFees] to an arbitrary JSON value. - * - * You should usually call [Builder.interchangeFees] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun interchangeFees(interchangeFees: JsonField) = apply { - this.interchangeFees = interchangeFees - } - - /** - * `gross_settlement` net of `interchange_fees` and `visa_charges` (if applicable), in - * currency's smallest unit. - */ - fun netSettlement(netSettlement: Long) = netSettlement(JsonField.of(netSettlement)) - - /** - * Sets [Builder.netSettlement] to an arbitrary JSON value. - * - * You should usually call [Builder.netSettlement] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun netSettlement(netSettlement: JsonField) = apply { - this.netSettlement = netSettlement - } - - /** Charges specific to Visa/Interlink, in currency's smallest unit. */ - fun visaCharges(visaCharges: Long) = visaCharges(JsonField.of(visaCharges)) - - /** - * Sets [Builder.visaCharges] to an arbitrary JSON value. - * - * You should usually call [Builder.visaCharges] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun visaCharges(visaCharges: JsonField) = apply { this.visaCharges = visaCharges } - - 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 - * .grossSettlement() - * .interchangeFees() - * .netSettlement() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Amounts = - Amounts( - checkRequired("grossSettlement", grossSettlement), - checkRequired("interchangeFees", interchangeFees), - checkRequired("netSettlement", netSettlement), - visaCharges, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Amounts = apply { - if (validated) { - return@apply - } - - grossSettlement() - interchangeFees() - netSettlement() - visaCharges() - 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 (grossSettlement.asKnown().isPresent) 1 else 0) + - (if (interchangeFees.asKnown().isPresent) 1 else 0) + - (if (netSettlement.asKnown().isPresent) 1 else 0) + - (if (visaCharges.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Amounts && - grossSettlement == other.grossSettlement && - interchangeFees == other.interchangeFees && - netSettlement == other.netSettlement && - visaCharges == other.visaCharges && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - grossSettlement, - interchangeFees, - netSettlement, - visaCharges, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Amounts{grossSettlement=$grossSettlement, interchangeFees=$interchangeFees, netSettlement=$netSettlement, visaCharges=$visaCharges, additionalProperties=$additionalProperties}" - } - - /** - * Card network where the transaction took place. AMEX, VISA, MASTERCARD, MAESTRO, or INTERLINK. - */ - 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 VISA = of("VISA") - - @JvmField val MASTERCARD = of("MASTERCARD") - - @JvmField val MAESTRO = of("MAESTRO") - - @JvmField val INTERLINK = of("INTERLINK") - - @JvmStatic fun of(value: String) = Network(JsonField.of(value)) - } - - /** An enum containing [Network]'s known values. */ - enum class Known { - AMEX, - VISA, - MASTERCARD, - MAESTRO, - INTERLINK, - } - - /** - * 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, - VISA, - MASTERCARD, - MAESTRO, - INTERLINK, - /** 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 - VISA -> Value.VISA - MASTERCARD -> Value.MASTERCARD - MAESTRO -> Value.MAESTRO - INTERLINK -> Value.INTERLINK - 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 - VISA -> Known.VISA - MASTERCARD -> Known.MASTERCARD - MAESTRO -> Known.MAESTRO - INTERLINK -> Known.INTERLINK - 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 - - 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() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NetworkTotalRetrieveResponse && - token == other.token && - amounts == other.amounts && - created == other.created && - currency == other.currency && - institutionId == other.institutionId && - isComplete == other.isComplete && - network == other.network && - reportDate == other.reportDate && - settlementInstitutionId == other.settlementInstitutionId && - settlementService == other.settlementService && - updated == other.updated && - cycle == other.cycle && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - token, - amounts, - created, - currency, - institutionId, - isComplete, - network, - reportDate, - settlementInstitutionId, - settlementService, - updated, - cycle, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NetworkTotalRetrieveResponse{token=$token, amounts=$amounts, created=$created, currency=$currency, institutionId=$institutionId, isComplete=$isComplete, network=$network, reportDate=$reportDate, settlementInstitutionId=$settlementInstitutionId, settlementService=$settlementService, updated=$updated, cycle=$cycle, additionalProperties=$additionalProperties}" -} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NonPciCard.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NonPciCard.kt index 89b60bde9..c9a3056f7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NonPciCard.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NonPciCard.kt @@ -37,6 +37,7 @@ private constructor( private val state: JsonField, private val type: JsonField, private val authRuleTokens: JsonField>, + private val bulkOrderToken: JsonField, private val cardholderCurrency: JsonField, private val comment: JsonField, private val digitalCardArtToken: JsonField, @@ -80,6 +81,9 @@ private constructor( @JsonProperty("auth_rule_tokens") @ExcludeMissing authRuleTokens: JsonField> = JsonMissing.of(), + @JsonProperty("bulk_order_token") + @ExcludeMissing + bulkOrderToken: JsonField = JsonMissing.of(), @JsonProperty("cardholder_currency") @ExcludeMissing cardholderCurrency: JsonField = JsonMissing.of(), @@ -117,6 +121,7 @@ private constructor( state, type, authRuleTokens, + bulkOrderToken, cardholderCurrency, comment, digitalCardArtToken, @@ -260,6 +265,15 @@ private constructor( @Deprecated("deprecated") fun authRuleTokens(): Optional> = authRuleTokens.getOptional("auth_rule_tokens") + /** + * Globally unique identifier for the bulk order associated with this card. Only applicable to + * physical cards that are part of a bulk shipment + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bulkOrderToken(): Optional = bulkOrderToken.getOptional("bulk_order_token") + /** * 3-character alphabetic ISO 4217 code for the currency of the cardholder. * @@ -478,6 +492,15 @@ private constructor( @ExcludeMissing fun _authRuleTokens(): JsonField> = authRuleTokens + /** + * Returns the raw JSON value of [bulkOrderToken]. + * + * Unlike [bulkOrderToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bulk_order_token") + @ExcludeMissing + fun _bulkOrderToken(): JsonField = bulkOrderToken + /** * Returns the raw JSON value of [cardholderCurrency]. * @@ -625,6 +648,7 @@ private constructor( private var state: JsonField? = null private var type: JsonField? = null private var authRuleTokens: JsonField>? = null + private var bulkOrderToken: JsonField = JsonMissing.of() private var cardholderCurrency: JsonField = JsonMissing.of() private var comment: JsonField = JsonMissing.of() private var digitalCardArtToken: JsonField = JsonMissing.of() @@ -653,6 +677,7 @@ private constructor( state = nonPciCard.state type = nonPciCard.type authRuleTokens = nonPciCard.authRuleTokens.map { it.toMutableList() } + bulkOrderToken = nonPciCard.bulkOrderToken cardholderCurrency = nonPciCard.cardholderCurrency comment = nonPciCard.comment digitalCardArtToken = nonPciCard.digitalCardArtToken @@ -879,6 +904,28 @@ private constructor( } } + /** + * Globally unique identifier for the bulk order associated with this card. Only applicable + * to physical cards that are part of a bulk shipment + */ + fun bulkOrderToken(bulkOrderToken: String?) = + bulkOrderToken(JsonField.ofNullable(bulkOrderToken)) + + /** Alias for calling [Builder.bulkOrderToken] with `bulkOrderToken.orElse(null)`. */ + fun bulkOrderToken(bulkOrderToken: Optional) = + bulkOrderToken(bulkOrderToken.getOrNull()) + + /** + * Sets [Builder.bulkOrderToken] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkOrderToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bulkOrderToken(bulkOrderToken: JsonField) = apply { + this.bulkOrderToken = bulkOrderToken + } + /** 3-character alphabetic ISO 4217 code for the currency of the cardholder. */ fun cardholderCurrency(cardholderCurrency: String) = cardholderCurrency(JsonField.of(cardholderCurrency)) @@ -1148,6 +1195,7 @@ private constructor( checkRequired("state", state), checkRequired("type", type), (authRuleTokens ?: JsonMissing.of()).map { it.toImmutable() }, + bulkOrderToken, cardholderCurrency, comment, digitalCardArtToken, @@ -1183,6 +1231,7 @@ private constructor( state().validate() type().validate() authRuleTokens() + bulkOrderToken() cardholderCurrency() comment() digitalCardArtToken() @@ -1225,6 +1274,7 @@ private constructor( (state.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + (authRuleTokens.asKnown().getOrNull()?.size ?: 0) + + (if (bulkOrderToken.asKnown().isPresent) 1 else 0) + (if (cardholderCurrency.asKnown().isPresent) 1 else 0) + (if (comment.asKnown().isPresent) 1 else 0) + (if (digitalCardArtToken.asKnown().isPresent) 1 else 0) + @@ -2601,6 +2651,7 @@ private constructor( state == other.state && type == other.type && authRuleTokens == other.authRuleTokens && + bulkOrderToken == other.bulkOrderToken && cardholderCurrency == other.cardholderCurrency && comment == other.comment && digitalCardArtToken == other.digitalCardArtToken && @@ -2630,6 +2681,7 @@ private constructor( state, type, authRuleTokens, + bulkOrderToken, cardholderCurrency, comment, digitalCardArtToken, @@ -2649,5 +2701,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NonPciCard{token=$token, accountToken=$accountToken, cardProgramToken=$cardProgramToken, created=$created, funding=$funding, lastFour=$lastFour, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, authRuleTokens=$authRuleTokens, cardholderCurrency=$cardholderCurrency, comment=$comment, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, hostname=$hostname, memo=$memo, networkProgramToken=$networkProgramToken, pendingCommands=$pendingCommands, productId=$productId, replacementFor=$replacementFor, substatus=$substatus, additionalProperties=$additionalProperties}" + "NonPciCard{token=$token, accountToken=$accountToken, cardProgramToken=$cardProgramToken, created=$created, funding=$funding, lastFour=$lastFour, pinStatus=$pinStatus, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, authRuleTokens=$authRuleTokens, bulkOrderToken=$bulkOrderToken, cardholderCurrency=$cardholderCurrency, comment=$comment, digitalCardArtToken=$digitalCardArtToken, expMonth=$expMonth, expYear=$expYear, hostname=$hostname, memo=$memo, networkProgramToken=$networkProgramToken, pendingCommands=$pendingCommands, productId=$productId, replacementFor=$replacementFor, substatus=$substatus, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPage.kt index d9cff828e..d2b4c2445 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPage.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPage.kt @@ -16,7 +16,7 @@ private constructor( private val service: NetworkTotalService, private val params: ReportSettlementNetworkTotalListParams, private val response: ReportSettlementNetworkTotalListPageResponse, -) : Page { +) : Page { /** * Delegates to [ReportSettlementNetworkTotalListPageResponse], but gracefully handles missing @@ -24,8 +24,7 @@ private constructor( * * @see ReportSettlementNetworkTotalListPageResponse.data */ - fun data(): List = - response._data().getOptional("data").getOrNull() ?: emptyList() + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** * Delegates to [ReportSettlementNetworkTotalListPageResponse], but gracefully handles missing @@ -35,7 +34,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = items().isNotEmpty() @@ -48,7 +47,7 @@ private constructor( override fun nextPage(): ReportSettlementNetworkTotalListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): ReportSettlementNetworkTotalListParams = params diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageAsync.kt index d7c04b2d5..64d06dc2e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageAsync.kt @@ -19,7 +19,7 @@ private constructor( private val streamHandlerExecutor: Executor, private val params: ReportSettlementNetworkTotalListParams, private val response: ReportSettlementNetworkTotalListPageResponse, -) : PageAsync { +) : PageAsync { /** * Delegates to [ReportSettlementNetworkTotalListPageResponse], but gracefully handles missing @@ -27,8 +27,7 @@ private constructor( * * @see ReportSettlementNetworkTotalListPageResponse.data */ - fun data(): List = - response._data().getOptional("data").getOrNull() ?: emptyList() + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() /** * Delegates to [ReportSettlementNetworkTotalListPageResponse], but gracefully handles missing @@ -38,7 +37,7 @@ private constructor( */ fun hasMore(): Optional = response._hasMore().getOptional("has_more") - override fun items(): List = data() + override fun items(): List = data() override fun hasNextPage(): Boolean = items().isNotEmpty() @@ -52,8 +51,7 @@ private constructor( override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPagerAsync = - AutoPagerAsync.from(this, streamHandlerExecutor) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): ReportSettlementNetworkTotalListParams = params diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageResponse.kt index 54693dbf2..248a7ab66 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageResponse.kt @@ -21,7 +21,7 @@ import kotlin.jvm.optionals.getOrNull class ReportSettlementNetworkTotalListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val data: JsonField>, + private val data: JsonField>, private val hasMore: JsonField, private val additionalProperties: MutableMap, ) { @@ -30,7 +30,7 @@ private constructor( private constructor( @JsonProperty("data") @ExcludeMissing - data: JsonField> = JsonMissing.of(), + data: JsonField> = JsonMissing.of(), @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), ) : this(data, hasMore, mutableMapOf()) @@ -38,7 +38,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 data(): List = data.getRequired("data") + fun data(): List = data.getRequired("data") /** * Indicates whether there are more network total records to be retrieved. @@ -53,9 +53,7 @@ private constructor( * * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("data") - @ExcludeMissing - fun _data(): JsonField> = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data /** * Returns the raw JSON value of [hasMore]. @@ -94,7 +92,7 @@ private constructor( /** A builder for [ReportSettlementNetworkTotalListPageResponse]. */ class Builder internal constructor() { - private var data: JsonField>? = null + private var data: JsonField>? = null private var hasMore: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -109,25 +107,25 @@ private constructor( reportSettlementNetworkTotalListPageResponse.additionalProperties.toMutableMap() } - fun data(data: List) = data(JsonField.of(data)) + fun data(data: List) = data(JsonField.of(data)) /** * Sets [Builder.data] to an arbitrary JSON value. * - * You should usually call [Builder.data] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun data(data: JsonField>) = apply { + fun data(data: JsonField>) = apply { this.data = data.map { it.toMutableList() } } /** - * Adds a single [NetworkTotalListResponse] to [Builder.data]. + * Adds a single [NetworkTotal] to [Builder.data]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addData(data: NetworkTotalListResponse) = apply { + fun addData(data: NetworkTotal) = apply { this.data = (this.data ?: JsonField.of(mutableListOf())).also { checkKnown("data", it).add(data) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthentication.kt similarity index 99% rename from lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt rename to lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthentication.kt index 5dcbcb5b1..c6e0383b7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthenticationRetrieveResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthentication.kt @@ -20,7 +20,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Represents a 3DS authentication */ -class AuthenticationRetrieveResponse +class ThreeDSAuthentication @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val token: JsonField, @@ -502,8 +502,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AuthenticationRetrieveResponse]. + * Returns a mutable builder for constructing an instance of [ThreeDSAuthentication]. * * The following fields are required: * ```java @@ -523,7 +522,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AuthenticationRetrieveResponse]. */ + /** A builder for [ThreeDSAuthentication]. */ class Builder internal constructor() { private var token: JsonField? = null @@ -552,30 +551,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(authenticationRetrieveResponse: AuthenticationRetrieveResponse) = apply { - token = authenticationRetrieveResponse.token - accountType = authenticationRetrieveResponse.accountType - authenticationResult = authenticationRetrieveResponse.authenticationResult - cardExpiryCheck = authenticationRetrieveResponse.cardExpiryCheck - cardToken = authenticationRetrieveResponse.cardToken - cardholder = authenticationRetrieveResponse.cardholder - channel = authenticationRetrieveResponse.channel - created = authenticationRetrieveResponse.created - merchant = authenticationRetrieveResponse.merchant - messageCategory = authenticationRetrieveResponse.messageCategory + internal fun from(threeDSAuthentication: ThreeDSAuthentication) = apply { + token = threeDSAuthentication.token + accountType = threeDSAuthentication.accountType + authenticationResult = threeDSAuthentication.authenticationResult + cardExpiryCheck = threeDSAuthentication.cardExpiryCheck + cardToken = threeDSAuthentication.cardToken + cardholder = threeDSAuthentication.cardholder + channel = threeDSAuthentication.channel + created = threeDSAuthentication.created + merchant = threeDSAuthentication.merchant + messageCategory = threeDSAuthentication.messageCategory threeDSRequestorChallengeIndicator = - authenticationRetrieveResponse.threeDSRequestorChallengeIndicator - additionalData = authenticationRetrieveResponse.additionalData - app = authenticationRetrieveResponse.app - authenticationRequestType = authenticationRetrieveResponse.authenticationRequestType - browser = authenticationRetrieveResponse.browser - challengeMetadata = authenticationRetrieveResponse.challengeMetadata - challengeOrchestratedBy = authenticationRetrieveResponse.challengeOrchestratedBy - decisionMadeBy = authenticationRetrieveResponse.decisionMadeBy - threeRiRequestType = authenticationRetrieveResponse.threeRiRequestType - transaction = authenticationRetrieveResponse.transaction - additionalProperties = - authenticationRetrieveResponse.additionalProperties.toMutableMap() + threeDSAuthentication.threeDSRequestorChallengeIndicator + additionalData = threeDSAuthentication.additionalData + app = threeDSAuthentication.app + authenticationRequestType = threeDSAuthentication.authenticationRequestType + browser = threeDSAuthentication.browser + challengeMetadata = threeDSAuthentication.challengeMetadata + challengeOrchestratedBy = threeDSAuthentication.challengeOrchestratedBy + decisionMadeBy = threeDSAuthentication.decisionMadeBy + threeRiRequestType = threeDSAuthentication.threeRiRequestType + transaction = threeDSAuthentication.transaction + additionalProperties = threeDSAuthentication.additionalProperties.toMutableMap() } /** @@ -975,7 +973,7 @@ private constructor( } /** - * Returns an immutable instance of [AuthenticationRetrieveResponse]. + * Returns an immutable instance of [ThreeDSAuthentication]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -996,8 +994,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AuthenticationRetrieveResponse = - AuthenticationRetrieveResponse( + fun build(): ThreeDSAuthentication = + ThreeDSAuthentication( checkRequired("token", token), checkRequired("accountType", accountType), checkRequired("authenticationResult", authenticationResult), @@ -1027,7 +1025,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AuthenticationRetrieveResponse = apply { + fun validate(): ThreeDSAuthentication = apply { if (validated) { return@apply } @@ -8400,7 +8398,7 @@ private constructor( return true } - return other is AuthenticationRetrieveResponse && + return other is ThreeDSAuthentication && token == other.token && accountType == other.accountType && authenticationResult == other.authenticationResult && @@ -8453,5 +8451,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AuthenticationRetrieveResponse{token=$token, accountType=$accountType, authenticationResult=$authenticationResult, cardExpiryCheck=$cardExpiryCheck, cardToken=$cardToken, cardholder=$cardholder, channel=$channel, created=$created, merchant=$merchant, messageCategory=$messageCategory, threeDSRequestorChallengeIndicator=$threeDSRequestorChallengeIndicator, additionalData=$additionalData, app=$app, authenticationRequestType=$authenticationRequestType, browser=$browser, challengeMetadata=$challengeMetadata, challengeOrchestratedBy=$challengeOrchestratedBy, decisionMadeBy=$decisionMadeBy, threeRiRequestType=$threeRiRequestType, transaction=$transaction, additionalProperties=$additionalProperties}" + "ThreeDSAuthentication{token=$token, accountType=$accountType, authenticationResult=$authenticationResult, cardExpiryCheck=$cardExpiryCheck, cardToken=$cardToken, cardholder=$cardholder, channel=$channel, created=$created, merchant=$merchant, messageCategory=$messageCategory, threeDSRequestorChallengeIndicator=$threeDSRequestorChallengeIndicator, additionalData=$additionalData, app=$app, authenticationRequestType=$authenticationRequestType, browser=$browser, challengeMetadata=$challengeMetadata, challengeOrchestratedBy=$challengeOrchestratedBy, decisionMadeBy=$decisionMadeBy, threeRiRequestType=$threeRiRequestType, transaction=$transaction, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenInfo.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenInfo.kt new file mode 100644 index 000000000..4bff18ffc --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenInfo.kt @@ -0,0 +1,342 @@ +// 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.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class TokenInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val walletType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("wallet_type") + @ExcludeMissing + walletType: JsonField = JsonMissing.of() + ) : this(walletType, mutableMapOf()) + + /** + * The wallet_type field will indicate the source of the token. Possible token sources include + * digital wallets (Apple, Google, or Samsung Pay), merchant tokenization, and “other” sources + * like in-flight commerce. Masterpass is not currently supported and is included for future + * use. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun walletType(): WalletType = walletType.getRequired("wallet_type") + + /** + * Returns the raw JSON value of [walletType]. + * + * Unlike [walletType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("wallet_type") + @ExcludeMissing + fun _walletType(): JsonField = walletType + + @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 [TokenInfo]. + * + * The following fields are required: + * ```java + * .walletType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenInfo]. */ + class Builder internal constructor() { + + private var walletType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenInfo: TokenInfo) = apply { + walletType = tokenInfo.walletType + additionalProperties = tokenInfo.additionalProperties.toMutableMap() + } + + /** + * The wallet_type field will indicate the source of the token. Possible token sources + * include digital wallets (Apple, Google, or Samsung Pay), merchant tokenization, and + * “other” sources like in-flight commerce. Masterpass is not currently supported and is + * included for future use. + */ + fun walletType(walletType: WalletType) = walletType(JsonField.of(walletType)) + + /** + * Sets [Builder.walletType] to an arbitrary JSON value. + * + * You should usually call [Builder.walletType] with a well-typed [WalletType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun walletType(walletType: JsonField) = apply { this.walletType = walletType } + + 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 [TokenInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .walletType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenInfo = + TokenInfo(checkRequired("walletType", walletType), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TokenInfo = apply { + if (validated) { + return@apply + } + + walletType().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 = (walletType.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The wallet_type field will indicate the source of the token. Possible token sources include + * digital wallets (Apple, Google, or Samsung Pay), merchant tokenization, and “other” sources + * like in-flight commerce. Masterpass is not currently supported and is included for future + * use. + */ + class WalletType @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 APPLE_PAY = of("APPLE_PAY") + + @JvmField val GOOGLE_PAY = of("GOOGLE_PAY") + + @JvmField val MASTERPASS = of("MASTERPASS") + + @JvmField val MERCHANT = of("MERCHANT") + + @JvmField val OTHER = of("OTHER") + + @JvmField val SAMSUNG_PAY = of("SAMSUNG_PAY") + + @JvmStatic fun of(value: String) = WalletType(JsonField.of(value)) + } + + /** An enum containing [WalletType]'s known values. */ + enum class Known { + APPLE_PAY, + GOOGLE_PAY, + MASTERPASS, + MERCHANT, + OTHER, + SAMSUNG_PAY, + } + + /** + * An enum containing [WalletType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WalletType] 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 { + APPLE_PAY, + GOOGLE_PAY, + MASTERPASS, + MERCHANT, + OTHER, + SAMSUNG_PAY, + /** + * An enum member indicating that [WalletType] 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) { + APPLE_PAY -> Value.APPLE_PAY + GOOGLE_PAY -> Value.GOOGLE_PAY + MASTERPASS -> Value.MASTERPASS + MERCHANT -> Value.MERCHANT + OTHER -> Value.OTHER + SAMSUNG_PAY -> Value.SAMSUNG_PAY + 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) { + APPLE_PAY -> Known.APPLE_PAY + GOOGLE_PAY -> Known.GOOGLE_PAY + MASTERPASS -> Known.MASTERPASS + MERCHANT -> Known.MERCHANT + OTHER -> Known.OTHER + SAMSUNG_PAY -> Known.SAMSUNG_PAY + else -> throw LithicInvalidDataException("Unknown WalletType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): WalletType = 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 WalletType && 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 TokenInfo && + walletType == other.walletType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(walletType, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenInfo{walletType=$walletType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Tokenization.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Tokenization.kt index 02cbd2cec..66428ec8c 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Tokenization.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Tokenization.kt @@ -1860,885 +1860,6 @@ private constructor( override fun toString() = value.toString() } - class TokenizationRuleResult - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val authRuleToken: JsonField, - private val explanation: JsonField, - private val name: JsonField, - private val result: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("auth_rule_token") - @ExcludeMissing - authRuleToken: JsonField = JsonMissing.of(), - @JsonProperty("explanation") - @ExcludeMissing - explanation: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("result") @ExcludeMissing result: JsonField = JsonMissing.of(), - ) : this(authRuleToken, explanation, name, result, mutableMapOf()) - - /** - * The Auth Rule Token associated with the rule. If this is set to null, then the result - * was not associated with a customer-configured rule. This may happen in cases where a - * tokenization is declined or requires TFA due to a Lithic-configured security or - * compliance rule, for example. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun authRuleToken(): Optional = authRuleToken.getOptional("auth_rule_token") - - /** - * A human-readable explanation outlining the motivation for the rule's result - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun explanation(): Optional = explanation.getOptional("explanation") - - /** - * The name for the rule, if any was configured - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The result associated with this rule - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun result(): Result = result.getRequired("result") - - /** - * Returns the raw JSON value of [authRuleToken]. - * - * Unlike [authRuleToken], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("auth_rule_token") - @ExcludeMissing - fun _authRuleToken(): JsonField = authRuleToken - - /** - * Returns the raw JSON value of [explanation]. - * - * Unlike [explanation], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("explanation") - @ExcludeMissing - fun _explanation(): JsonField = explanation - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [result]. - * - * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result - - @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 - * [TokenizationRuleResult]. - * - * The following fields are required: - * ```java - * .authRuleToken() - * .explanation() - * .name() - * .result() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenizationRuleResult]. */ - class Builder internal constructor() { - - private var authRuleToken: JsonField? = null - private var explanation: JsonField? = null - private var name: JsonField? = null - private var result: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tokenizationRuleResult: TokenizationRuleResult) = apply { - authRuleToken = tokenizationRuleResult.authRuleToken - explanation = tokenizationRuleResult.explanation - name = tokenizationRuleResult.name - result = tokenizationRuleResult.result - additionalProperties = - tokenizationRuleResult.additionalProperties.toMutableMap() - } - - /** - * The Auth Rule Token associated with the rule. If this is set to null, then the - * result was not associated with a customer-configured rule. This may happen in - * cases where a tokenization is declined or requires TFA due to a Lithic-configured - * security or compliance rule, for example. - */ - fun authRuleToken(authRuleToken: String?) = - authRuleToken(JsonField.ofNullable(authRuleToken)) - - /** Alias for calling [Builder.authRuleToken] with `authRuleToken.orElse(null)`. */ - fun authRuleToken(authRuleToken: Optional) = - authRuleToken(authRuleToken.getOrNull()) - - /** - * Sets [Builder.authRuleToken] to an arbitrary JSON value. - * - * You should usually call [Builder.authRuleToken] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun authRuleToken(authRuleToken: JsonField) = apply { - this.authRuleToken = authRuleToken - } - - /** A human-readable explanation outlining the motivation for the rule's result */ - fun explanation(explanation: String?) = - explanation(JsonField.ofNullable(explanation)) - - /** Alias for calling [Builder.explanation] with `explanation.orElse(null)`. */ - fun explanation(explanation: Optional) = - explanation(explanation.getOrNull()) - - /** - * Sets [Builder.explanation] to an arbitrary JSON value. - * - * You should usually call [Builder.explanation] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun explanation(explanation: JsonField) = apply { - this.explanation = explanation - } - - /** The name for the rule, if any was configured */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The result associated with this rule */ - fun result(result: Result) = result(JsonField.of(result)) - - /** - * Sets [Builder.result] to an arbitrary JSON value. - * - * You should usually call [Builder.result] with a well-typed [Result] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun result(result: JsonField) = apply { this.result = result } - - fun 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 [TokenizationRuleResult]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .authRuleToken() - * .explanation() - * .name() - * .result() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TokenizationRuleResult = - TokenizationRuleResult( - checkRequired("authRuleToken", authRuleToken), - checkRequired("explanation", explanation), - checkRequired("name", name), - checkRequired("result", result), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TokenizationRuleResult = apply { - if (validated) { - return@apply - } - - authRuleToken() - explanation() - name() - result().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 (authRuleToken.asKnown().isPresent) 1 else 0) + - (if (explanation.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (result.asKnown().getOrNull()?.validity() ?: 0) - - /** The result associated with this rule */ - class Result @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val APPROVED = of("APPROVED") - - @JvmField val DECLINED = of("DECLINED") - - @JvmField val REQUIRE_TFA = of("REQUIRE_TFA") - - @JvmField val ERROR = of("ERROR") - - @JvmStatic fun of(value: String) = Result(JsonField.of(value)) - } - - /** An enum containing [Result]'s known values. */ - enum class Known { - APPROVED, - DECLINED, - REQUIRE_TFA, - ERROR, - } - - /** - * An enum containing [Result]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Result] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - APPROVED, - DECLINED, - REQUIRE_TFA, - ERROR, - /** - * An enum member indicating that [Result] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - APPROVED -> Value.APPROVED - DECLINED -> Value.DECLINED - REQUIRE_TFA -> Value.REQUIRE_TFA - 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) { - APPROVED -> Known.APPROVED - DECLINED -> Known.DECLINED - REQUIRE_TFA -> Known.REQUIRE_TFA - ERROR -> Known.ERROR - else -> throw LithicInvalidDataException("Unknown Result: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Result = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: LithicInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Result && 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 TokenizationRuleResult && - authRuleToken == other.authRuleToken && - explanation == other.explanation && - name == other.name && - result == other.result && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(authRuleToken, explanation, name, result, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TokenizationRuleResult{authRuleToken=$authRuleToken, explanation=$explanation, name=$name, result=$result, additionalProperties=$additionalProperties}" - } - - /** Reason code for why a tokenization was declined */ - class TokenizationDeclineReason - @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 ACCOUNT_SCORE_1 = of("ACCOUNT_SCORE_1") - - @JvmField val DEVICE_SCORE_1 = of("DEVICE_SCORE_1") - - @JvmField - val ALL_WALLET_DECLINE_REASONS_PRESENT = of("ALL_WALLET_DECLINE_REASONS_PRESENT") - - @JvmField - val WALLET_RECOMMENDED_DECISION_RED = of("WALLET_RECOMMENDED_DECISION_RED") - - @JvmField val CVC_MISMATCH = of("CVC_MISMATCH") - - @JvmField val CARD_EXPIRY_MONTH_MISMATCH = of("CARD_EXPIRY_MONTH_MISMATCH") - - @JvmField val CARD_EXPIRY_YEAR_MISMATCH = of("CARD_EXPIRY_YEAR_MISMATCH") - - @JvmField val CARD_INVALID_STATE = of("CARD_INVALID_STATE") - - @JvmField val CUSTOMER_RED_PATH = of("CUSTOMER_RED_PATH") - - @JvmField val INVALID_CUSTOMER_RESPONSE = of("INVALID_CUSTOMER_RESPONSE") - - @JvmField val NETWORK_FAILURE = of("NETWORK_FAILURE") - - @JvmField val GENERIC_DECLINE = of("GENERIC_DECLINE") - - @JvmField val DIGITAL_CARD_ART_REQUIRED = of("DIGITAL_CARD_ART_REQUIRED") - - @JvmStatic fun of(value: String) = TokenizationDeclineReason(JsonField.of(value)) - } - - /** An enum containing [TokenizationDeclineReason]'s known values. */ - enum class Known { - ACCOUNT_SCORE_1, - DEVICE_SCORE_1, - ALL_WALLET_DECLINE_REASONS_PRESENT, - WALLET_RECOMMENDED_DECISION_RED, - CVC_MISMATCH, - CARD_EXPIRY_MONTH_MISMATCH, - CARD_EXPIRY_YEAR_MISMATCH, - CARD_INVALID_STATE, - CUSTOMER_RED_PATH, - INVALID_CUSTOMER_RESPONSE, - NETWORK_FAILURE, - GENERIC_DECLINE, - DIGITAL_CARD_ART_REQUIRED, - } - - /** - * An enum containing [TokenizationDeclineReason]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [TokenizationDeclineReason] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACCOUNT_SCORE_1, - DEVICE_SCORE_1, - ALL_WALLET_DECLINE_REASONS_PRESENT, - WALLET_RECOMMENDED_DECISION_RED, - CVC_MISMATCH, - CARD_EXPIRY_MONTH_MISMATCH, - CARD_EXPIRY_YEAR_MISMATCH, - CARD_INVALID_STATE, - CUSTOMER_RED_PATH, - INVALID_CUSTOMER_RESPONSE, - NETWORK_FAILURE, - GENERIC_DECLINE, - DIGITAL_CARD_ART_REQUIRED, - /** - * An enum member indicating that [TokenizationDeclineReason] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACCOUNT_SCORE_1 -> Value.ACCOUNT_SCORE_1 - DEVICE_SCORE_1 -> Value.DEVICE_SCORE_1 - ALL_WALLET_DECLINE_REASONS_PRESENT -> Value.ALL_WALLET_DECLINE_REASONS_PRESENT - WALLET_RECOMMENDED_DECISION_RED -> Value.WALLET_RECOMMENDED_DECISION_RED - CVC_MISMATCH -> Value.CVC_MISMATCH - CARD_EXPIRY_MONTH_MISMATCH -> Value.CARD_EXPIRY_MONTH_MISMATCH - CARD_EXPIRY_YEAR_MISMATCH -> Value.CARD_EXPIRY_YEAR_MISMATCH - CARD_INVALID_STATE -> Value.CARD_INVALID_STATE - CUSTOMER_RED_PATH -> Value.CUSTOMER_RED_PATH - INVALID_CUSTOMER_RESPONSE -> Value.INVALID_CUSTOMER_RESPONSE - NETWORK_FAILURE -> Value.NETWORK_FAILURE - GENERIC_DECLINE -> Value.GENERIC_DECLINE - DIGITAL_CARD_ART_REQUIRED -> Value.DIGITAL_CARD_ART_REQUIRED - 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) { - ACCOUNT_SCORE_1 -> Known.ACCOUNT_SCORE_1 - DEVICE_SCORE_1 -> Known.DEVICE_SCORE_1 - ALL_WALLET_DECLINE_REASONS_PRESENT -> Known.ALL_WALLET_DECLINE_REASONS_PRESENT - WALLET_RECOMMENDED_DECISION_RED -> Known.WALLET_RECOMMENDED_DECISION_RED - CVC_MISMATCH -> Known.CVC_MISMATCH - CARD_EXPIRY_MONTH_MISMATCH -> Known.CARD_EXPIRY_MONTH_MISMATCH - CARD_EXPIRY_YEAR_MISMATCH -> Known.CARD_EXPIRY_YEAR_MISMATCH - CARD_INVALID_STATE -> Known.CARD_INVALID_STATE - CUSTOMER_RED_PATH -> Known.CUSTOMER_RED_PATH - INVALID_CUSTOMER_RESPONSE -> Known.INVALID_CUSTOMER_RESPONSE - NETWORK_FAILURE -> Known.NETWORK_FAILURE - GENERIC_DECLINE -> Known.GENERIC_DECLINE - DIGITAL_CARD_ART_REQUIRED -> Known.DIGITAL_CARD_ART_REQUIRED - else -> - throw LithicInvalidDataException( - "Unknown TokenizationDeclineReason: $value" - ) - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): TokenizationDeclineReason = 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 TokenizationDeclineReason && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Reason code for why a tokenization required two-factor authentication */ - class TokenizationTfaReason - @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 WALLET_RECOMMENDED_TFA = of("WALLET_RECOMMENDED_TFA") - - @JvmField val SUSPICIOUS_ACTIVITY = of("SUSPICIOUS_ACTIVITY") - - @JvmField val DEVICE_RECENTLY_LOST = of("DEVICE_RECENTLY_LOST") - - @JvmField val TOO_MANY_RECENT_ATTEMPTS = of("TOO_MANY_RECENT_ATTEMPTS") - - @JvmField val TOO_MANY_RECENT_TOKENS = of("TOO_MANY_RECENT_TOKENS") - - @JvmField val TOO_MANY_DIFFERENT_CARDHOLDERS = of("TOO_MANY_DIFFERENT_CARDHOLDERS") - - @JvmField val OUTSIDE_HOME_TERRITORY = of("OUTSIDE_HOME_TERRITORY") - - @JvmField val HAS_SUSPENDED_TOKENS = of("HAS_SUSPENDED_TOKENS") - - @JvmField val HIGH_RISK = of("HIGH_RISK") - - @JvmField val ACCOUNT_SCORE_LOW = of("ACCOUNT_SCORE_LOW") - - @JvmField val DEVICE_SCORE_LOW = of("DEVICE_SCORE_LOW") - - @JvmField val CARD_STATE_TFA = of("CARD_STATE_TFA") - - @JvmField val HARDCODED_TFA = of("HARDCODED_TFA") - - @JvmField val CUSTOMER_RULE_TFA = of("CUSTOMER_RULE_TFA") - - @JvmField val DEVICE_HOST_CARD_EMULATION = of("DEVICE_HOST_CARD_EMULATION") - - @JvmStatic fun of(value: String) = TokenizationTfaReason(JsonField.of(value)) - } - - /** An enum containing [TokenizationTfaReason]'s known values. */ - enum class Known { - WALLET_RECOMMENDED_TFA, - SUSPICIOUS_ACTIVITY, - DEVICE_RECENTLY_LOST, - TOO_MANY_RECENT_ATTEMPTS, - TOO_MANY_RECENT_TOKENS, - TOO_MANY_DIFFERENT_CARDHOLDERS, - OUTSIDE_HOME_TERRITORY, - HAS_SUSPENDED_TOKENS, - HIGH_RISK, - ACCOUNT_SCORE_LOW, - DEVICE_SCORE_LOW, - CARD_STATE_TFA, - HARDCODED_TFA, - CUSTOMER_RULE_TFA, - DEVICE_HOST_CARD_EMULATION, - } - - /** - * An enum containing [TokenizationTfaReason]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [TokenizationTfaReason] 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 { - WALLET_RECOMMENDED_TFA, - SUSPICIOUS_ACTIVITY, - DEVICE_RECENTLY_LOST, - TOO_MANY_RECENT_ATTEMPTS, - TOO_MANY_RECENT_TOKENS, - TOO_MANY_DIFFERENT_CARDHOLDERS, - OUTSIDE_HOME_TERRITORY, - HAS_SUSPENDED_TOKENS, - HIGH_RISK, - ACCOUNT_SCORE_LOW, - DEVICE_SCORE_LOW, - CARD_STATE_TFA, - HARDCODED_TFA, - CUSTOMER_RULE_TFA, - DEVICE_HOST_CARD_EMULATION, - /** - * An enum member indicating that [TokenizationTfaReason] 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) { - WALLET_RECOMMENDED_TFA -> Value.WALLET_RECOMMENDED_TFA - SUSPICIOUS_ACTIVITY -> Value.SUSPICIOUS_ACTIVITY - DEVICE_RECENTLY_LOST -> Value.DEVICE_RECENTLY_LOST - TOO_MANY_RECENT_ATTEMPTS -> Value.TOO_MANY_RECENT_ATTEMPTS - TOO_MANY_RECENT_TOKENS -> Value.TOO_MANY_RECENT_TOKENS - TOO_MANY_DIFFERENT_CARDHOLDERS -> Value.TOO_MANY_DIFFERENT_CARDHOLDERS - OUTSIDE_HOME_TERRITORY -> Value.OUTSIDE_HOME_TERRITORY - HAS_SUSPENDED_TOKENS -> Value.HAS_SUSPENDED_TOKENS - HIGH_RISK -> Value.HIGH_RISK - ACCOUNT_SCORE_LOW -> Value.ACCOUNT_SCORE_LOW - DEVICE_SCORE_LOW -> Value.DEVICE_SCORE_LOW - CARD_STATE_TFA -> Value.CARD_STATE_TFA - HARDCODED_TFA -> Value.HARDCODED_TFA - CUSTOMER_RULE_TFA -> Value.CUSTOMER_RULE_TFA - DEVICE_HOST_CARD_EMULATION -> Value.DEVICE_HOST_CARD_EMULATION - 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) { - WALLET_RECOMMENDED_TFA -> Known.WALLET_RECOMMENDED_TFA - SUSPICIOUS_ACTIVITY -> Known.SUSPICIOUS_ACTIVITY - DEVICE_RECENTLY_LOST -> Known.DEVICE_RECENTLY_LOST - TOO_MANY_RECENT_ATTEMPTS -> Known.TOO_MANY_RECENT_ATTEMPTS - TOO_MANY_RECENT_TOKENS -> Known.TOO_MANY_RECENT_TOKENS - TOO_MANY_DIFFERENT_CARDHOLDERS -> Known.TOO_MANY_DIFFERENT_CARDHOLDERS - OUTSIDE_HOME_TERRITORY -> Known.OUTSIDE_HOME_TERRITORY - HAS_SUSPENDED_TOKENS -> Known.HAS_SUSPENDED_TOKENS - HIGH_RISK -> Known.HIGH_RISK - ACCOUNT_SCORE_LOW -> Known.ACCOUNT_SCORE_LOW - DEVICE_SCORE_LOW -> Known.DEVICE_SCORE_LOW - CARD_STATE_TFA -> Known.CARD_STATE_TFA - HARDCODED_TFA -> Known.HARDCODED_TFA - CUSTOMER_RULE_TFA -> Known.CUSTOMER_RULE_TFA - DEVICE_HOST_CARD_EMULATION -> Known.DEVICE_HOST_CARD_EMULATION - else -> - throw LithicInvalidDataException("Unknown TokenizationTfaReason: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): TokenizationTfaReason = 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 TokenizationTfaReason && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Enum representing the type of tokenization event that occurred */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationDeclineReason.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationDeclineReason.kt new file mode 100644 index 000000000..c94a79348 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationDeclineReason.kt @@ -0,0 +1,203 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.lithic.api.core.Enum +import com.lithic.api.core.JsonField +import com.lithic.api.errors.LithicInvalidDataException + +/** Reason code for why a tokenization was declined */ +class TokenizationDeclineReason +@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 ACCOUNT_SCORE_1 = of("ACCOUNT_SCORE_1") + + @JvmField val DEVICE_SCORE_1 = of("DEVICE_SCORE_1") + + @JvmField val ALL_WALLET_DECLINE_REASONS_PRESENT = of("ALL_WALLET_DECLINE_REASONS_PRESENT") + + @JvmField val WALLET_RECOMMENDED_DECISION_RED = of("WALLET_RECOMMENDED_DECISION_RED") + + @JvmField val CVC_MISMATCH = of("CVC_MISMATCH") + + @JvmField val CARD_EXPIRY_MONTH_MISMATCH = of("CARD_EXPIRY_MONTH_MISMATCH") + + @JvmField val CARD_EXPIRY_YEAR_MISMATCH = of("CARD_EXPIRY_YEAR_MISMATCH") + + @JvmField val CARD_INVALID_STATE = of("CARD_INVALID_STATE") + + @JvmField val CUSTOMER_RED_PATH = of("CUSTOMER_RED_PATH") + + @JvmField val INVALID_CUSTOMER_RESPONSE = of("INVALID_CUSTOMER_RESPONSE") + + @JvmField val NETWORK_FAILURE = of("NETWORK_FAILURE") + + @JvmField val GENERIC_DECLINE = of("GENERIC_DECLINE") + + @JvmField val DIGITAL_CARD_ART_REQUIRED = of("DIGITAL_CARD_ART_REQUIRED") + + @JvmStatic fun of(value: String) = TokenizationDeclineReason(JsonField.of(value)) + } + + /** An enum containing [TokenizationDeclineReason]'s known values. */ + enum class Known { + ACCOUNT_SCORE_1, + DEVICE_SCORE_1, + ALL_WALLET_DECLINE_REASONS_PRESENT, + WALLET_RECOMMENDED_DECISION_RED, + CVC_MISMATCH, + CARD_EXPIRY_MONTH_MISMATCH, + CARD_EXPIRY_YEAR_MISMATCH, + CARD_INVALID_STATE, + CUSTOMER_RED_PATH, + INVALID_CUSTOMER_RESPONSE, + NETWORK_FAILURE, + GENERIC_DECLINE, + DIGITAL_CARD_ART_REQUIRED, + } + + /** + * An enum containing [TokenizationDeclineReason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [TokenizationDeclineReason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_SCORE_1, + DEVICE_SCORE_1, + ALL_WALLET_DECLINE_REASONS_PRESENT, + WALLET_RECOMMENDED_DECISION_RED, + CVC_MISMATCH, + CARD_EXPIRY_MONTH_MISMATCH, + CARD_EXPIRY_YEAR_MISMATCH, + CARD_INVALID_STATE, + CUSTOMER_RED_PATH, + INVALID_CUSTOMER_RESPONSE, + NETWORK_FAILURE, + GENERIC_DECLINE, + DIGITAL_CARD_ART_REQUIRED, + /** + * An enum member indicating that [TokenizationDeclineReason] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_SCORE_1 -> Value.ACCOUNT_SCORE_1 + DEVICE_SCORE_1 -> Value.DEVICE_SCORE_1 + ALL_WALLET_DECLINE_REASONS_PRESENT -> Value.ALL_WALLET_DECLINE_REASONS_PRESENT + WALLET_RECOMMENDED_DECISION_RED -> Value.WALLET_RECOMMENDED_DECISION_RED + CVC_MISMATCH -> Value.CVC_MISMATCH + CARD_EXPIRY_MONTH_MISMATCH -> Value.CARD_EXPIRY_MONTH_MISMATCH + CARD_EXPIRY_YEAR_MISMATCH -> Value.CARD_EXPIRY_YEAR_MISMATCH + CARD_INVALID_STATE -> Value.CARD_INVALID_STATE + CUSTOMER_RED_PATH -> Value.CUSTOMER_RED_PATH + INVALID_CUSTOMER_RESPONSE -> Value.INVALID_CUSTOMER_RESPONSE + NETWORK_FAILURE -> Value.NETWORK_FAILURE + GENERIC_DECLINE -> Value.GENERIC_DECLINE + DIGITAL_CARD_ART_REQUIRED -> Value.DIGITAL_CARD_ART_REQUIRED + 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) { + ACCOUNT_SCORE_1 -> Known.ACCOUNT_SCORE_1 + DEVICE_SCORE_1 -> Known.DEVICE_SCORE_1 + ALL_WALLET_DECLINE_REASONS_PRESENT -> Known.ALL_WALLET_DECLINE_REASONS_PRESENT + WALLET_RECOMMENDED_DECISION_RED -> Known.WALLET_RECOMMENDED_DECISION_RED + CVC_MISMATCH -> Known.CVC_MISMATCH + CARD_EXPIRY_MONTH_MISMATCH -> Known.CARD_EXPIRY_MONTH_MISMATCH + CARD_EXPIRY_YEAR_MISMATCH -> Known.CARD_EXPIRY_YEAR_MISMATCH + CARD_INVALID_STATE -> Known.CARD_INVALID_STATE + CUSTOMER_RED_PATH -> Known.CUSTOMER_RED_PATH + INVALID_CUSTOMER_RESPONSE -> Known.INVALID_CUSTOMER_RESPONSE + NETWORK_FAILURE -> Known.NETWORK_FAILURE + GENERIC_DECLINE -> Known.GENERIC_DECLINE + DIGITAL_CARD_ART_REQUIRED -> Known.DIGITAL_CARD_ART_REQUIRED + else -> throw LithicInvalidDataException("Unknown TokenizationDeclineReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenizationDeclineReason = 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 TokenizationDeclineReason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationRuleResult.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationRuleResult.kt new file mode 100644 index 000000000..291ef70af --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationRuleResult.kt @@ -0,0 +1,454 @@ +// 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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TokenizationRuleResult +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val authRuleToken: JsonField, + private val explanation: JsonField, + private val name: JsonField, + private val result: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("auth_rule_token") + @ExcludeMissing + authRuleToken: JsonField = JsonMissing.of(), + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("result") @ExcludeMissing result: JsonField = JsonMissing.of(), + ) : this(authRuleToken, explanation, name, result, mutableMapOf()) + + /** + * The Auth Rule Token associated with the rule. If this is set to null, then the result was not + * associated with a customer-configured rule. This may happen in cases where a tokenization is + * declined or requires TFA due to a Lithic-configured security or compliance rule, for example. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authRuleToken(): Optional = authRuleToken.getOptional("auth_rule_token") + + /** + * A human-readable explanation outlining the motivation for the rule's result + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * The name for the rule, if any was configured + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The result associated with this rule + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): Result = result.getRequired("result") + + /** + * Returns the raw JSON value of [authRuleToken]. + * + * Unlike [authRuleToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auth_rule_token") + @ExcludeMissing + fun _authRuleToken(): JsonField = authRuleToken + + /** + * Returns the raw JSON value of [explanation]. + * + * Unlike [explanation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("explanation") @ExcludeMissing fun _explanation(): JsonField = explanation + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + @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 [TokenizationRuleResult]. + * + * The following fields are required: + * ```java + * .authRuleToken() + * .explanation() + * .name() + * .result() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationRuleResult]. */ + class Builder internal constructor() { + + private var authRuleToken: JsonField? = null + private var explanation: JsonField? = null + private var name: JsonField? = null + private var result: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenizationRuleResult: TokenizationRuleResult) = apply { + authRuleToken = tokenizationRuleResult.authRuleToken + explanation = tokenizationRuleResult.explanation + name = tokenizationRuleResult.name + result = tokenizationRuleResult.result + additionalProperties = tokenizationRuleResult.additionalProperties.toMutableMap() + } + + /** + * The Auth Rule Token associated with the rule. If this is set to null, then the result was + * not associated with a customer-configured rule. This may happen in cases where a + * tokenization is declined or requires TFA due to a Lithic-configured security or + * compliance rule, for example. + */ + fun authRuleToken(authRuleToken: String?) = + authRuleToken(JsonField.ofNullable(authRuleToken)) + + /** Alias for calling [Builder.authRuleToken] with `authRuleToken.orElse(null)`. */ + fun authRuleToken(authRuleToken: Optional) = + authRuleToken(authRuleToken.getOrNull()) + + /** + * Sets [Builder.authRuleToken] to an arbitrary JSON value. + * + * You should usually call [Builder.authRuleToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun authRuleToken(authRuleToken: JsonField) = apply { + this.authRuleToken = authRuleToken + } + + /** A human-readable explanation outlining the motivation for the rule's result */ + fun explanation(explanation: String?) = explanation(JsonField.ofNullable(explanation)) + + /** Alias for calling [Builder.explanation] with `explanation.orElse(null)`. */ + fun explanation(explanation: Optional) = explanation(explanation.getOrNull()) + + /** + * Sets [Builder.explanation] to an arbitrary JSON value. + * + * You should usually call [Builder.explanation] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun explanation(explanation: JsonField) = apply { this.explanation = explanation } + + /** The name for the rule, if any was configured */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The result associated with this rule */ + fun result(result: Result) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Result] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + fun 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 [TokenizationRuleResult]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .authRuleToken() + * .explanation() + * .name() + * .result() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationRuleResult = + TokenizationRuleResult( + checkRequired("authRuleToken", authRuleToken), + checkRequired("explanation", explanation), + checkRequired("name", name), + checkRequired("result", result), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationRuleResult = apply { + if (validated) { + return@apply + } + + authRuleToken() + explanation() + name() + result().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 (authRuleToken.asKnown().isPresent) 1 else 0) + + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + /** The result associated with this rule */ + class Result @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val REQUIRE_TFA = of("REQUIRE_TFA") + + @JvmField val ERROR = of("ERROR") + + @JvmStatic fun of(value: String) = Result(JsonField.of(value)) + } + + /** An enum containing [Result]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + REQUIRE_TFA, + ERROR, + } + + /** + * An enum containing [Result]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Result] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPROVED, + DECLINED, + REQUIRE_TFA, + ERROR, + /** An enum member indicating that [Result] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + REQUIRE_TFA -> Value.REQUIRE_TFA + 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) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + REQUIRE_TFA -> Known.REQUIRE_TFA + ERROR -> Known.ERROR + else -> throw LithicInvalidDataException("Unknown Result: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Result = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && 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 TokenizationRuleResult && + authRuleToken == other.authRuleToken && + explanation == other.explanation && + name == other.name && + result == other.result && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(authRuleToken, explanation, name, result, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationRuleResult{authRuleToken=$authRuleToken, explanation=$explanation, name=$name, result=$result, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTfaReason.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTfaReason.kt new file mode 100644 index 000000000..48cb3c602 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTfaReason.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.lithic.api.core.Enum +import com.lithic.api.core.JsonField +import com.lithic.api.errors.LithicInvalidDataException + +/** Reason code for why a tokenization required two-factor authentication */ +class TokenizationTfaReason @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 WALLET_RECOMMENDED_TFA = of("WALLET_RECOMMENDED_TFA") + + @JvmField val SUSPICIOUS_ACTIVITY = of("SUSPICIOUS_ACTIVITY") + + @JvmField val DEVICE_RECENTLY_LOST = of("DEVICE_RECENTLY_LOST") + + @JvmField val TOO_MANY_RECENT_ATTEMPTS = of("TOO_MANY_RECENT_ATTEMPTS") + + @JvmField val TOO_MANY_RECENT_TOKENS = of("TOO_MANY_RECENT_TOKENS") + + @JvmField val TOO_MANY_DIFFERENT_CARDHOLDERS = of("TOO_MANY_DIFFERENT_CARDHOLDERS") + + @JvmField val OUTSIDE_HOME_TERRITORY = of("OUTSIDE_HOME_TERRITORY") + + @JvmField val HAS_SUSPENDED_TOKENS = of("HAS_SUSPENDED_TOKENS") + + @JvmField val HIGH_RISK = of("HIGH_RISK") + + @JvmField val ACCOUNT_SCORE_LOW = of("ACCOUNT_SCORE_LOW") + + @JvmField val DEVICE_SCORE_LOW = of("DEVICE_SCORE_LOW") + + @JvmField val CARD_STATE_TFA = of("CARD_STATE_TFA") + + @JvmField val HARDCODED_TFA = of("HARDCODED_TFA") + + @JvmField val CUSTOMER_RULE_TFA = of("CUSTOMER_RULE_TFA") + + @JvmField val DEVICE_HOST_CARD_EMULATION = of("DEVICE_HOST_CARD_EMULATION") + + @JvmStatic fun of(value: String) = TokenizationTfaReason(JsonField.of(value)) + } + + /** An enum containing [TokenizationTfaReason]'s known values. */ + enum class Known { + WALLET_RECOMMENDED_TFA, + SUSPICIOUS_ACTIVITY, + DEVICE_RECENTLY_LOST, + TOO_MANY_RECENT_ATTEMPTS, + TOO_MANY_RECENT_TOKENS, + TOO_MANY_DIFFERENT_CARDHOLDERS, + OUTSIDE_HOME_TERRITORY, + HAS_SUSPENDED_TOKENS, + HIGH_RISK, + ACCOUNT_SCORE_LOW, + DEVICE_SCORE_LOW, + CARD_STATE_TFA, + HARDCODED_TFA, + CUSTOMER_RULE_TFA, + DEVICE_HOST_CARD_EMULATION, + } + + /** + * An enum containing [TokenizationTfaReason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TokenizationTfaReason] 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 { + WALLET_RECOMMENDED_TFA, + SUSPICIOUS_ACTIVITY, + DEVICE_RECENTLY_LOST, + TOO_MANY_RECENT_ATTEMPTS, + TOO_MANY_RECENT_TOKENS, + TOO_MANY_DIFFERENT_CARDHOLDERS, + OUTSIDE_HOME_TERRITORY, + HAS_SUSPENDED_TOKENS, + HIGH_RISK, + ACCOUNT_SCORE_LOW, + DEVICE_SCORE_LOW, + CARD_STATE_TFA, + HARDCODED_TFA, + CUSTOMER_RULE_TFA, + DEVICE_HOST_CARD_EMULATION, + /** + * An enum member indicating that [TokenizationTfaReason] 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) { + WALLET_RECOMMENDED_TFA -> Value.WALLET_RECOMMENDED_TFA + SUSPICIOUS_ACTIVITY -> Value.SUSPICIOUS_ACTIVITY + DEVICE_RECENTLY_LOST -> Value.DEVICE_RECENTLY_LOST + TOO_MANY_RECENT_ATTEMPTS -> Value.TOO_MANY_RECENT_ATTEMPTS + TOO_MANY_RECENT_TOKENS -> Value.TOO_MANY_RECENT_TOKENS + TOO_MANY_DIFFERENT_CARDHOLDERS -> Value.TOO_MANY_DIFFERENT_CARDHOLDERS + OUTSIDE_HOME_TERRITORY -> Value.OUTSIDE_HOME_TERRITORY + HAS_SUSPENDED_TOKENS -> Value.HAS_SUSPENDED_TOKENS + HIGH_RISK -> Value.HIGH_RISK + ACCOUNT_SCORE_LOW -> Value.ACCOUNT_SCORE_LOW + DEVICE_SCORE_LOW -> Value.DEVICE_SCORE_LOW + CARD_STATE_TFA -> Value.CARD_STATE_TFA + HARDCODED_TFA -> Value.HARDCODED_TFA + CUSTOMER_RULE_TFA -> Value.CUSTOMER_RULE_TFA + DEVICE_HOST_CARD_EMULATION -> Value.DEVICE_HOST_CARD_EMULATION + 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) { + WALLET_RECOMMENDED_TFA -> Known.WALLET_RECOMMENDED_TFA + SUSPICIOUS_ACTIVITY -> Known.SUSPICIOUS_ACTIVITY + DEVICE_RECENTLY_LOST -> Known.DEVICE_RECENTLY_LOST + TOO_MANY_RECENT_ATTEMPTS -> Known.TOO_MANY_RECENT_ATTEMPTS + TOO_MANY_RECENT_TOKENS -> Known.TOO_MANY_RECENT_TOKENS + TOO_MANY_DIFFERENT_CARDHOLDERS -> Known.TOO_MANY_DIFFERENT_CARDHOLDERS + OUTSIDE_HOME_TERRITORY -> Known.OUTSIDE_HOME_TERRITORY + HAS_SUSPENDED_TOKENS -> Known.HAS_SUSPENDED_TOKENS + HIGH_RISK -> Known.HIGH_RISK + ACCOUNT_SCORE_LOW -> Known.ACCOUNT_SCORE_LOW + DEVICE_SCORE_LOW -> Known.DEVICE_SCORE_LOW + CARD_STATE_TFA -> Known.CARD_STATE_TFA + HARDCODED_TFA -> Known.HARDCODED_TFA + CUSTOMER_RULE_TFA -> Known.CUSTOMER_RULE_TFA + DEVICE_HOST_CARD_EMULATION -> Known.DEVICE_HOST_CARD_EMULATION + else -> throw LithicInvalidDataException("Unknown TokenizationTfaReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenizationTfaReason = 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 TokenizationTfaReason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transaction.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transaction.kt index 5ef9f16ab..e9e8f7e88 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transaction.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Transaction.kt @@ -2695,1000 +2695,6 @@ private constructor( "Avs{address=$address, zipcode=$zipcode, additionalProperties=$additionalProperties}" } - class CardholderAuthentication - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val authenticationMethod: JsonField, - private val authenticationResult: JsonField, - private val decisionMadeBy: JsonField, - private val liabilityShift: JsonField, - private val threeDSAuthenticationToken: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("authentication_method") - @ExcludeMissing - authenticationMethod: JsonField = JsonMissing.of(), - @JsonProperty("authentication_result") - @ExcludeMissing - authenticationResult: JsonField = JsonMissing.of(), - @JsonProperty("decision_made_by") - @ExcludeMissing - decisionMadeBy: JsonField = JsonMissing.of(), - @JsonProperty("liability_shift") - @ExcludeMissing - liabilityShift: JsonField = JsonMissing.of(), - @JsonProperty("three_ds_authentication_token") - @ExcludeMissing - threeDSAuthenticationToken: JsonField = JsonMissing.of(), - ) : this( - authenticationMethod, - authenticationResult, - decisionMadeBy, - liabilityShift, - threeDSAuthenticationToken, - mutableMapOf(), - ) - - /** - * Indicates the method used to authenticate 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). - */ - fun authenticationMethod(): AuthenticationMethod = - authenticationMethod.getRequired("authentication_method") - - /** - * Indicates the outcome of the 3DS authentication process. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun authenticationResult(): AuthenticationResult = - authenticationResult.getRequired("authentication_result") - - /** - * Indicates which party made the 3DS authentication decision. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun decisionMadeBy(): DecisionMadeBy = decisionMadeBy.getRequired("decision_made_by") - - /** - * Indicates whether chargeback liability shift applies to the transaction. Possible enum - * values: - * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, - * chargeback liability shift applies. - * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is - * liable. - * * `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated - * cryptography, possibly recurring. Chargeback liability shift to the issuer applies. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun liabilityShift(): LiabilityShift = liabilityShift.getRequired("liability_shift") - - /** - * Unique identifier you can use to match a given 3DS authentication (available via the - * three_ds_authentication.created event webhook) and the transaction. Note that in cases - * where liability shift does not occur, this token is matched to the transaction on a - * best-effort basis. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun threeDSAuthenticationToken(): Optional = - threeDSAuthenticationToken.getOptional("three_ds_authentication_token") - - /** - * Returns the raw JSON value of [authenticationMethod]. - * - * Unlike [authenticationMethod], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("authentication_method") - @ExcludeMissing - fun _authenticationMethod(): JsonField = authenticationMethod - - /** - * Returns the raw JSON value of [authenticationResult]. - * - * Unlike [authenticationResult], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("authentication_result") - @ExcludeMissing - fun _authenticationResult(): JsonField = authenticationResult - - /** - * Returns the raw JSON value of [decisionMadeBy]. - * - * Unlike [decisionMadeBy], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("decision_made_by") - @ExcludeMissing - fun _decisionMadeBy(): JsonField = decisionMadeBy - - /** - * Returns the raw JSON value of [liabilityShift]. - * - * Unlike [liabilityShift], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("liability_shift") - @ExcludeMissing - fun _liabilityShift(): JsonField = liabilityShift - - /** - * Returns the raw JSON value of [threeDSAuthenticationToken]. - * - * Unlike [threeDSAuthenticationToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("three_ds_authentication_token") - @ExcludeMissing - fun _threeDSAuthenticationToken(): JsonField = threeDSAuthenticationToken - - @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 [CardholderAuthentication]. - * - * The following fields are required: - * ```java - * .authenticationMethod() - * .authenticationResult() - * .decisionMadeBy() - * .liabilityShift() - * .threeDSAuthenticationToken() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CardholderAuthentication]. */ - class Builder internal constructor() { - - private var authenticationMethod: JsonField? = null - private var authenticationResult: JsonField? = null - private var decisionMadeBy: JsonField? = null - private var liabilityShift: JsonField? = null - private var threeDSAuthenticationToken: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(cardholderAuthentication: CardholderAuthentication) = apply { - authenticationMethod = cardholderAuthentication.authenticationMethod - authenticationResult = cardholderAuthentication.authenticationResult - decisionMadeBy = cardholderAuthentication.decisionMadeBy - liabilityShift = cardholderAuthentication.liabilityShift - threeDSAuthenticationToken = cardholderAuthentication.threeDSAuthenticationToken - additionalProperties = cardholderAuthentication.additionalProperties.toMutableMap() - } - - /** Indicates the method used to authenticate the cardholder. */ - fun authenticationMethod(authenticationMethod: AuthenticationMethod) = - authenticationMethod(JsonField.of(authenticationMethod)) - - /** - * Sets [Builder.authenticationMethod] to an arbitrary JSON value. - * - * You should usually call [Builder.authenticationMethod] with a well-typed - * [AuthenticationMethod] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun authenticationMethod(authenticationMethod: JsonField) = - apply { - this.authenticationMethod = authenticationMethod - } - - /** Indicates the outcome of the 3DS authentication process. */ - fun authenticationResult(authenticationResult: AuthenticationResult) = - authenticationResult(JsonField.of(authenticationResult)) - - /** - * Sets [Builder.authenticationResult] to an arbitrary JSON value. - * - * You should usually call [Builder.authenticationResult] with a well-typed - * [AuthenticationResult] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun authenticationResult(authenticationResult: JsonField) = - apply { - this.authenticationResult = authenticationResult - } - - /** Indicates which party made the 3DS authentication decision. */ - fun decisionMadeBy(decisionMadeBy: DecisionMadeBy) = - decisionMadeBy(JsonField.of(decisionMadeBy)) - - /** - * Sets [Builder.decisionMadeBy] to an arbitrary JSON value. - * - * You should usually call [Builder.decisionMadeBy] with a well-typed [DecisionMadeBy] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun decisionMadeBy(decisionMadeBy: JsonField) = apply { - this.decisionMadeBy = decisionMadeBy - } - - /** - * Indicates whether chargeback liability shift applies to the transaction. Possible - * enum values: - * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure - * flow, chargeback liability shift applies. - * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant - * is liable. - * * `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated - * cryptography, possibly recurring. Chargeback liability shift to the issuer applies. - */ - fun liabilityShift(liabilityShift: LiabilityShift) = - liabilityShift(JsonField.of(liabilityShift)) - - /** - * Sets [Builder.liabilityShift] to an arbitrary JSON value. - * - * You should usually call [Builder.liabilityShift] with a well-typed [LiabilityShift] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun liabilityShift(liabilityShift: JsonField) = apply { - this.liabilityShift = liabilityShift - } - - /** - * Unique identifier you can use to match a given 3DS authentication (available via the - * three_ds_authentication.created event webhook) and the transaction. Note that in - * cases where liability shift does not occur, this token is matched to the transaction - * on a best-effort basis. - */ - fun threeDSAuthenticationToken(threeDSAuthenticationToken: String?) = - threeDSAuthenticationToken(JsonField.ofNullable(threeDSAuthenticationToken)) - - /** - * Alias for calling [Builder.threeDSAuthenticationToken] with - * `threeDSAuthenticationToken.orElse(null)`. - */ - fun threeDSAuthenticationToken(threeDSAuthenticationToken: Optional) = - threeDSAuthenticationToken(threeDSAuthenticationToken.getOrNull()) - - /** - * Sets [Builder.threeDSAuthenticationToken] to an arbitrary JSON value. - * - * You should usually call [Builder.threeDSAuthenticationToken] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun threeDSAuthenticationToken(threeDSAuthenticationToken: JsonField) = apply { - this.threeDSAuthenticationToken = threeDSAuthenticationToken - } - - 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 [CardholderAuthentication]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .authenticationMethod() - * .authenticationResult() - * .decisionMadeBy() - * .liabilityShift() - * .threeDSAuthenticationToken() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CardholderAuthentication = - CardholderAuthentication( - checkRequired("authenticationMethod", authenticationMethod), - checkRequired("authenticationResult", authenticationResult), - checkRequired("decisionMadeBy", decisionMadeBy), - checkRequired("liabilityShift", liabilityShift), - checkRequired("threeDSAuthenticationToken", threeDSAuthenticationToken), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CardholderAuthentication = apply { - if (validated) { - return@apply - } - - authenticationMethod().validate() - authenticationResult().validate() - decisionMadeBy().validate() - liabilityShift().validate() - threeDSAuthenticationToken() - 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 = - (authenticationMethod.asKnown().getOrNull()?.validity() ?: 0) + - (authenticationResult.asKnown().getOrNull()?.validity() ?: 0) + - (decisionMadeBy.asKnown().getOrNull()?.validity() ?: 0) + - (liabilityShift.asKnown().getOrNull()?.validity() ?: 0) + - (if (threeDSAuthenticationToken.asKnown().isPresent) 1 else 0) - - /** Indicates the method used to authenticate the cardholder. */ - class AuthenticationMethod - @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 FRICTIONLESS = of("FRICTIONLESS") - - @JvmField val CHALLENGE = of("CHALLENGE") - - @JvmField val NONE = of("NONE") - - @JvmStatic fun of(value: String) = AuthenticationMethod(JsonField.of(value)) - } - - /** An enum containing [AuthenticationMethod]'s known values. */ - enum class Known { - FRICTIONLESS, - CHALLENGE, - NONE, - } - - /** - * An enum containing [AuthenticationMethod]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AuthenticationMethod] 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 { - FRICTIONLESS, - CHALLENGE, - NONE, - /** - * An enum member indicating that [AuthenticationMethod] 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) { - FRICTIONLESS -> Value.FRICTIONLESS - CHALLENGE -> Value.CHALLENGE - NONE -> Value.NONE - 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) { - FRICTIONLESS -> Known.FRICTIONLESS - CHALLENGE -> Known.CHALLENGE - NONE -> Known.NONE - else -> throw LithicInvalidDataException("Unknown AuthenticationMethod: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): AuthenticationMethod = 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 AuthenticationMethod && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Indicates the outcome of the 3DS authentication process. */ - class AuthenticationResult - @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 ATTEMPTS = of("ATTEMPTS") - - @JvmField val DECLINE = of("DECLINE") - - @JvmField val NONE = of("NONE") - - @JvmField val SUCCESS = of("SUCCESS") - - @JvmStatic fun of(value: String) = AuthenticationResult(JsonField.of(value)) - } - - /** An enum containing [AuthenticationResult]'s known values. */ - enum class Known { - ATTEMPTS, - DECLINE, - NONE, - SUCCESS, - } - - /** - * An enum containing [AuthenticationResult]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AuthenticationResult] 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 { - ATTEMPTS, - DECLINE, - NONE, - SUCCESS, - /** - * An enum member indicating that [AuthenticationResult] 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) { - ATTEMPTS -> Value.ATTEMPTS - DECLINE -> Value.DECLINE - NONE -> Value.NONE - SUCCESS -> Value.SUCCESS - 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) { - ATTEMPTS -> Known.ATTEMPTS - DECLINE -> Known.DECLINE - NONE -> Known.NONE - SUCCESS -> Known.SUCCESS - else -> throw LithicInvalidDataException("Unknown AuthenticationResult: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): AuthenticationResult = 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 AuthenticationResult && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Indicates which party made the 3DS authentication decision. */ - class DecisionMadeBy - @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 CUSTOMER_RULES = of("CUSTOMER_RULES") - - @JvmField val CUSTOMER_ENDPOINT = of("CUSTOMER_ENDPOINT") - - @JvmField val LITHIC_DEFAULT = of("LITHIC_DEFAULT") - - @JvmField val LITHIC_RULES = of("LITHIC_RULES") - - @JvmField val NETWORK = of("NETWORK") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = DecisionMadeBy(JsonField.of(value)) - } - - /** An enum containing [DecisionMadeBy]'s known values. */ - enum class Known { - CUSTOMER_RULES, - CUSTOMER_ENDPOINT, - LITHIC_DEFAULT, - LITHIC_RULES, - NETWORK, - UNKNOWN, - } - - /** - * An enum containing [DecisionMadeBy]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [DecisionMadeBy] 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 { - CUSTOMER_RULES, - CUSTOMER_ENDPOINT, - LITHIC_DEFAULT, - LITHIC_RULES, - NETWORK, - UNKNOWN, - /** - * An enum member indicating that [DecisionMadeBy] 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) { - CUSTOMER_RULES -> Value.CUSTOMER_RULES - CUSTOMER_ENDPOINT -> Value.CUSTOMER_ENDPOINT - LITHIC_DEFAULT -> Value.LITHIC_DEFAULT - LITHIC_RULES -> Value.LITHIC_RULES - NETWORK -> Value.NETWORK - 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) { - CUSTOMER_RULES -> Known.CUSTOMER_RULES - CUSTOMER_ENDPOINT -> Known.CUSTOMER_ENDPOINT - LITHIC_DEFAULT -> Known.LITHIC_DEFAULT - LITHIC_RULES -> Known.LITHIC_RULES - NETWORK -> Known.NETWORK - UNKNOWN -> Known.UNKNOWN - else -> throw LithicInvalidDataException("Unknown DecisionMadeBy: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): DecisionMadeBy = 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 DecisionMadeBy && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Indicates whether chargeback liability shift applies to the transaction. Possible enum - * values: - * * `3DS_AUTHENTICATED`: The transaction was fully authenticated through a 3-D Secure flow, - * chargeback liability shift applies. - * * `NONE`: Chargeback liability shift has not shifted to the issuer, i.e. the merchant is - * liable. - * * `TOKEN_AUTHENTICATED`: The transaction was a tokenized payment with validated - * cryptography, possibly recurring. Chargeback liability shift to the issuer applies. - */ - class LiabilityShift - @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 _3DS_AUTHENTICATED = of("3DS_AUTHENTICATED") - - @JvmField val TOKEN_AUTHENTICATED = of("TOKEN_AUTHENTICATED") - - @JvmField val NONE = of("NONE") - - @JvmStatic fun of(value: String) = LiabilityShift(JsonField.of(value)) - } - - /** An enum containing [LiabilityShift]'s known values. */ - enum class Known { - _3DS_AUTHENTICATED, - TOKEN_AUTHENTICATED, - NONE, - } - - /** - * An enum containing [LiabilityShift]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [LiabilityShift] 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 { - _3DS_AUTHENTICATED, - TOKEN_AUTHENTICATED, - NONE, - /** - * An enum member indicating that [LiabilityShift] 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) { - _3DS_AUTHENTICATED -> Value._3DS_AUTHENTICATED - TOKEN_AUTHENTICATED -> Value.TOKEN_AUTHENTICATED - NONE -> Value.NONE - 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) { - _3DS_AUTHENTICATED -> Known._3DS_AUTHENTICATED - TOKEN_AUTHENTICATED -> Known.TOKEN_AUTHENTICATED - NONE -> Known.NONE - else -> throw LithicInvalidDataException("Unknown LiabilityShift: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): LiabilityShift = 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 LiabilityShift && 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 CardholderAuthentication && - authenticationMethod == other.authenticationMethod && - authenticationResult == other.authenticationResult && - decisionMadeBy == other.decisionMadeBy && - liabilityShift == other.liabilityShift && - threeDSAuthenticationToken == other.threeDSAuthenticationToken && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - authenticationMethod, - authenticationResult, - decisionMadeBy, - liabilityShift, - threeDSAuthenticationToken, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CardholderAuthentication{authenticationMethod=$authenticationMethod, authenticationResult=$authenticationResult, decisionMadeBy=$decisionMadeBy, liabilityShift=$liabilityShift, threeDSAuthenticationToken=$threeDSAuthenticationToken, additionalProperties=$additionalProperties}" - } - /** * Card network of the authorization. Value is `UNKNOWN` when Lithic cannot determine the * network code from the upstream provider. @@ -6355,341 +5361,6 @@ private constructor( override fun toString() = value.toString() } - class TokenInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val walletType: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("wallet_type") - @ExcludeMissing - walletType: JsonField = JsonMissing.of() - ) : this(walletType, mutableMapOf()) - - /** - * The wallet_type field will indicate the source of the token. Possible token sources - * include digital wallets (Apple, Google, or Samsung Pay), merchant tokenization, and - * “other” sources like in-flight commerce. Masterpass is not currently supported and is - * included for future use. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun walletType(): WalletType = walletType.getRequired("wallet_type") - - /** - * Returns the raw JSON value of [walletType]. - * - * Unlike [walletType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("wallet_type") - @ExcludeMissing - fun _walletType(): JsonField = walletType - - @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 [TokenInfo]. - * - * The following fields are required: - * ```java - * .walletType() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenInfo]. */ - class Builder internal constructor() { - - private var walletType: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tokenInfo: TokenInfo) = apply { - walletType = tokenInfo.walletType - additionalProperties = tokenInfo.additionalProperties.toMutableMap() - } - - /** - * The wallet_type field will indicate the source of the token. Possible token sources - * include digital wallets (Apple, Google, or Samsung Pay), merchant tokenization, and - * “other” sources like in-flight commerce. Masterpass is not currently supported and is - * included for future use. - */ - fun walletType(walletType: WalletType) = walletType(JsonField.of(walletType)) - - /** - * Sets [Builder.walletType] to an arbitrary JSON value. - * - * You should usually call [Builder.walletType] with a well-typed [WalletType] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun walletType(walletType: JsonField) = apply { - this.walletType = walletType - } - - 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 [TokenInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .walletType() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TokenInfo = - TokenInfo( - checkRequired("walletType", walletType), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TokenInfo = apply { - if (validated) { - return@apply - } - - walletType().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 = (walletType.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The wallet_type field will indicate the source of the token. Possible token sources - * include digital wallets (Apple, Google, or Samsung Pay), merchant tokenization, and - * “other” sources like in-flight commerce. Masterpass is not currently supported and is - * included for future use. - */ - class WalletType @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 APPLE_PAY = of("APPLE_PAY") - - @JvmField val GOOGLE_PAY = of("GOOGLE_PAY") - - @JvmField val MASTERPASS = of("MASTERPASS") - - @JvmField val MERCHANT = of("MERCHANT") - - @JvmField val OTHER = of("OTHER") - - @JvmField val SAMSUNG_PAY = of("SAMSUNG_PAY") - - @JvmStatic fun of(value: String) = WalletType(JsonField.of(value)) - } - - /** An enum containing [WalletType]'s known values. */ - enum class Known { - APPLE_PAY, - GOOGLE_PAY, - MASTERPASS, - MERCHANT, - OTHER, - SAMSUNG_PAY, - } - - /** - * An enum containing [WalletType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [WalletType] 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 { - APPLE_PAY, - GOOGLE_PAY, - MASTERPASS, - MERCHANT, - OTHER, - SAMSUNG_PAY, - /** - * An enum member indicating that [WalletType] 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) { - APPLE_PAY -> Value.APPLE_PAY - GOOGLE_PAY -> Value.GOOGLE_PAY - MASTERPASS -> Value.MASTERPASS - MERCHANT -> Value.MERCHANT - OTHER -> Value.OTHER - SAMSUNG_PAY -> Value.SAMSUNG_PAY - 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) { - APPLE_PAY -> Known.APPLE_PAY - GOOGLE_PAY -> Known.GOOGLE_PAY - MASTERPASS -> Known.MASTERPASS - MERCHANT -> Known.MERCHANT - OTHER -> Known.OTHER - SAMSUNG_PAY -> Known.SAMSUNG_PAY - else -> throw LithicInvalidDataException("Unknown WalletType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): WalletType = 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 WalletType && 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 TokenInfo && - walletType == other.walletType && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(walletType, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TokenInfo{walletType=$walletType, additionalProperties=$additionalProperties}" - } - class TransactionEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/WalletDecisioningInfo.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/WalletDecisioningInfo.kt new file mode 100644 index 000000000..68c09eab4 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/WalletDecisioningInfo.kt @@ -0,0 +1,357 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class WalletDecisioningInfo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountScore: JsonField, + private val deviceScore: JsonField, + private val recommendedDecision: JsonField, + private val recommendationReasons: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_score") + @ExcludeMissing + accountScore: JsonField = JsonMissing.of(), + @JsonProperty("device_score") + @ExcludeMissing + deviceScore: JsonField = JsonMissing.of(), + @JsonProperty("recommended_decision") + @ExcludeMissing + recommendedDecision: JsonField = JsonMissing.of(), + @JsonProperty("recommendation_reasons") + @ExcludeMissing + recommendationReasons: JsonField> = JsonMissing.of(), + ) : this(accountScore, deviceScore, recommendedDecision, recommendationReasons, mutableMapOf()) + + /** + * Score given to the account by the Wallet Provider + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountScore(): Optional = accountScore.getOptional("account_score") + + /** + * Score given to the device by the Wallet Provider + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deviceScore(): Optional = deviceScore.getOptional("device_score") + + /** + * The decision recommended by the Wallet Provider + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recommendedDecision(): Optional = + recommendedDecision.getOptional("recommended_decision") + + /** + * Reasons provided to the Wallet Provider on how the recommended decision was reached + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recommendationReasons(): Optional> = + recommendationReasons.getOptional("recommendation_reasons") + + /** + * Returns the raw JSON value of [accountScore]. + * + * Unlike [accountScore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_score") + @ExcludeMissing + fun _accountScore(): JsonField = accountScore + + /** + * Returns the raw JSON value of [deviceScore]. + * + * Unlike [deviceScore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device_score") + @ExcludeMissing + fun _deviceScore(): JsonField = deviceScore + + /** + * Returns the raw JSON value of [recommendedDecision]. + * + * Unlike [recommendedDecision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("recommended_decision") + @ExcludeMissing + fun _recommendedDecision(): JsonField = recommendedDecision + + /** + * Returns the raw JSON value of [recommendationReasons]. + * + * Unlike [recommendationReasons], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("recommendation_reasons") + @ExcludeMissing + fun _recommendationReasons(): JsonField> = recommendationReasons + + @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 [WalletDecisioningInfo]. + * + * The following fields are required: + * ```java + * .accountScore() + * .deviceScore() + * .recommendedDecision() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WalletDecisioningInfo]. */ + class Builder internal constructor() { + + private var accountScore: JsonField? = null + private var deviceScore: JsonField? = null + private var recommendedDecision: JsonField? = null + private var recommendationReasons: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(walletDecisioningInfo: WalletDecisioningInfo) = apply { + accountScore = walletDecisioningInfo.accountScore + deviceScore = walletDecisioningInfo.deviceScore + recommendedDecision = walletDecisioningInfo.recommendedDecision + recommendationReasons = + walletDecisioningInfo.recommendationReasons.map { it.toMutableList() } + additionalProperties = walletDecisioningInfo.additionalProperties.toMutableMap() + } + + /** Score given to the account by the Wallet Provider */ + fun accountScore(accountScore: String?) = accountScore(JsonField.ofNullable(accountScore)) + + /** Alias for calling [Builder.accountScore] with `accountScore.orElse(null)`. */ + fun accountScore(accountScore: Optional) = accountScore(accountScore.getOrNull()) + + /** + * Sets [Builder.accountScore] to an arbitrary JSON value. + * + * You should usually call [Builder.accountScore] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountScore(accountScore: JsonField) = apply { + this.accountScore = accountScore + } + + /** Score given to the device by the Wallet Provider */ + fun deviceScore(deviceScore: String?) = deviceScore(JsonField.ofNullable(deviceScore)) + + /** Alias for calling [Builder.deviceScore] with `deviceScore.orElse(null)`. */ + fun deviceScore(deviceScore: Optional) = deviceScore(deviceScore.getOrNull()) + + /** + * Sets [Builder.deviceScore] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceScore] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun deviceScore(deviceScore: JsonField) = apply { this.deviceScore = deviceScore } + + /** The decision recommended by the Wallet Provider */ + fun recommendedDecision(recommendedDecision: String?) = + recommendedDecision(JsonField.ofNullable(recommendedDecision)) + + /** + * Alias for calling [Builder.recommendedDecision] with `recommendedDecision.orElse(null)`. + */ + fun recommendedDecision(recommendedDecision: Optional) = + recommendedDecision(recommendedDecision.getOrNull()) + + /** + * Sets [Builder.recommendedDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.recommendedDecision] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recommendedDecision(recommendedDecision: JsonField) = apply { + this.recommendedDecision = recommendedDecision + } + + /** Reasons provided to the Wallet Provider on how the recommended decision was reached */ + fun recommendationReasons(recommendationReasons: List?) = + recommendationReasons(JsonField.ofNullable(recommendationReasons)) + + /** + * Alias for calling [Builder.recommendationReasons] with + * `recommendationReasons.orElse(null)`. + */ + fun recommendationReasons(recommendationReasons: Optional>) = + recommendationReasons(recommendationReasons.getOrNull()) + + /** + * Sets [Builder.recommendationReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.recommendationReasons] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun recommendationReasons(recommendationReasons: JsonField>) = apply { + this.recommendationReasons = recommendationReasons.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [recommendationReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRecommendationReason(recommendationReason: String) = apply { + recommendationReasons = + (recommendationReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("recommendationReasons", it).add(recommendationReason) + } + } + + 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 [WalletDecisioningInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountScore() + * .deviceScore() + * .recommendedDecision() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WalletDecisioningInfo = + WalletDecisioningInfo( + checkRequired("accountScore", accountScore), + checkRequired("deviceScore", deviceScore), + checkRequired("recommendedDecision", recommendedDecision), + (recommendationReasons ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WalletDecisioningInfo = apply { + if (validated) { + return@apply + } + + accountScore() + deviceScore() + recommendedDecision() + recommendationReasons() + 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 (accountScore.asKnown().isPresent) 1 else 0) + + (if (deviceScore.asKnown().isPresent) 1 else 0) + + (if (recommendedDecision.asKnown().isPresent) 1 else 0) + + (recommendationReasons.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WalletDecisioningInfo && + accountScore == other.accountScore && + deviceScore == other.deviceScore && + recommendedDecision == other.recommendedDecision && + recommendationReasons == other.recommendationReasons && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountScore, + deviceScore, + recommendedDecision, + recommendationReasons, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WalletDecisioningInfo{accountScore=$accountScore, deviceScore=$deviceScore, recommendedDecision=$recommendedDecision, recommendationReasons=$recommendationReasons, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsync.kt new file mode 100644 index 000000000..e21cf894f --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsync.kt @@ -0,0 +1,251 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.CardBulkOrder +import com.lithic.api.models.CardBulkOrderCreateParams +import com.lithic.api.models.CardBulkOrderListPageAsync +import com.lithic.api.models.CardBulkOrderListParams +import com.lithic.api.models.CardBulkOrderRetrieveParams +import com.lithic.api.models.CardBulkOrderUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardBulkOrderServiceAsync { + + /** + * 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): CardBulkOrderServiceAsync + + /** + * Create a new bulk order for physical card shipments **[BETA]**. Cards can be added to the + * order via the POST /v1/cards endpoint by specifying the bulk_order_token. Lock the order via + * PATCH /v1/card_bulk_orders/{bulk_order_token} to prepare for shipment. Please work with your + * Customer Success Manager and card personalization bureau to ensure bulk shipping is supported + * for your program. + */ + fun create(params: CardBulkOrderCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardBulkOrderCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Retrieve a specific bulk order by token **[BETA]** */ + fun retrieve(bulkOrderToken: String): CompletableFuture = + retrieve(bulkOrderToken, CardBulkOrderRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + bulkOrderToken: String, + params: CardBulkOrderRetrieveParams = CardBulkOrderRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().bulkOrderToken(bulkOrderToken).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + bulkOrderToken: String, + params: CardBulkOrderRetrieveParams = CardBulkOrderRetrieveParams.none(), + ): CompletableFuture = retrieve(bulkOrderToken, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardBulkOrderRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: CardBulkOrderRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + bulkOrderToken: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(bulkOrderToken, CardBulkOrderRetrieveParams.none(), requestOptions) + + /** + * Update a bulk order **[BETA]**. Primarily used to lock the order, preventing additional cards + * from being added + */ + fun update( + bulkOrderToken: String, + params: CardBulkOrderUpdateParams, + ): CompletableFuture = update(bulkOrderToken, params, RequestOptions.none()) + + /** @see update */ + fun update( + bulkOrderToken: String, + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().bulkOrderToken(bulkOrderToken).build(), requestOptions) + + /** @see update */ + fun update(params: CardBulkOrderUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** List bulk orders for physical card shipments **[BETA]** */ + fun list(): CompletableFuture = list(CardBulkOrderListParams.none()) + + /** @see list */ + fun list( + params: CardBulkOrderListParams = CardBulkOrderListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: CardBulkOrderListParams = CardBulkOrderListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(CardBulkOrderListParams.none(), requestOptions) + + /** + * A view of [CardBulkOrderServiceAsync] 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 + ): CardBulkOrderServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/card_bulk_orders`, but is otherwise the same as + * [CardBulkOrderServiceAsync.create]. + */ + fun create( + params: CardBulkOrderCreateParams + ): CompletableFuture> = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardBulkOrderCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/card_bulk_orders/{bulk_order_token}`, but is + * otherwise the same as [CardBulkOrderServiceAsync.retrieve]. + */ + fun retrieve(bulkOrderToken: String): CompletableFuture> = + retrieve(bulkOrderToken, CardBulkOrderRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + bulkOrderToken: String, + params: CardBulkOrderRetrieveParams = CardBulkOrderRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().bulkOrderToken(bulkOrderToken).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + bulkOrderToken: String, + params: CardBulkOrderRetrieveParams = CardBulkOrderRetrieveParams.none(), + ): CompletableFuture> = + retrieve(bulkOrderToken, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardBulkOrderRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: CardBulkOrderRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + bulkOrderToken: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(bulkOrderToken, CardBulkOrderRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /v1/card_bulk_orders/{bulk_order_token}`, but is + * otherwise the same as [CardBulkOrderServiceAsync.update]. + */ + fun update( + bulkOrderToken: String, + params: CardBulkOrderUpdateParams, + ): CompletableFuture> = + update(bulkOrderToken, params, RequestOptions.none()) + + /** @see update */ + fun update( + bulkOrderToken: String, + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().bulkOrderToken(bulkOrderToken).build(), requestOptions) + + /** @see update */ + fun update( + params: CardBulkOrderUpdateParams + ): CompletableFuture> = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /v1/card_bulk_orders`, but is otherwise the same as + * [CardBulkOrderServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(CardBulkOrderListParams.none()) + + /** @see list */ + fun list( + params: CardBulkOrderListParams = CardBulkOrderListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: CardBulkOrderListParams = CardBulkOrderListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(CardBulkOrderListParams.none(), requestOptions) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsyncImpl.kt new file mode 100644 index 000000000..b7d4b07e8 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsyncImpl.kt @@ -0,0 +1,219 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.handlers.jsonHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.core.http.json +import com.lithic.api.core.http.parseable +import com.lithic.api.core.prepareAsync +import com.lithic.api.models.CardBulkOrder +import com.lithic.api.models.CardBulkOrderCreateParams +import com.lithic.api.models.CardBulkOrderListPageAsync +import com.lithic.api.models.CardBulkOrderListPageResponse +import com.lithic.api.models.CardBulkOrderListParams +import com.lithic.api.models.CardBulkOrderRetrieveParams +import com.lithic.api.models.CardBulkOrderUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardBulkOrderServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CardBulkOrderServiceAsync { + + private val withRawResponse: CardBulkOrderServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardBulkOrderServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardBulkOrderServiceAsync = + CardBulkOrderServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardBulkOrderCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/card_bulk_orders + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: CardBulkOrderRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/card_bulk_orders/{bulk_order_token} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /v1/card_bulk_orders/{bulk_order_token} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: CardBulkOrderListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /v1/card_bulk_orders + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardBulkOrderServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardBulkOrderServiceAsync.WithRawResponse = + CardBulkOrderServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardBulkOrderCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "card_bulk_orders") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CardBulkOrderRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkOrderToken", params.bulkOrderToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "card_bulk_orders", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkOrderToken", params.bulkOrderToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "card_bulk_orders", params._pathParam(0)) + .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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardBulkOrderListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "card_bulk_orders") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CardBulkOrderListPageAsync.builder() + .service(CardBulkOrderServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsync.kt index b014de4b9..ad0625da3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsync.kt @@ -5,6 +5,7 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.ExternalBankAccount import com.lithic.api.models.ExternalBankAccountCreateParams import com.lithic.api.models.ExternalBankAccountCreateResponse import com.lithic.api.models.ExternalBankAccountListPageAsync @@ -14,9 +15,7 @@ import com.lithic.api.models.ExternalBankAccountRetrieveResponse import com.lithic.api.models.ExternalBankAccountRetryMicroDepositsParams import com.lithic.api.models.ExternalBankAccountRetryMicroDepositsResponse import com.lithic.api.models.ExternalBankAccountRetryPrenoteParams -import com.lithic.api.models.ExternalBankAccountRetryPrenoteResponse import com.lithic.api.models.ExternalBankAccountUnpauseParams -import com.lithic.api.models.ExternalBankAccountUnpauseResponse import com.lithic.api.models.ExternalBankAccountUpdateParams import com.lithic.api.models.ExternalBankAccountUpdateResponse import com.lithic.api.services.async.externalBankAccounts.MicroDepositServiceAsync @@ -217,9 +216,7 @@ interface ExternalBankAccountServiceAsync { ) /** Retry external bank account prenote verification. */ - fun retryPrenote( - externalBankAccountToken: String - ): CompletableFuture = + fun retryPrenote(externalBankAccountToken: String): CompletableFuture = retryPrenote(externalBankAccountToken, ExternalBankAccountRetryPrenoteParams.none()) /** @see retryPrenote */ @@ -228,7 +225,7 @@ interface ExternalBankAccountServiceAsync { params: ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retryPrenote( params.toBuilder().externalBankAccountToken(externalBankAccountToken).build(), requestOptions, @@ -238,26 +235,25 @@ interface ExternalBankAccountServiceAsync { fun retryPrenote( externalBankAccountToken: String, params: ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams.none(), - ): CompletableFuture = + ): CompletableFuture = retryPrenote(externalBankAccountToken, params, RequestOptions.none()) /** @see retryPrenote */ fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retryPrenote */ fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams - ): CompletableFuture = - retryPrenote(params, RequestOptions.none()) + ): CompletableFuture = retryPrenote(params, RequestOptions.none()) /** @see retryPrenote */ fun retryPrenote( externalBankAccountToken: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = retryPrenote( externalBankAccountToken, ExternalBankAccountRetryPrenoteParams.none(), @@ -265,9 +261,7 @@ interface ExternalBankAccountServiceAsync { ) /** Unpause an external bank account */ - fun unpause( - externalBankAccountToken: String - ): CompletableFuture = + fun unpause(externalBankAccountToken: String): CompletableFuture = unpause(externalBankAccountToken, ExternalBankAccountUnpauseParams.none()) /** @see unpause */ @@ -275,7 +269,7 @@ interface ExternalBankAccountServiceAsync { externalBankAccountToken: String, params: ExternalBankAccountUnpauseParams = ExternalBankAccountUnpauseParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = unpause( params.toBuilder().externalBankAccountToken(externalBankAccountToken).build(), requestOptions, @@ -285,26 +279,24 @@ interface ExternalBankAccountServiceAsync { fun unpause( externalBankAccountToken: String, params: ExternalBankAccountUnpauseParams = ExternalBankAccountUnpauseParams.none(), - ): CompletableFuture = + ): CompletableFuture = unpause(externalBankAccountToken, params, RequestOptions.none()) /** @see unpause */ fun unpause( params: ExternalBankAccountUnpauseParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see unpause */ - fun unpause( - params: ExternalBankAccountUnpauseParams - ): CompletableFuture = + fun unpause(params: ExternalBankAccountUnpauseParams): CompletableFuture = unpause(params, RequestOptions.none()) /** @see unpause */ fun unpause( externalBankAccountToken: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = unpause(externalBankAccountToken, ExternalBankAccountUnpauseParams.none(), requestOptions) /** @@ -535,7 +527,7 @@ interface ExternalBankAccountServiceAsync { */ fun retryPrenote( externalBankAccountToken: String - ): CompletableFuture> = + ): CompletableFuture> = retryPrenote(externalBankAccountToken, ExternalBankAccountRetryPrenoteParams.none()) /** @see retryPrenote */ @@ -544,7 +536,7 @@ interface ExternalBankAccountServiceAsync { params: ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = retryPrenote( params.toBuilder().externalBankAccountToken(externalBankAccountToken).build(), requestOptions, @@ -555,26 +547,26 @@ interface ExternalBankAccountServiceAsync { externalBankAccountToken: String, params: ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = retryPrenote(externalBankAccountToken, params, RequestOptions.none()) /** @see retryPrenote */ fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see retryPrenote */ fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams - ): CompletableFuture> = + ): CompletableFuture> = retryPrenote(params, RequestOptions.none()) /** @see retryPrenote */ fun retryPrenote( externalBankAccountToken: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = retryPrenote( externalBankAccountToken, ExternalBankAccountRetryPrenoteParams.none(), @@ -588,7 +580,7 @@ interface ExternalBankAccountServiceAsync { */ fun unpause( externalBankAccountToken: String - ): CompletableFuture> = + ): CompletableFuture> = unpause(externalBankAccountToken, ExternalBankAccountUnpauseParams.none()) /** @see unpause */ @@ -596,7 +588,7 @@ interface ExternalBankAccountServiceAsync { externalBankAccountToken: String, params: ExternalBankAccountUnpauseParams = ExternalBankAccountUnpauseParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = unpause( params.toBuilder().externalBankAccountToken(externalBankAccountToken).build(), requestOptions, @@ -606,26 +598,26 @@ interface ExternalBankAccountServiceAsync { fun unpause( externalBankAccountToken: String, params: ExternalBankAccountUnpauseParams = ExternalBankAccountUnpauseParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = unpause(externalBankAccountToken, params, RequestOptions.none()) /** @see unpause */ fun unpause( params: ExternalBankAccountUnpauseParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see unpause */ fun unpause( params: ExternalBankAccountUnpauseParams - ): CompletableFuture> = + ): CompletableFuture> = unpause(params, RequestOptions.none()) /** @see unpause */ fun unpause( externalBankAccountToken: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = unpause( externalBankAccountToken, ExternalBankAccountUnpauseParams.none(), diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncImpl.kt index 2fe1f632c..92e745fc9 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncImpl.kt @@ -16,6 +16,7 @@ import com.lithic.api.core.http.HttpResponseFor 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.ExternalBankAccount import com.lithic.api.models.ExternalBankAccountCreateParams import com.lithic.api.models.ExternalBankAccountCreateResponse import com.lithic.api.models.ExternalBankAccountListPageAsync @@ -26,9 +27,7 @@ import com.lithic.api.models.ExternalBankAccountRetrieveResponse import com.lithic.api.models.ExternalBankAccountRetryMicroDepositsParams import com.lithic.api.models.ExternalBankAccountRetryMicroDepositsResponse import com.lithic.api.models.ExternalBankAccountRetryPrenoteParams -import com.lithic.api.models.ExternalBankAccountRetryPrenoteResponse import com.lithic.api.models.ExternalBankAccountUnpauseParams -import com.lithic.api.models.ExternalBankAccountUnpauseResponse import com.lithic.api.models.ExternalBankAccountUpdateParams import com.lithic.api.models.ExternalBankAccountUpdateResponse import com.lithic.api.services.async.externalBankAccounts.MicroDepositServiceAsync @@ -98,14 +97,14 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc override fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/external_bank_accounts/{external_bank_account_token}/retry_prenote withRawResponse().retryPrenote(params, requestOptions).thenApply { it.parse() } override fun unpause( params: ExternalBankAccountUnpauseParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /v1/external_bank_accounts/{external_bank_account_token}/unpause withRawResponse().unpause(params, requestOptions).thenApply { it.parse() } @@ -304,13 +303,13 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc } } - private val retryPrenoteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retryPrenoteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("externalBankAccountToken", params.externalBankAccountToken().getOrNull()) @@ -343,13 +342,13 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc } } - private val unpauseHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val unpauseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun unpause( params: ExternalBankAccountUnpauseParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("externalBankAccountToken", params.externalBankAccountToken().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsync.kt index 2237a88e5..c6065c771 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsync.kt @@ -5,12 +5,12 @@ package com.lithic.api.services.async import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.FundingEvent import com.lithic.api.models.FundingEventListPageAsync import com.lithic.api.models.FundingEventListParams import com.lithic.api.models.FundingEventRetrieveDetailsParams import com.lithic.api.models.FundingEventRetrieveDetailsResponse import com.lithic.api.models.FundingEventRetrieveParams -import com.lithic.api.models.FundingEventRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -29,7 +29,7 @@ interface FundingEventServiceAsync { fun withOptions(modifier: Consumer): FundingEventServiceAsync /** Get funding event for program by id */ - fun retrieve(fundingEventToken: String): CompletableFuture = + fun retrieve(fundingEventToken: String): CompletableFuture = retrieve(fundingEventToken, FundingEventRetrieveParams.none()) /** @see retrieve */ @@ -37,32 +37,30 @@ interface FundingEventServiceAsync { fundingEventToken: String, params: FundingEventRetrieveParams = FundingEventRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieve(params.toBuilder().fundingEventToken(fundingEventToken).build(), requestOptions) /** @see retrieve */ fun retrieve( fundingEventToken: String, params: FundingEventRetrieveParams = FundingEventRetrieveParams.none(), - ): CompletableFuture = - retrieve(fundingEventToken, params, RequestOptions.none()) + ): CompletableFuture = retrieve(fundingEventToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: FundingEventRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieve */ - fun retrieve( - params: FundingEventRetrieveParams - ): CompletableFuture = retrieve(params, RequestOptions.none()) + fun retrieve(params: FundingEventRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( fundingEventToken: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = retrieve(fundingEventToken, FundingEventRetrieveParams.none(), requestOptions) /** Get all funding events for program */ @@ -145,9 +143,7 @@ interface FundingEventServiceAsync { * Returns a raw HTTP response for `get /v1/funding_events/{funding_event_token}`, but is * otherwise the same as [FundingEventServiceAsync.retrieve]. */ - fun retrieve( - fundingEventToken: String - ): CompletableFuture> = + fun retrieve(fundingEventToken: String): CompletableFuture> = retrieve(fundingEventToken, FundingEventRetrieveParams.none()) /** @see retrieve */ @@ -155,7 +151,7 @@ interface FundingEventServiceAsync { fundingEventToken: String, params: FundingEventRetrieveParams = FundingEventRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve( params.toBuilder().fundingEventToken(fundingEventToken).build(), requestOptions, @@ -165,26 +161,26 @@ interface FundingEventServiceAsync { fun retrieve( fundingEventToken: String, params: FundingEventRetrieveParams = FundingEventRetrieveParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve(fundingEventToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: FundingEventRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see retrieve */ fun retrieve( params: FundingEventRetrieveParams - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( fundingEventToken: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = retrieve(fundingEventToken, FundingEventRetrieveParams.none(), requestOptions) /** diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsyncImpl.kt index f3aa916e0..4b2a51dcb 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/FundingEventServiceAsyncImpl.kt @@ -15,13 +15,13 @@ import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable import com.lithic.api.core.prepareAsync +import com.lithic.api.models.FundingEvent import com.lithic.api.models.FundingEventListPageAsync import com.lithic.api.models.FundingEventListPageResponse import com.lithic.api.models.FundingEventListParams import com.lithic.api.models.FundingEventRetrieveDetailsParams import com.lithic.api.models.FundingEventRetrieveDetailsResponse import com.lithic.api.models.FundingEventRetrieveParams -import com.lithic.api.models.FundingEventRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -41,7 +41,7 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption override fun retrieve( params: FundingEventRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/funding_events/{funding_event_token} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } @@ -72,13 +72,13 @@ class FundingEventServiceAsyncImpl internal constructor(private val clientOption clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: FundingEventRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fundingEventToken", params.fundingEventToken().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/InternalTransactionServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/InternalTransactionServiceAsync.kt new file mode 100644 index 000000000..ffd9ea03a --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/InternalTransactionServiceAsync.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import java.util.function.Consumer + +interface InternalTransactionServiceAsync { + + /** + * 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): InternalTransactionServiceAsync + + /** + * A view of [InternalTransactionServiceAsync] 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 + ): InternalTransactionServiceAsync.WithRawResponse + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/InternalTransactionServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/InternalTransactionServiceAsyncImpl.kt new file mode 100644 index 000000000..7fc8431fa --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/InternalTransactionServiceAsyncImpl.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async + +import com.lithic.api.core.ClientOptions +import java.util.function.Consumer + +class InternalTransactionServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : InternalTransactionServiceAsync { + + private val withRawResponse: InternalTransactionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InternalTransactionServiceAsync.WithRawResponse = + withRawResponse + + override fun withOptions( + modifier: Consumer + ): InternalTransactionServiceAsync = + InternalTransactionServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InternalTransactionServiceAsync.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): InternalTransactionServiceAsync.WithRawResponse = + InternalTransactionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsync.kt index 5376ffade..7c5c85fee 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsync.kt @@ -5,7 +5,7 @@ package com.lithic.api.services.async.reports.settlement import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponseFor -import com.lithic.api.models.NetworkTotalRetrieveResponse +import com.lithic.api.models.NetworkTotal import com.lithic.api.models.ReportSettlementNetworkTotalListPageAsync import com.lithic.api.models.ReportSettlementNetworkTotalListParams import com.lithic.api.models.ReportSettlementNetworkTotalRetrieveParams @@ -27,7 +27,7 @@ interface NetworkTotalServiceAsync { fun withOptions(modifier: Consumer): NetworkTotalServiceAsync /** Retrieve a specific network total record by token. Not available in sandbox. */ - fun retrieve(token: String): CompletableFuture = + fun retrieve(token: String): CompletableFuture = retrieve(token, ReportSettlementNetworkTotalRetrieveParams.none()) /** @see retrieve */ @@ -36,7 +36,7 @@ interface NetworkTotalServiceAsync { params: ReportSettlementNetworkTotalRetrieveParams = ReportSettlementNetworkTotalRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieve(params.toBuilder().token(token).build(), requestOptions) /** @see retrieve */ @@ -44,25 +44,21 @@ interface NetworkTotalServiceAsync { token: String, params: ReportSettlementNetworkTotalRetrieveParams = ReportSettlementNetworkTotalRetrieveParams.none(), - ): CompletableFuture = - retrieve(token, params, RequestOptions.none()) + ): CompletableFuture = retrieve(token, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieve */ fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams - ): CompletableFuture = retrieve(params, RequestOptions.none()) + ): CompletableFuture = retrieve(params, RequestOptions.none()) /** @see retrieve */ - fun retrieve( - token: String, - requestOptions: RequestOptions, - ): CompletableFuture = + fun retrieve(token: String, requestOptions: RequestOptions): CompletableFuture = retrieve(token, ReportSettlementNetworkTotalRetrieveParams.none(), requestOptions) /** List network total records with optional filters. Not available in sandbox. */ @@ -108,9 +104,7 @@ interface NetworkTotalServiceAsync { * Returns a raw HTTP response for `get /v1/reports/settlement/network_totals/{token}`, but * is otherwise the same as [NetworkTotalServiceAsync.retrieve]. */ - fun retrieve( - token: String - ): CompletableFuture> = + fun retrieve(token: String): CompletableFuture> = retrieve(token, ReportSettlementNetworkTotalRetrieveParams.none()) /** @see retrieve */ @@ -119,7 +113,7 @@ interface NetworkTotalServiceAsync { params: ReportSettlementNetworkTotalRetrieveParams = ReportSettlementNetworkTotalRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params.toBuilder().token(token).build(), requestOptions) /** @see retrieve */ @@ -127,26 +121,26 @@ interface NetworkTotalServiceAsync { token: String, params: ReportSettlementNetworkTotalRetrieveParams = ReportSettlementNetworkTotalRetrieveParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve(token, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see retrieve */ fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( token: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = retrieve(token, ReportSettlementNetworkTotalRetrieveParams.none(), requestOptions) /** diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsyncImpl.kt index 4ea419cce..b3069d859 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/reports/settlement/NetworkTotalServiceAsyncImpl.kt @@ -15,7 +15,7 @@ import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable import com.lithic.api.core.prepareAsync -import com.lithic.api.models.NetworkTotalRetrieveResponse +import com.lithic.api.models.NetworkTotal import com.lithic.api.models.ReportSettlementNetworkTotalListPageAsync import com.lithic.api.models.ReportSettlementNetworkTotalListPageResponse import com.lithic.api.models.ReportSettlementNetworkTotalListParams @@ -39,7 +39,7 @@ class NetworkTotalServiceAsyncImpl internal constructor(private val clientOption override fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/reports/settlement/network_totals/{token} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } @@ -63,13 +63,13 @@ class NetworkTotalServiceAsyncImpl internal constructor(private val clientOption clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("token", params.token().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsync.kt index a455cf8cc..575fa9075 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsync.kt @@ -6,8 +6,8 @@ import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponseFor -import com.lithic.api.models.AuthenticationRetrieveResponse import com.lithic.api.models.AuthenticationSimulateResponse +import com.lithic.api.models.ThreeDSAuthentication import com.lithic.api.models.ThreeDSAuthenticationRetrieveParams import com.lithic.api.models.ThreeDSAuthenticationSimulateOtpEntryParams import com.lithic.api.models.ThreeDSAuthenticationSimulateParams @@ -29,9 +29,7 @@ interface AuthenticationServiceAsync { fun withOptions(modifier: Consumer): AuthenticationServiceAsync /** Get 3DS Authentication by token */ - fun retrieve( - threeDSAuthenticationToken: String - ): CompletableFuture = + fun retrieve(threeDSAuthenticationToken: String): CompletableFuture = retrieve(threeDSAuthenticationToken, ThreeDSAuthenticationRetrieveParams.none()) /** @see retrieve */ @@ -39,7 +37,7 @@ interface AuthenticationServiceAsync { threeDSAuthenticationToken: String, params: ThreeDSAuthenticationRetrieveParams = ThreeDSAuthenticationRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieve( params.toBuilder().threeDSAuthenticationToken(threeDSAuthenticationToken).build(), requestOptions, @@ -49,25 +47,25 @@ interface AuthenticationServiceAsync { fun retrieve( threeDSAuthenticationToken: String, params: ThreeDSAuthenticationRetrieveParams = ThreeDSAuthenticationRetrieveParams.none(), - ): CompletableFuture = + ): CompletableFuture = retrieve(threeDSAuthenticationToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: ThreeDSAuthenticationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** @see retrieve */ fun retrieve( params: ThreeDSAuthenticationRetrieveParams - ): CompletableFuture = retrieve(params, RequestOptions.none()) + ): CompletableFuture = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( threeDSAuthenticationToken: String, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = retrieve( threeDSAuthenticationToken, ThreeDSAuthenticationRetrieveParams.none(), @@ -129,7 +127,7 @@ interface AuthenticationServiceAsync { */ fun retrieve( threeDSAuthenticationToken: String - ): CompletableFuture> = + ): CompletableFuture> = retrieve(threeDSAuthenticationToken, ThreeDSAuthenticationRetrieveParams.none()) /** @see retrieve */ @@ -138,7 +136,7 @@ interface AuthenticationServiceAsync { params: ThreeDSAuthenticationRetrieveParams = ThreeDSAuthenticationRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve( params.toBuilder().threeDSAuthenticationToken(threeDSAuthenticationToken).build(), requestOptions, @@ -148,26 +146,26 @@ interface AuthenticationServiceAsync { fun retrieve( threeDSAuthenticationToken: String, params: ThreeDSAuthenticationRetrieveParams = ThreeDSAuthenticationRetrieveParams.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve(threeDSAuthenticationToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: ThreeDSAuthenticationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** @see retrieve */ fun retrieve( params: ThreeDSAuthenticationRetrieveParams - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( threeDSAuthenticationToken: String, requestOptions: RequestOptions, - ): CompletableFuture> = + ): CompletableFuture> = retrieve( threeDSAuthenticationToken, ThreeDSAuthenticationRetrieveParams.none(), diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncImpl.kt index db24c9692..b34ee87a7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncImpl.kt @@ -17,8 +17,8 @@ import com.lithic.api.core.http.HttpResponseFor 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.AuthenticationRetrieveResponse import com.lithic.api.models.AuthenticationSimulateResponse +import com.lithic.api.models.ThreeDSAuthentication import com.lithic.api.models.ThreeDSAuthenticationRetrieveParams import com.lithic.api.models.ThreeDSAuthenticationSimulateOtpEntryParams import com.lithic.api.models.ThreeDSAuthenticationSimulateParams @@ -43,7 +43,7 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS override fun retrieve( params: ThreeDSAuthenticationRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /v1/three_ds_authentication/{three_ds_authentication_token} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } @@ -74,13 +74,13 @@ internal constructor(private val clientOptions: ClientOptions) : AuthenticationS clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: ThreeDSAuthenticationRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired( diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardBulkOrderService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardBulkOrderService.kt new file mode 100644 index 000000000..6339c2cc2 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardBulkOrderService.kt @@ -0,0 +1,251 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.CardBulkOrder +import com.lithic.api.models.CardBulkOrderCreateParams +import com.lithic.api.models.CardBulkOrderListPage +import com.lithic.api.models.CardBulkOrderListParams +import com.lithic.api.models.CardBulkOrderRetrieveParams +import com.lithic.api.models.CardBulkOrderUpdateParams +import java.util.function.Consumer + +interface CardBulkOrderService { + + /** + * 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): CardBulkOrderService + + /** + * Create a new bulk order for physical card shipments **[BETA]**. Cards can be added to the + * order via the POST /v1/cards endpoint by specifying the bulk_order_token. Lock the order via + * PATCH /v1/card_bulk_orders/{bulk_order_token} to prepare for shipment. Please work with your + * Customer Success Manager and card personalization bureau to ensure bulk shipping is supported + * for your program. + */ + fun create(params: CardBulkOrderCreateParams): CardBulkOrder = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardBulkOrderCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardBulkOrder + + /** Retrieve a specific bulk order by token **[BETA]** */ + fun retrieve(bulkOrderToken: String): CardBulkOrder = + retrieve(bulkOrderToken, CardBulkOrderRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + bulkOrderToken: String, + params: CardBulkOrderRetrieveParams = CardBulkOrderRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardBulkOrder = + retrieve(params.toBuilder().bulkOrderToken(bulkOrderToken).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + bulkOrderToken: String, + params: CardBulkOrderRetrieveParams = CardBulkOrderRetrieveParams.none(), + ): CardBulkOrder = retrieve(bulkOrderToken, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardBulkOrderRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardBulkOrder + + /** @see retrieve */ + fun retrieve(params: CardBulkOrderRetrieveParams): CardBulkOrder = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(bulkOrderToken: String, requestOptions: RequestOptions): CardBulkOrder = + retrieve(bulkOrderToken, CardBulkOrderRetrieveParams.none(), requestOptions) + + /** + * Update a bulk order **[BETA]**. Primarily used to lock the order, preventing additional cards + * from being added + */ + fun update(bulkOrderToken: String, params: CardBulkOrderUpdateParams): CardBulkOrder = + update(bulkOrderToken, params, RequestOptions.none()) + + /** @see update */ + fun update( + bulkOrderToken: String, + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardBulkOrder = + update(params.toBuilder().bulkOrderToken(bulkOrderToken).build(), requestOptions) + + /** @see update */ + fun update(params: CardBulkOrderUpdateParams): CardBulkOrder = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardBulkOrder + + /** List bulk orders for physical card shipments **[BETA]** */ + fun list(): CardBulkOrderListPage = list(CardBulkOrderListParams.none()) + + /** @see list */ + fun list( + params: CardBulkOrderListParams = CardBulkOrderListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardBulkOrderListPage + + /** @see list */ + fun list( + params: CardBulkOrderListParams = CardBulkOrderListParams.none() + ): CardBulkOrderListPage = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CardBulkOrderListPage = + list(CardBulkOrderListParams.none(), requestOptions) + + /** + * A view of [CardBulkOrderService] 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 + ): CardBulkOrderService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/card_bulk_orders`, but is otherwise the same as + * [CardBulkOrderService.create]. + */ + @MustBeClosed + fun create(params: CardBulkOrderCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: CardBulkOrderCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/card_bulk_orders/{bulk_order_token}`, but is + * otherwise the same as [CardBulkOrderService.retrieve]. + */ + @MustBeClosed + fun retrieve(bulkOrderToken: String): HttpResponseFor = + retrieve(bulkOrderToken, CardBulkOrderRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + bulkOrderToken: String, + params: CardBulkOrderRetrieveParams = CardBulkOrderRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().bulkOrderToken(bulkOrderToken).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + bulkOrderToken: String, + params: CardBulkOrderRetrieveParams = CardBulkOrderRetrieveParams.none(), + ): HttpResponseFor = retrieve(bulkOrderToken, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: CardBulkOrderRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: CardBulkOrderRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + bulkOrderToken: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(bulkOrderToken, CardBulkOrderRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /v1/card_bulk_orders/{bulk_order_token}`, but is + * otherwise the same as [CardBulkOrderService.update]. + */ + @MustBeClosed + fun update( + bulkOrderToken: String, + params: CardBulkOrderUpdateParams, + ): HttpResponseFor = update(bulkOrderToken, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + bulkOrderToken: String, + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().bulkOrderToken(bulkOrderToken).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: CardBulkOrderUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /v1/card_bulk_orders`, but is otherwise the same as + * [CardBulkOrderService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(CardBulkOrderListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: CardBulkOrderListParams = CardBulkOrderListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: CardBulkOrderListParams = CardBulkOrderListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(CardBulkOrderListParams.none(), requestOptions) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardBulkOrderServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardBulkOrderServiceImpl.kt new file mode 100644 index 000000000..be14bbd6a --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/CardBulkOrderServiceImpl.kt @@ -0,0 +1,205 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.checkRequired +import com.lithic.api.core.handlers.errorBodyHandler +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.handlers.jsonHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.core.http.json +import com.lithic.api.core.http.parseable +import com.lithic.api.core.prepare +import com.lithic.api.models.CardBulkOrder +import com.lithic.api.models.CardBulkOrderCreateParams +import com.lithic.api.models.CardBulkOrderListPage +import com.lithic.api.models.CardBulkOrderListPageResponse +import com.lithic.api.models.CardBulkOrderListParams +import com.lithic.api.models.CardBulkOrderRetrieveParams +import com.lithic.api.models.CardBulkOrderUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardBulkOrderServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardBulkOrderService { + + private val withRawResponse: CardBulkOrderService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardBulkOrderService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardBulkOrderService = + CardBulkOrderServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardBulkOrderCreateParams, + requestOptions: RequestOptions, + ): CardBulkOrder = + // post /v1/card_bulk_orders + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: CardBulkOrderRetrieveParams, + requestOptions: RequestOptions, + ): CardBulkOrder = + // get /v1/card_bulk_orders/{bulk_order_token} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions, + ): CardBulkOrder = + // patch /v1/card_bulk_orders/{bulk_order_token} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: CardBulkOrderListParams, + requestOptions: RequestOptions, + ): CardBulkOrderListPage = + // get /v1/card_bulk_orders + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardBulkOrderService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardBulkOrderService.WithRawResponse = + CardBulkOrderServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardBulkOrderCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "card_bulk_orders") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: CardBulkOrderRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkOrderToken", params.bulkOrderToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "card_bulk_orders", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: CardBulkOrderUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("bulkOrderToken", params.bulkOrderToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "card_bulk_orders", params._pathParam(0)) + .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 { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardBulkOrderListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "card_bulk_orders") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + CardBulkOrderListPage.builder() + .service(CardBulkOrderServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountService.kt index 641e0eeef..b7ea69e4f 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountService.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountService.kt @@ -6,6 +6,7 @@ import com.google.errorprone.annotations.MustBeClosed import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.ExternalBankAccount import com.lithic.api.models.ExternalBankAccountCreateParams import com.lithic.api.models.ExternalBankAccountCreateResponse import com.lithic.api.models.ExternalBankAccountListPage @@ -15,9 +16,7 @@ import com.lithic.api.models.ExternalBankAccountRetrieveResponse import com.lithic.api.models.ExternalBankAccountRetryMicroDepositsParams import com.lithic.api.models.ExternalBankAccountRetryMicroDepositsResponse import com.lithic.api.models.ExternalBankAccountRetryPrenoteParams -import com.lithic.api.models.ExternalBankAccountRetryPrenoteResponse import com.lithic.api.models.ExternalBankAccountUnpauseParams -import com.lithic.api.models.ExternalBankAccountUnpauseResponse import com.lithic.api.models.ExternalBankAccountUpdateParams import com.lithic.api.models.ExternalBankAccountUpdateResponse import com.lithic.api.services.blocking.externalBankAccounts.MicroDepositService @@ -206,7 +205,7 @@ interface ExternalBankAccountService { ) /** Retry external bank account prenote verification. */ - fun retryPrenote(externalBankAccountToken: String): ExternalBankAccountRetryPrenoteResponse = + fun retryPrenote(externalBankAccountToken: String): ExternalBankAccount = retryPrenote(externalBankAccountToken, ExternalBankAccountRetryPrenoteParams.none()) /** @see retryPrenote */ @@ -215,7 +214,7 @@ interface ExternalBankAccountService { params: ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): ExternalBankAccountRetryPrenoteResponse = + ): ExternalBankAccount = retryPrenote( params.toBuilder().externalBankAccountToken(externalBankAccountToken).build(), requestOptions, @@ -225,25 +224,23 @@ interface ExternalBankAccountService { fun retryPrenote( externalBankAccountToken: String, params: ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams.none(), - ): ExternalBankAccountRetryPrenoteResponse = - retryPrenote(externalBankAccountToken, params, RequestOptions.none()) + ): ExternalBankAccount = retryPrenote(externalBankAccountToken, params, RequestOptions.none()) /** @see retryPrenote */ fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): ExternalBankAccountRetryPrenoteResponse + ): ExternalBankAccount /** @see retryPrenote */ - fun retryPrenote( - params: ExternalBankAccountRetryPrenoteParams - ): ExternalBankAccountRetryPrenoteResponse = retryPrenote(params, RequestOptions.none()) + fun retryPrenote(params: ExternalBankAccountRetryPrenoteParams): ExternalBankAccount = + retryPrenote(params, RequestOptions.none()) /** @see retryPrenote */ fun retryPrenote( externalBankAccountToken: String, requestOptions: RequestOptions, - ): ExternalBankAccountRetryPrenoteResponse = + ): ExternalBankAccount = retryPrenote( externalBankAccountToken, ExternalBankAccountRetryPrenoteParams.none(), @@ -251,7 +248,7 @@ interface ExternalBankAccountService { ) /** Unpause an external bank account */ - fun unpause(externalBankAccountToken: String): ExternalBankAccountUnpauseResponse = + fun unpause(externalBankAccountToken: String): ExternalBankAccount = unpause(externalBankAccountToken, ExternalBankAccountUnpauseParams.none()) /** @see unpause */ @@ -259,7 +256,7 @@ interface ExternalBankAccountService { externalBankAccountToken: String, params: ExternalBankAccountUnpauseParams = ExternalBankAccountUnpauseParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): ExternalBankAccountUnpauseResponse = + ): ExternalBankAccount = unpause( params.toBuilder().externalBankAccountToken(externalBankAccountToken).build(), requestOptions, @@ -269,24 +266,23 @@ interface ExternalBankAccountService { fun unpause( externalBankAccountToken: String, params: ExternalBankAccountUnpauseParams = ExternalBankAccountUnpauseParams.none(), - ): ExternalBankAccountUnpauseResponse = - unpause(externalBankAccountToken, params, RequestOptions.none()) + ): ExternalBankAccount = unpause(externalBankAccountToken, params, RequestOptions.none()) /** @see unpause */ fun unpause( params: ExternalBankAccountUnpauseParams, requestOptions: RequestOptions = RequestOptions.none(), - ): ExternalBankAccountUnpauseResponse + ): ExternalBankAccount /** @see unpause */ - fun unpause(params: ExternalBankAccountUnpauseParams): ExternalBankAccountUnpauseResponse = + fun unpause(params: ExternalBankAccountUnpauseParams): ExternalBankAccount = unpause(params, RequestOptions.none()) /** @see unpause */ fun unpause( externalBankAccountToken: String, requestOptions: RequestOptions, - ): ExternalBankAccountUnpauseResponse = + ): ExternalBankAccount = unpause(externalBankAccountToken, ExternalBankAccountUnpauseParams.none(), requestOptions) /** @@ -539,9 +535,7 @@ interface ExternalBankAccountService { * the same as [ExternalBankAccountService.retryPrenote]. */ @MustBeClosed - fun retryPrenote( - externalBankAccountToken: String - ): HttpResponseFor = + fun retryPrenote(externalBankAccountToken: String): HttpResponseFor = retryPrenote(externalBankAccountToken, ExternalBankAccountRetryPrenoteParams.none()) /** @see retryPrenote */ @@ -551,7 +545,7 @@ interface ExternalBankAccountService { params: ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = retryPrenote( params.toBuilder().externalBankAccountToken(externalBankAccountToken).build(), requestOptions, @@ -563,7 +557,7 @@ interface ExternalBankAccountService { externalBankAccountToken: String, params: ExternalBankAccountRetryPrenoteParams = ExternalBankAccountRetryPrenoteParams.none(), - ): HttpResponseFor = + ): HttpResponseFor = retryPrenote(externalBankAccountToken, params, RequestOptions.none()) /** @see retryPrenote */ @@ -571,21 +565,20 @@ interface ExternalBankAccountService { fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see retryPrenote */ @MustBeClosed fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams - ): HttpResponseFor = - retryPrenote(params, RequestOptions.none()) + ): HttpResponseFor = retryPrenote(params, RequestOptions.none()) /** @see retryPrenote */ @MustBeClosed fun retryPrenote( externalBankAccountToken: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = retryPrenote( externalBankAccountToken, ExternalBankAccountRetryPrenoteParams.none(), @@ -598,9 +591,7 @@ interface ExternalBankAccountService { * same as [ExternalBankAccountService.unpause]. */ @MustBeClosed - fun unpause( - externalBankAccountToken: String - ): HttpResponseFor = + fun unpause(externalBankAccountToken: String): HttpResponseFor = unpause(externalBankAccountToken, ExternalBankAccountUnpauseParams.none()) /** @see unpause */ @@ -609,7 +600,7 @@ interface ExternalBankAccountService { externalBankAccountToken: String, params: ExternalBankAccountUnpauseParams = ExternalBankAccountUnpauseParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = unpause( params.toBuilder().externalBankAccountToken(externalBankAccountToken).build(), requestOptions, @@ -620,7 +611,7 @@ interface ExternalBankAccountService { fun unpause( externalBankAccountToken: String, params: ExternalBankAccountUnpauseParams = ExternalBankAccountUnpauseParams.none(), - ): HttpResponseFor = + ): HttpResponseFor = unpause(externalBankAccountToken, params, RequestOptions.none()) /** @see unpause */ @@ -628,21 +619,20 @@ interface ExternalBankAccountService { fun unpause( params: ExternalBankAccountUnpauseParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see unpause */ @MustBeClosed fun unpause( params: ExternalBankAccountUnpauseParams - ): HttpResponseFor = - unpause(params, RequestOptions.none()) + ): HttpResponseFor = unpause(params, RequestOptions.none()) /** @see unpause */ @MustBeClosed fun unpause( externalBankAccountToken: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = unpause( externalBankAccountToken, ExternalBankAccountUnpauseParams.none(), diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceImpl.kt index 5309aba3d..7001796cd 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceImpl.kt @@ -16,6 +16,7 @@ import com.lithic.api.core.http.HttpResponseFor 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.ExternalBankAccount import com.lithic.api.models.ExternalBankAccountCreateParams import com.lithic.api.models.ExternalBankAccountCreateResponse import com.lithic.api.models.ExternalBankAccountListPage @@ -26,9 +27,7 @@ import com.lithic.api.models.ExternalBankAccountRetrieveResponse import com.lithic.api.models.ExternalBankAccountRetryMicroDepositsParams import com.lithic.api.models.ExternalBankAccountRetryMicroDepositsResponse import com.lithic.api.models.ExternalBankAccountRetryPrenoteParams -import com.lithic.api.models.ExternalBankAccountRetryPrenoteResponse import com.lithic.api.models.ExternalBankAccountUnpauseParams -import com.lithic.api.models.ExternalBankAccountUnpauseResponse import com.lithic.api.models.ExternalBankAccountUpdateParams import com.lithic.api.models.ExternalBankAccountUpdateResponse import com.lithic.api.services.blocking.externalBankAccounts.MicroDepositService @@ -94,14 +93,14 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc override fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, requestOptions: RequestOptions, - ): ExternalBankAccountRetryPrenoteResponse = + ): ExternalBankAccount = // post /v1/external_bank_accounts/{external_bank_account_token}/retry_prenote withRawResponse().retryPrenote(params, requestOptions).parse() override fun unpause( params: ExternalBankAccountUnpauseParams, requestOptions: RequestOptions, - ): ExternalBankAccountUnpauseResponse = + ): ExternalBankAccount = // post /v1/external_bank_accounts/{external_bank_account_token}/unpause withRawResponse().unpause(params, requestOptions).parse() @@ -284,13 +283,13 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc } } - private val retryPrenoteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retryPrenoteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retryPrenote( params: ExternalBankAccountRetryPrenoteParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("externalBankAccountToken", params.externalBankAccountToken().getOrNull()) @@ -320,13 +319,13 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalBankAcc } } - private val unpauseHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val unpauseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun unpause( params: ExternalBankAccountUnpauseParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("externalBankAccountToken", params.externalBankAccountToken().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventService.kt index c9f04dbe7..1aceb45bb 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventService.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventService.kt @@ -6,12 +6,12 @@ import com.google.errorprone.annotations.MustBeClosed import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponseFor +import com.lithic.api.models.FundingEvent import com.lithic.api.models.FundingEventListPage import com.lithic.api.models.FundingEventListParams import com.lithic.api.models.FundingEventRetrieveDetailsParams import com.lithic.api.models.FundingEventRetrieveDetailsResponse import com.lithic.api.models.FundingEventRetrieveParams -import com.lithic.api.models.FundingEventRetrieveResponse import java.util.function.Consumer interface FundingEventService { @@ -29,7 +29,7 @@ interface FundingEventService { fun withOptions(modifier: Consumer): FundingEventService /** Get funding event for program by id */ - fun retrieve(fundingEventToken: String): FundingEventRetrieveResponse = + fun retrieve(fundingEventToken: String): FundingEvent = retrieve(fundingEventToken, FundingEventRetrieveParams.none()) /** @see retrieve */ @@ -37,30 +37,27 @@ interface FundingEventService { fundingEventToken: String, params: FundingEventRetrieveParams = FundingEventRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): FundingEventRetrieveResponse = + ): FundingEvent = retrieve(params.toBuilder().fundingEventToken(fundingEventToken).build(), requestOptions) /** @see retrieve */ fun retrieve( fundingEventToken: String, params: FundingEventRetrieveParams = FundingEventRetrieveParams.none(), - ): FundingEventRetrieveResponse = retrieve(fundingEventToken, params, RequestOptions.none()) + ): FundingEvent = retrieve(fundingEventToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: FundingEventRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): FundingEventRetrieveResponse + ): FundingEvent /** @see retrieve */ - fun retrieve(params: FundingEventRetrieveParams): FundingEventRetrieveResponse = + fun retrieve(params: FundingEventRetrieveParams): FundingEvent = retrieve(params, RequestOptions.none()) /** @see retrieve */ - fun retrieve( - fundingEventToken: String, - requestOptions: RequestOptions, - ): FundingEventRetrieveResponse = + fun retrieve(fundingEventToken: String, requestOptions: RequestOptions): FundingEvent = retrieve(fundingEventToken, FundingEventRetrieveParams.none(), requestOptions) /** Get all funding events for program */ @@ -139,7 +136,7 @@ interface FundingEventService { * otherwise the same as [FundingEventService.retrieve]. */ @MustBeClosed - fun retrieve(fundingEventToken: String): HttpResponseFor = + fun retrieve(fundingEventToken: String): HttpResponseFor = retrieve(fundingEventToken, FundingEventRetrieveParams.none()) /** @see retrieve */ @@ -148,7 +145,7 @@ interface FundingEventService { fundingEventToken: String, params: FundingEventRetrieveParams = FundingEventRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = retrieve( params.toBuilder().fundingEventToken(fundingEventToken).build(), requestOptions, @@ -159,7 +156,7 @@ interface FundingEventService { fun retrieve( fundingEventToken: String, params: FundingEventRetrieveParams = FundingEventRetrieveParams.none(), - ): HttpResponseFor = + ): HttpResponseFor = retrieve(fundingEventToken, params, RequestOptions.none()) /** @see retrieve */ @@ -167,20 +164,19 @@ interface FundingEventService { fun retrieve( params: FundingEventRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see retrieve */ @MustBeClosed - fun retrieve( - params: FundingEventRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) + fun retrieve(params: FundingEventRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) /** @see retrieve */ @MustBeClosed fun retrieve( fundingEventToken: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = retrieve(fundingEventToken, FundingEventRetrieveParams.none(), requestOptions) /** diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventServiceImpl.kt index 559b83c0f..5009c51c0 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/FundingEventServiceImpl.kt @@ -15,13 +15,13 @@ import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable import com.lithic.api.core.prepare +import com.lithic.api.models.FundingEvent import com.lithic.api.models.FundingEventListPage import com.lithic.api.models.FundingEventListPageResponse import com.lithic.api.models.FundingEventListParams import com.lithic.api.models.FundingEventRetrieveDetailsParams import com.lithic.api.models.FundingEventRetrieveDetailsResponse import com.lithic.api.models.FundingEventRetrieveParams -import com.lithic.api.models.FundingEventRetrieveResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -40,7 +40,7 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl override fun retrieve( params: FundingEventRetrieveParams, requestOptions: RequestOptions, - ): FundingEventRetrieveResponse = + ): FundingEvent = // get /v1/funding_events/{funding_event_token} withRawResponse().retrieve(params, requestOptions).parse() @@ -71,13 +71,13 @@ class FundingEventServiceImpl internal constructor(private val clientOptions: Cl clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: FundingEventRetrieveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("fundingEventToken", params.fundingEventToken().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/InternalTransactionService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/InternalTransactionService.kt new file mode 100644 index 000000000..7a4de948c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/InternalTransactionService.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.core.ClientOptions +import java.util.function.Consumer + +interface InternalTransactionService { + + /** + * 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): InternalTransactionService + + /** + * A view of [InternalTransactionService] 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 + ): InternalTransactionService.WithRawResponse + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/InternalTransactionServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/InternalTransactionServiceImpl.kt new file mode 100644 index 000000000..04df64717 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/InternalTransactionServiceImpl.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking + +import com.lithic.api.core.ClientOptions +import java.util.function.Consumer + +class InternalTransactionServiceImpl +internal constructor(private val clientOptions: ClientOptions) : InternalTransactionService { + + private val withRawResponse: InternalTransactionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InternalTransactionService.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): InternalTransactionService = + InternalTransactionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InternalTransactionService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): InternalTransactionService.WithRawResponse = + InternalTransactionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalService.kt index edc41238c..2a278d427 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalService.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalService.kt @@ -6,7 +6,7 @@ import com.google.errorprone.annotations.MustBeClosed import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponseFor -import com.lithic.api.models.NetworkTotalRetrieveResponse +import com.lithic.api.models.NetworkTotal import com.lithic.api.models.ReportSettlementNetworkTotalListPage import com.lithic.api.models.ReportSettlementNetworkTotalListParams import com.lithic.api.models.ReportSettlementNetworkTotalRetrieveParams @@ -27,7 +27,7 @@ interface NetworkTotalService { fun withOptions(modifier: Consumer): NetworkTotalService /** Retrieve a specific network total record by token. Not available in sandbox. */ - fun retrieve(token: String): NetworkTotalRetrieveResponse = + fun retrieve(token: String): NetworkTotal = retrieve(token, ReportSettlementNetworkTotalRetrieveParams.none()) /** @see retrieve */ @@ -36,28 +36,27 @@ interface NetworkTotalService { params: ReportSettlementNetworkTotalRetrieveParams = ReportSettlementNetworkTotalRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): NetworkTotalRetrieveResponse = - retrieve(params.toBuilder().token(token).build(), requestOptions) + ): NetworkTotal = retrieve(params.toBuilder().token(token).build(), requestOptions) /** @see retrieve */ fun retrieve( token: String, params: ReportSettlementNetworkTotalRetrieveParams = ReportSettlementNetworkTotalRetrieveParams.none(), - ): NetworkTotalRetrieveResponse = retrieve(token, params, RequestOptions.none()) + ): NetworkTotal = retrieve(token, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): NetworkTotalRetrieveResponse + ): NetworkTotal /** @see retrieve */ - fun retrieve(params: ReportSettlementNetworkTotalRetrieveParams): NetworkTotalRetrieveResponse = + fun retrieve(params: ReportSettlementNetworkTotalRetrieveParams): NetworkTotal = retrieve(params, RequestOptions.none()) /** @see retrieve */ - fun retrieve(token: String, requestOptions: RequestOptions): NetworkTotalRetrieveResponse = + fun retrieve(token: String, requestOptions: RequestOptions): NetworkTotal = retrieve(token, ReportSettlementNetworkTotalRetrieveParams.none(), requestOptions) /** List network total records with optional filters. Not available in sandbox. */ @@ -100,7 +99,7 @@ interface NetworkTotalService { * is otherwise the same as [NetworkTotalService.retrieve]. */ @MustBeClosed - fun retrieve(token: String): HttpResponseFor = + fun retrieve(token: String): HttpResponseFor = retrieve(token, ReportSettlementNetworkTotalRetrieveParams.none()) /** @see retrieve */ @@ -110,7 +109,7 @@ interface NetworkTotalService { params: ReportSettlementNetworkTotalRetrieveParams = ReportSettlementNetworkTotalRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = retrieve(params.toBuilder().token(token).build(), requestOptions) /** @see retrieve */ @@ -119,28 +118,24 @@ interface NetworkTotalService { token: String, params: ReportSettlementNetworkTotalRetrieveParams = ReportSettlementNetworkTotalRetrieveParams.none(), - ): HttpResponseFor = - retrieve(token, params, RequestOptions.none()) + ): HttpResponseFor = retrieve(token, params, RequestOptions.none()) /** @see retrieve */ @MustBeClosed fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see retrieve */ @MustBeClosed fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) + ): HttpResponseFor = retrieve(params, RequestOptions.none()) /** @see retrieve */ @MustBeClosed - fun retrieve( - token: String, - requestOptions: RequestOptions, - ): HttpResponseFor = + fun retrieve(token: String, requestOptions: RequestOptions): HttpResponseFor = retrieve(token, ReportSettlementNetworkTotalRetrieveParams.none(), requestOptions) /** diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalServiceImpl.kt index 4fac7e5d9..fc75fb840 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/reports/settlement/NetworkTotalServiceImpl.kt @@ -15,7 +15,7 @@ import com.lithic.api.core.http.HttpResponse.Handler import com.lithic.api.core.http.HttpResponseFor import com.lithic.api.core.http.parseable import com.lithic.api.core.prepare -import com.lithic.api.models.NetworkTotalRetrieveResponse +import com.lithic.api.models.NetworkTotal import com.lithic.api.models.ReportSettlementNetworkTotalListPage import com.lithic.api.models.ReportSettlementNetworkTotalListPageResponse import com.lithic.api.models.ReportSettlementNetworkTotalListParams @@ -38,7 +38,7 @@ class NetworkTotalServiceImpl internal constructor(private val clientOptions: Cl override fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, requestOptions: RequestOptions, - ): NetworkTotalRetrieveResponse = + ): NetworkTotal = // get /v1/reports/settlement/network_totals/{token} withRawResponse().retrieve(params, requestOptions).parse() @@ -62,13 +62,13 @@ class NetworkTotalServiceImpl internal constructor(private val clientOptions: Cl clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: ReportSettlementNetworkTotalRetrieveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("token", params.token().getOrNull()) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationService.kt index 0c10dbe2a..b169e5f65 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationService.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationService.kt @@ -7,8 +7,8 @@ import com.lithic.api.core.ClientOptions import com.lithic.api.core.RequestOptions import com.lithic.api.core.http.HttpResponse import com.lithic.api.core.http.HttpResponseFor -import com.lithic.api.models.AuthenticationRetrieveResponse import com.lithic.api.models.AuthenticationSimulateResponse +import com.lithic.api.models.ThreeDSAuthentication import com.lithic.api.models.ThreeDSAuthenticationRetrieveParams import com.lithic.api.models.ThreeDSAuthenticationSimulateOtpEntryParams import com.lithic.api.models.ThreeDSAuthenticationSimulateParams @@ -29,7 +29,7 @@ interface AuthenticationService { fun withOptions(modifier: Consumer): AuthenticationService /** Get 3DS Authentication by token */ - fun retrieve(threeDSAuthenticationToken: String): AuthenticationRetrieveResponse = + fun retrieve(threeDSAuthenticationToken: String): ThreeDSAuthentication = retrieve(threeDSAuthenticationToken, ThreeDSAuthenticationRetrieveParams.none()) /** @see retrieve */ @@ -37,7 +37,7 @@ interface AuthenticationService { threeDSAuthenticationToken: String, params: ThreeDSAuthenticationRetrieveParams = ThreeDSAuthenticationRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): AuthenticationRetrieveResponse = + ): ThreeDSAuthentication = retrieve( params.toBuilder().threeDSAuthenticationToken(threeDSAuthenticationToken).build(), requestOptions, @@ -47,24 +47,23 @@ interface AuthenticationService { fun retrieve( threeDSAuthenticationToken: String, params: ThreeDSAuthenticationRetrieveParams = ThreeDSAuthenticationRetrieveParams.none(), - ): AuthenticationRetrieveResponse = - retrieve(threeDSAuthenticationToken, params, RequestOptions.none()) + ): ThreeDSAuthentication = retrieve(threeDSAuthenticationToken, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: ThreeDSAuthenticationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): AuthenticationRetrieveResponse + ): ThreeDSAuthentication /** @see retrieve */ - fun retrieve(params: ThreeDSAuthenticationRetrieveParams): AuthenticationRetrieveResponse = + fun retrieve(params: ThreeDSAuthenticationRetrieveParams): ThreeDSAuthentication = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( threeDSAuthenticationToken: String, requestOptions: RequestOptions, - ): AuthenticationRetrieveResponse = + ): ThreeDSAuthentication = retrieve( threeDSAuthenticationToken, ThreeDSAuthenticationRetrieveParams.none(), @@ -122,9 +121,7 @@ interface AuthenticationService { * as [AuthenticationService.retrieve]. */ @MustBeClosed - fun retrieve( - threeDSAuthenticationToken: String - ): HttpResponseFor = + fun retrieve(threeDSAuthenticationToken: String): HttpResponseFor = retrieve(threeDSAuthenticationToken, ThreeDSAuthenticationRetrieveParams.none()) /** @see retrieve */ @@ -134,7 +131,7 @@ interface AuthenticationService { params: ThreeDSAuthenticationRetrieveParams = ThreeDSAuthenticationRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = retrieve( params.toBuilder().threeDSAuthenticationToken(threeDSAuthenticationToken).build(), requestOptions, @@ -145,7 +142,7 @@ interface AuthenticationService { fun retrieve( threeDSAuthenticationToken: String, params: ThreeDSAuthenticationRetrieveParams = ThreeDSAuthenticationRetrieveParams.none(), - ): HttpResponseFor = + ): HttpResponseFor = retrieve(threeDSAuthenticationToken, params, RequestOptions.none()) /** @see retrieve */ @@ -153,20 +150,20 @@ interface AuthenticationService { fun retrieve( params: ThreeDSAuthenticationRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** @see retrieve */ @MustBeClosed fun retrieve( params: ThreeDSAuthenticationRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) + ): HttpResponseFor = retrieve(params, RequestOptions.none()) /** @see retrieve */ @MustBeClosed fun retrieve( threeDSAuthenticationToken: String, requestOptions: RequestOptions, - ): HttpResponseFor = + ): HttpResponseFor = retrieve( threeDSAuthenticationToken, ThreeDSAuthenticationRetrieveParams.none(), diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceImpl.kt index 7a166c579..ef6657e6d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceImpl.kt @@ -17,8 +17,8 @@ import com.lithic.api.core.http.HttpResponseFor 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.AuthenticationRetrieveResponse import com.lithic.api.models.AuthenticationSimulateResponse +import com.lithic.api.models.ThreeDSAuthentication import com.lithic.api.models.ThreeDSAuthenticationRetrieveParams import com.lithic.api.models.ThreeDSAuthenticationSimulateOtpEntryParams import com.lithic.api.models.ThreeDSAuthenticationSimulateParams @@ -40,7 +40,7 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: override fun retrieve( params: ThreeDSAuthenticationRetrieveParams, requestOptions: RequestOptions, - ): AuthenticationRetrieveResponse = + ): ThreeDSAuthentication = // get /v1/three_ds_authentication/{three_ds_authentication_token} withRawResponse().retrieve(params, requestOptions).parse() @@ -72,13 +72,13 @@ class AuthenticationServiceImpl internal constructor(private val clientOptions: clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: ThreeDSAuthenticationRetrieveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired( diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt index b70f59d9d..82191a81c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt @@ -270,17 +270,13 @@ internal class AccountActivityListResponseTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod.FRICTIONLESS - ) - .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS - ) - .decisionMadeBy(Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK) - .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() ) @@ -331,11 +327,7 @@ internal class AccountActivityListResponseTest { .result(Transaction.DeclineResult.APPROVED) .settledAmount(0L) .status(Transaction.Status.PENDING) - .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() - ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addEvent( Transaction.TransactionEvent.builder() @@ -508,20 +500,16 @@ internal class AccountActivityListResponseTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod - .FRICTIONLESS + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS - ) - .decisionMadeBy( - Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK + CardholderAuthentication.AuthenticationResult.SUCCESS ) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift - ._3DS_AUTHENTICATED + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED ) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() @@ -574,9 +562,7 @@ internal class AccountActivityListResponseTest { .settledAmount(0L) .status(Transaction.Status.PENDING) .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addEvent( diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt index 371813022..5f44839a7 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt @@ -297,17 +297,13 @@ internal class AccountActivityRetrieveTransactionResponseTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod.FRICTIONLESS - ) - .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS - ) - .decisionMadeBy(Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK) - .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() ) @@ -358,11 +354,7 @@ internal class AccountActivityRetrieveTransactionResponseTest { .result(Transaction.DeclineResult.APPROVED) .settledAmount(0L) .status(Transaction.Status.PENDING) - .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() - ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addEvent( Transaction.TransactionEvent.builder() @@ -536,20 +528,16 @@ internal class AccountActivityRetrieveTransactionResponseTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod - .FRICTIONLESS + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS - ) - .decisionMadeBy( - Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK + CardholderAuthentication.AuthenticationResult.SUCCESS ) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift - ._3DS_AUTHENTICATED + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED ) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() @@ -602,9 +590,7 @@ internal class AccountActivityRetrieveTransactionResponseTest { .settledAmount(0L) .status(Transaction.Status.PENDING) .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() ) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addEvent( diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBalanceListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBalanceListPageResponseTest.kt index d54a13a09..88c6c08d0 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBalanceListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBalanceListPageResponseTest.kt @@ -15,7 +15,7 @@ internal class CardBalanceListPageResponseTest { val cardBalanceListPageResponse = CardBalanceListPageResponse.builder() .addData( - BalanceListResponse.builder() + FinancialAccountBalance.builder() .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") .availableAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -24,7 +24,7 @@ internal class CardBalanceListPageResponseTest { .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .totalAmount(0L) - .type(BalanceListResponse.Type.ISSUING) + .type(FinancialAccountBalance.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -33,7 +33,7 @@ internal class CardBalanceListPageResponseTest { assertThat(cardBalanceListPageResponse.data()) .containsExactly( - BalanceListResponse.builder() + FinancialAccountBalance.builder() .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") .availableAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -42,7 +42,7 @@ internal class CardBalanceListPageResponseTest { .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .totalAmount(0L) - .type(BalanceListResponse.Type.ISSUING) + .type(FinancialAccountBalance.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -55,7 +55,7 @@ internal class CardBalanceListPageResponseTest { val cardBalanceListPageResponse = CardBalanceListPageResponse.builder() .addData( - BalanceListResponse.builder() + FinancialAccountBalance.builder() .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") .availableAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -64,7 +64,7 @@ internal class CardBalanceListPageResponseTest { .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .totalAmount(0L) - .type(BalanceListResponse.Type.ISSUING) + .type(FinancialAccountBalance.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderCreateParamsTest.kt new file mode 100644 index 000000000..95edeb7a9 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderCreateParamsTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardBulkOrderCreateParamsTest { + + @Test + fun create() { + CardBulkOrderCreateParams.builder() + .customerProductId("custom-card-design-123") + .shippingAddress( + JsonValue.from( + mapOf( + "address1" to "123 Main Street", + "city" to "NEW YORK", + "country" to "USA", + "first_name" to "Johnny", + "last_name" to "Appleseed", + "postal_code" to "10001", + "state" to "NY", + ) + ) + ) + .shippingMethod(CardBulkOrderCreateParams.ShippingMethod.BULK_EXPEDITED) + .build() + } + + @Test + fun body() { + val params = + CardBulkOrderCreateParams.builder() + .customerProductId("custom-card-design-123") + .shippingAddress( + JsonValue.from( + mapOf( + "address1" to "123 Main Street", + "city" to "NEW YORK", + "country" to "USA", + "first_name" to "Johnny", + "last_name" to "Appleseed", + "postal_code" to "10001", + "state" to "NY", + ) + ) + ) + .shippingMethod(CardBulkOrderCreateParams.ShippingMethod.BULK_EXPEDITED) + .build() + + val body = params._body() + + assertThat(body.customerProductId()).isEqualTo("custom-card-design-123") + assertThat(body._shippingAddress()) + .isEqualTo( + JsonValue.from( + mapOf( + "address1" to "123 Main Street", + "city" to "NEW YORK", + "country" to "USA", + "first_name" to "Johnny", + "last_name" to "Appleseed", + "postal_code" to "10001", + "state" to "NY", + ) + ) + ) + assertThat(body.shippingMethod()) + .isEqualTo(CardBulkOrderCreateParams.ShippingMethod.BULK_EXPEDITED) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderListPageResponseTest.kt new file mode 100644 index 000000000..e58a51e02 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderListPageResponseTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardBulkOrderListPageResponseTest { + + @Test + fun create() { + val cardBulkOrderListPageResponse = + CardBulkOrderListPageResponse.builder() + .addData( + CardBulkOrder.builder() + .token("7ef7d65c-9023-4da3-b113-3b8583fd7951") + .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .customerProductId("custom-card-design-123") + .shippingAddress(JsonValue.from(mapOf())) + .shippingMethod(CardBulkOrder.ShippingMethod.BULK_EXPEDITED) + .status(CardBulkOrder.Status.OPEN) + .updated(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .build() + ) + .hasMore(true) + .build() + + assertThat(cardBulkOrderListPageResponse.data()) + .containsExactly( + CardBulkOrder.builder() + .token("7ef7d65c-9023-4da3-b113-3b8583fd7951") + .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .customerProductId("custom-card-design-123") + .shippingAddress(JsonValue.from(mapOf())) + .shippingMethod(CardBulkOrder.ShippingMethod.BULK_EXPEDITED) + .status(CardBulkOrder.Status.OPEN) + .updated(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .build() + ) + assertThat(cardBulkOrderListPageResponse.hasMore()).isEqualTo(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardBulkOrderListPageResponse = + CardBulkOrderListPageResponse.builder() + .addData( + CardBulkOrder.builder() + .token("7ef7d65c-9023-4da3-b113-3b8583fd7951") + .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .customerProductId("custom-card-design-123") + .shippingAddress(JsonValue.from(mapOf())) + .shippingMethod(CardBulkOrder.ShippingMethod.BULK_EXPEDITED) + .status(CardBulkOrder.Status.OPEN) + .updated(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .build() + ) + .hasMore(true) + .build() + + val roundtrippedCardBulkOrderListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardBulkOrderListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardBulkOrderListPageResponse) + .isEqualTo(cardBulkOrderListPageResponse) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderListParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderListParamsTest.kt new file mode 100644 index 000000000..54ec6ecf1 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderListParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardBulkOrderListParamsTest { + + @Test + fun create() { + CardBulkOrderListParams.builder() + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endingBefore("ending_before") + .pageSize(1L) + .startingAfter("starting_after") + .build() + } + + @Test + fun queryParams() { + val params = + CardBulkOrderListParams.builder() + .begin(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .endingBefore("ending_before") + .pageSize(1L) + .startingAfter("starting_after") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("begin", "2019-12-27T18:11:19.117Z") + .put("end", "2019-12-27T18:11:19.117Z") + .put("ending_before", "ending_before") + .put("page_size", "1") + .put("starting_after", "starting_after") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = CardBulkOrderListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderRetrieveParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderRetrieveParamsTest.kt new file mode 100644 index 000000000..a24c4b0c9 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardBulkOrderRetrieveParamsTest { + + @Test + fun create() { + CardBulkOrderRetrieveParams.builder() + .bulkOrderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + CardBulkOrderRetrieveParams.builder() + .bulkOrderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderTest.kt new file mode 100644 index 000000000..9e8485583 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardBulkOrderTest { + + @Test + fun create() { + val cardBulkOrder = + CardBulkOrder.builder() + .token("7ef7d65c-9023-4da3-b113-3b8583fd7951") + .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .customerProductId("custom-card-design-123") + .shippingAddress(JsonValue.from(mapOf())) + .shippingMethod(CardBulkOrder.ShippingMethod.BULK_EXPEDITED) + .status(CardBulkOrder.Status.OPEN) + .updated(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .build() + + assertThat(cardBulkOrder.token()).isEqualTo("7ef7d65c-9023-4da3-b113-3b8583fd7951") + assertThat(cardBulkOrder.cardTokens()) + .containsExactly("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardBulkOrder.created()).isEqualTo(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + assertThat(cardBulkOrder.customerProductId()).contains("custom-card-design-123") + assertThat(cardBulkOrder._shippingAddress()).isEqualTo(JsonValue.from(mapOf())) + assertThat(cardBulkOrder.shippingMethod()) + .isEqualTo(CardBulkOrder.ShippingMethod.BULK_EXPEDITED) + assertThat(cardBulkOrder.status()).isEqualTo(CardBulkOrder.Status.OPEN) + assertThat(cardBulkOrder.updated()).isEqualTo(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardBulkOrder = + CardBulkOrder.builder() + .token("7ef7d65c-9023-4da3-b113-3b8583fd7951") + .addCardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .customerProductId("custom-card-design-123") + .shippingAddress(JsonValue.from(mapOf())) + .shippingMethod(CardBulkOrder.ShippingMethod.BULK_EXPEDITED) + .status(CardBulkOrder.Status.OPEN) + .updated(OffsetDateTime.parse("2021-06-28T22:53:15Z")) + .build() + + val roundtrippedCardBulkOrder = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardBulkOrder), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardBulkOrder).isEqualTo(cardBulkOrder) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderUpdateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderUpdateParamsTest.kt new file mode 100644 index 000000000..a60b74896 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardBulkOrderUpdateParamsTest.kt @@ -0,0 +1,43 @@ +// 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 CardBulkOrderUpdateParamsTest { + + @Test + fun create() { + CardBulkOrderUpdateParams.builder() + .bulkOrderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(CardBulkOrderUpdateParams.Status.LOCKED) + .build() + } + + @Test + fun pathParams() { + val params = + CardBulkOrderUpdateParams.builder() + .bulkOrderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(CardBulkOrderUpdateParams.Status.LOCKED) + .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 = + CardBulkOrderUpdateParams.builder() + .bulkOrderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(CardBulkOrderUpdateParams.Status.LOCKED) + .build() + + val body = params._body() + + assertThat(body.status()).isEqualTo(CardBulkOrderUpdateParams.Status.LOCKED) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt index 98587981a..d570ffb86 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreateParamsTest.kt @@ -12,6 +12,7 @@ internal class CardCreateParamsTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -52,6 +53,7 @@ internal class CardCreateParamsTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -89,6 +91,7 @@ internal class CardCreateParamsTest { assertThat(body.type()).isEqualTo(CardCreateParams.Type.VIRTUAL) assertThat(body.accountToken()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.bulkOrderToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(body.cardProgramToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(body.carrier()).contains(Carrier.builder().qrCodeUrl("qr_code_url").build()) assertThat(body.digitalCardArtToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt index fe85b513f..09497e5b6 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardListPageResponseTest.kt @@ -38,6 +38,7 @@ internal class CardListPageResponseTest { .state(NonPciCard.State.CLOSED) .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardholderCurrency("USD") .comment("comment") .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -80,6 +81,7 @@ internal class CardListPageResponseTest { .state(NonPciCard.State.CLOSED) .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardholderCurrency("USD") .comment("comment") .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -126,6 +128,7 @@ internal class CardListPageResponseTest { .state(NonPciCard.State.CLOSED) .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardholderCurrency("USD") .comment("comment") .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt index c31c63ad8..e257cbab9 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTest.kt @@ -37,6 +37,7 @@ internal class CardTest { .state(NonPciCard.State.CLOSED) .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardholderCurrency("USD") .comment("comment") .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -76,6 +77,7 @@ internal class CardTest { assertThat(card.state()).isEqualTo(NonPciCard.State.CLOSED) assertThat(card.type()).isEqualTo(NonPciCard.Type.MERCHANT_LOCKED) assertThat(card.authRuleTokens().getOrNull()).containsExactly("string") + assertThat(card.bulkOrderToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(card.cardholderCurrency()).contains("USD") assertThat(card.comment()).contains("comment") assertThat(card.digitalCardArtToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -119,6 +121,7 @@ internal class CardTest { .state(NonPciCard.State.CLOSED) .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardholderCurrency("USD") .comment("comment") .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardholderAuthenticationTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardholderAuthenticationTest.kt new file mode 100644 index 000000000..2f0d06c56 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardholderAuthenticationTest.kt @@ -0,0 +1,55 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardholderAuthenticationTest { + + @Test + fun create() { + val 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() + + assertThat(cardholderAuthentication.authenticationMethod()) + .isEqualTo(CardholderAuthentication.AuthenticationMethod.FRICTIONLESS) + assertThat(cardholderAuthentication.authenticationResult()) + .isEqualTo(CardholderAuthentication.AuthenticationResult.SUCCESS) + assertThat(cardholderAuthentication.decisionMadeBy()) + .isEqualTo(CardholderAuthentication.DecisionMadeBy.LITHIC_RULES) + assertThat(cardholderAuthentication.liabilityShift()) + .isEqualTo(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) + assertThat(cardholderAuthentication.threeDSAuthenticationToken()) + .contains("a6e372d0-b40a-43eb-b0d1-4e1aebef5875") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val 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() + + val roundtrippedCardholderAuthentication = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardholderAuthentication), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardholderAuthentication).isEqualTo(cardholderAuthentication) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DeviceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DeviceTest.kt new file mode 100644 index 000000000..9f94181ef --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DeviceTest.kt @@ -0,0 +1,41 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DeviceTest { + + @Test + fun create() { + val device = + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + + assertThat(device.imei()).contains("123456789012345") + assertThat(device.ipAddress()).contains("1.1.1.1") + assertThat(device.location()).contains("37.3860517/-122.0838511") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val device = + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + + val roundtrippedDevice = + jsonMapper.readValue(jsonMapper.writeValueAsString(device), jacksonTypeRef()) + + assertThat(roundtrippedDevice).isEqualTo(device) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenMetadataTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenMetadataTest.kt new file mode 100644 index 000000000..3d225c577 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenMetadataTest.kt @@ -0,0 +1,88 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DigitalWalletTokenMetadataTest { + + @Test + fun create() { + val digitalWalletTokenMetadata = + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + + assertThat(digitalWalletTokenMetadata.paymentAccountInfo()) + .isEqualTo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData.builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + assertThat(digitalWalletTokenMetadata.status()).isEqualTo("status") + assertThat(digitalWalletTokenMetadata.paymentAppInstanceId()) + .contains("payment_app_instance_id") + assertThat(digitalWalletTokenMetadata.tokenRequestorId()).contains("xxxxxxxxxxx") + assertThat(digitalWalletTokenMetadata.tokenRequestorName()) + .contains(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val digitalWalletTokenMetadata = + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + + val roundtrippedDigitalWalletTokenMetadata = + jsonMapper.readValue( + jsonMapper.writeValueAsString(digitalWalletTokenMetadata), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDigitalWalletTokenMetadata).isEqualTo(digitalWalletTokenMetadata) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponseTest.kt deleted file mode 100644 index 25e22c403..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountRetryPrenoteResponseTest.kt +++ /dev/null @@ -1,150 +0,0 @@ -// 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.LocalDate -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ExternalBankAccountRetryPrenoteResponseTest { - - @Test - fun create() { - val externalBankAccountRetryPrenoteResponse = - ExternalBankAccountRetryPrenoteResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .country("country") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .lastFour("last_four") - .owner("owner") - .ownerType(OwnerType.INDIVIDUAL) - .routingNumber("routing_number") - .state(ExternalBankAccountRetryPrenoteResponse.State.ENABLED) - .type(ExternalBankAccountRetryPrenoteResponse.AccountType.CHECKING) - .verificationAttempts(0L) - .verificationMethod(VerificationMethod.MANUAL) - .verificationState( - ExternalBankAccountRetryPrenoteResponse.VerificationState.PENDING - ) - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .address( - ExternalBankAccountAddress.builder() - .address1("x") - .city("x") - .country("USD") - .postalCode("11201") - .state("xx") - .address2("x") - .build() - ) - .companyId("company_id") - .dob(LocalDate.parse("2019-12-27")) - .doingBusinessAs("doing_business_as") - .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .userDefinedId("user_defined_id") - .verificationFailedReason("verification_failed_reason") - .build() - - assertThat(externalBankAccountRetryPrenoteResponse.token()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(externalBankAccountRetryPrenoteResponse.country()).isEqualTo("country") - assertThat(externalBankAccountRetryPrenoteResponse.created()) - .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(externalBankAccountRetryPrenoteResponse.currency()).isEqualTo("currency") - assertThat(externalBankAccountRetryPrenoteResponse.lastFour()).isEqualTo("last_four") - assertThat(externalBankAccountRetryPrenoteResponse.owner()).isEqualTo("owner") - assertThat(externalBankAccountRetryPrenoteResponse.ownerType()) - .isEqualTo(OwnerType.INDIVIDUAL) - assertThat(externalBankAccountRetryPrenoteResponse.routingNumber()) - .isEqualTo("routing_number") - assertThat(externalBankAccountRetryPrenoteResponse.state()) - .isEqualTo(ExternalBankAccountRetryPrenoteResponse.State.ENABLED) - assertThat(externalBankAccountRetryPrenoteResponse.type()) - .isEqualTo(ExternalBankAccountRetryPrenoteResponse.AccountType.CHECKING) - assertThat(externalBankAccountRetryPrenoteResponse.verificationAttempts()).isEqualTo(0L) - assertThat(externalBankAccountRetryPrenoteResponse.verificationMethod()) - .isEqualTo(VerificationMethod.MANUAL) - assertThat(externalBankAccountRetryPrenoteResponse.verificationState()) - .isEqualTo(ExternalBankAccountRetryPrenoteResponse.VerificationState.PENDING) - assertThat(externalBankAccountRetryPrenoteResponse.accountToken()) - .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(externalBankAccountRetryPrenoteResponse.address()) - .contains( - ExternalBankAccountAddress.builder() - .address1("x") - .city("x") - .country("USD") - .postalCode("11201") - .state("xx") - .address2("x") - .build() - ) - assertThat(externalBankAccountRetryPrenoteResponse.companyId()).contains("company_id") - assertThat(externalBankAccountRetryPrenoteResponse.dob()) - .contains(LocalDate.parse("2019-12-27")) - assertThat(externalBankAccountRetryPrenoteResponse.doingBusinessAs()) - .contains("doing_business_as") - assertThat(externalBankAccountRetryPrenoteResponse.financialAccountToken()) - .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(externalBankAccountRetryPrenoteResponse.name()).contains("name") - assertThat(externalBankAccountRetryPrenoteResponse.userDefinedId()) - .contains("user_defined_id") - assertThat(externalBankAccountRetryPrenoteResponse.verificationFailedReason()) - .contains("verification_failed_reason") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val externalBankAccountRetryPrenoteResponse = - ExternalBankAccountRetryPrenoteResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .country("country") - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .currency("currency") - .lastFour("last_four") - .owner("owner") - .ownerType(OwnerType.INDIVIDUAL) - .routingNumber("routing_number") - .state(ExternalBankAccountRetryPrenoteResponse.State.ENABLED) - .type(ExternalBankAccountRetryPrenoteResponse.AccountType.CHECKING) - .verificationAttempts(0L) - .verificationMethod(VerificationMethod.MANUAL) - .verificationState( - ExternalBankAccountRetryPrenoteResponse.VerificationState.PENDING - ) - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .address( - ExternalBankAccountAddress.builder() - .address1("x") - .city("x") - .country("USD") - .postalCode("11201") - .state("xx") - .address2("x") - .build() - ) - .companyId("company_id") - .dob(LocalDate.parse("2019-12-27")) - .doingBusinessAs("doing_business_as") - .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .name("name") - .userDefinedId("user_defined_id") - .verificationFailedReason("verification_failed_reason") - .build() - - val roundtrippedExternalBankAccountRetryPrenoteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(externalBankAccountRetryPrenoteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedExternalBankAccountRetryPrenoteResponse) - .isEqualTo(externalBankAccountRetryPrenoteResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountUnpauseResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountTest.kt similarity index 54% rename from lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountUnpauseResponseTest.kt rename to lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountTest.kt index 1bf900680..75c202ff9 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountUnpauseResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountTest.kt @@ -9,12 +9,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class ExternalBankAccountUnpauseResponseTest { +internal class ExternalBankAccountTest { @Test fun create() { - val externalBankAccountUnpauseResponse = - ExternalBankAccountUnpauseResponse.builder() + val externalBankAccount = + ExternalBankAccount.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .country("country") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -23,11 +23,11 @@ internal class ExternalBankAccountUnpauseResponseTest { .owner("owner") .ownerType(OwnerType.INDIVIDUAL) .routingNumber("routing_number") - .state(ExternalBankAccountUnpauseResponse.State.ENABLED) - .type(ExternalBankAccountUnpauseResponse.AccountType.CHECKING) + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) .verificationAttempts(0L) .verificationMethod(VerificationMethod.MANUAL) - .verificationState(ExternalBankAccountUnpauseResponse.VerificationState.PENDING) + .verificationState(ExternalBankAccount.VerificationState.PENDING) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .address( ExternalBankAccountAddress.builder() @@ -48,28 +48,24 @@ internal class ExternalBankAccountUnpauseResponseTest { .verificationFailedReason("verification_failed_reason") .build() - assertThat(externalBankAccountUnpauseResponse.token()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(externalBankAccountUnpauseResponse.country()).isEqualTo("country") - assertThat(externalBankAccountUnpauseResponse.created()) + assertThat(externalBankAccount.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalBankAccount.country()).isEqualTo("country") + assertThat(externalBankAccount.created()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(externalBankAccountUnpauseResponse.currency()).isEqualTo("currency") - assertThat(externalBankAccountUnpauseResponse.lastFour()).isEqualTo("last_four") - assertThat(externalBankAccountUnpauseResponse.owner()).isEqualTo("owner") - assertThat(externalBankAccountUnpauseResponse.ownerType()).isEqualTo(OwnerType.INDIVIDUAL) - assertThat(externalBankAccountUnpauseResponse.routingNumber()).isEqualTo("routing_number") - assertThat(externalBankAccountUnpauseResponse.state()) - .isEqualTo(ExternalBankAccountUnpauseResponse.State.ENABLED) - assertThat(externalBankAccountUnpauseResponse.type()) - .isEqualTo(ExternalBankAccountUnpauseResponse.AccountType.CHECKING) - assertThat(externalBankAccountUnpauseResponse.verificationAttempts()).isEqualTo(0L) - assertThat(externalBankAccountUnpauseResponse.verificationMethod()) - .isEqualTo(VerificationMethod.MANUAL) - assertThat(externalBankAccountUnpauseResponse.verificationState()) - .isEqualTo(ExternalBankAccountUnpauseResponse.VerificationState.PENDING) - assertThat(externalBankAccountUnpauseResponse.accountToken()) + assertThat(externalBankAccount.currency()).isEqualTo("currency") + assertThat(externalBankAccount.lastFour()).isEqualTo("last_four") + assertThat(externalBankAccount.owner()).isEqualTo("owner") + assertThat(externalBankAccount.ownerType()).isEqualTo(OwnerType.INDIVIDUAL) + assertThat(externalBankAccount.routingNumber()).isEqualTo("routing_number") + assertThat(externalBankAccount.state()).isEqualTo(ExternalBankAccount.State.ENABLED) + assertThat(externalBankAccount.type()).isEqualTo(ExternalBankAccount.AccountType.CHECKING) + assertThat(externalBankAccount.verificationAttempts()).isEqualTo(0L) + assertThat(externalBankAccount.verificationMethod()).isEqualTo(VerificationMethod.MANUAL) + assertThat(externalBankAccount.verificationState()) + .isEqualTo(ExternalBankAccount.VerificationState.PENDING) + assertThat(externalBankAccount.accountToken()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(externalBankAccountUnpauseResponse.address()) + assertThat(externalBankAccount.address()) .contains( ExternalBankAccountAddress.builder() .address1("x") @@ -80,23 +76,22 @@ internal class ExternalBankAccountUnpauseResponseTest { .address2("x") .build() ) - assertThat(externalBankAccountUnpauseResponse.companyId()).contains("company_id") - assertThat(externalBankAccountUnpauseResponse.dob()).contains(LocalDate.parse("2019-12-27")) - assertThat(externalBankAccountUnpauseResponse.doingBusinessAs()) - .contains("doing_business_as") - assertThat(externalBankAccountUnpauseResponse.financialAccountToken()) + assertThat(externalBankAccount.companyId()).contains("company_id") + assertThat(externalBankAccount.dob()).contains(LocalDate.parse("2019-12-27")) + assertThat(externalBankAccount.doingBusinessAs()).contains("doing_business_as") + assertThat(externalBankAccount.financialAccountToken()) .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(externalBankAccountUnpauseResponse.name()).contains("name") - assertThat(externalBankAccountUnpauseResponse.userDefinedId()).contains("user_defined_id") - assertThat(externalBankAccountUnpauseResponse.verificationFailedReason()) + assertThat(externalBankAccount.name()).contains("name") + assertThat(externalBankAccount.userDefinedId()).contains("user_defined_id") + assertThat(externalBankAccount.verificationFailedReason()) .contains("verification_failed_reason") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val externalBankAccountUnpauseResponse = - ExternalBankAccountUnpauseResponse.builder() + val externalBankAccount = + ExternalBankAccount.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .country("country") .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -105,11 +100,11 @@ internal class ExternalBankAccountUnpauseResponseTest { .owner("owner") .ownerType(OwnerType.INDIVIDUAL) .routingNumber("routing_number") - .state(ExternalBankAccountUnpauseResponse.State.ENABLED) - .type(ExternalBankAccountUnpauseResponse.AccountType.CHECKING) + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) .verificationAttempts(0L) .verificationMethod(VerificationMethod.MANUAL) - .verificationState(ExternalBankAccountUnpauseResponse.VerificationState.PENDING) + .verificationState(ExternalBankAccount.VerificationState.PENDING) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .address( ExternalBankAccountAddress.builder() @@ -130,13 +125,12 @@ internal class ExternalBankAccountUnpauseResponseTest { .verificationFailedReason("verification_failed_reason") .build() - val roundtrippedExternalBankAccountUnpauseResponse = + val roundtrippedExternalBankAccount = jsonMapper.readValue( - jsonMapper.writeValueAsString(externalBankAccountUnpauseResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(externalBankAccount), + jacksonTypeRef(), ) - assertThat(roundtrippedExternalBankAccountUnpauseResponse) - .isEqualTo(externalBankAccountUnpauseResponse) + assertThat(roundtrippedExternalBankAccount).isEqualTo(externalBankAccount) } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageResponseTest.kt index bdaec260a..fb98383ad 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountBalanceListPageResponseTest.kt @@ -15,7 +15,7 @@ internal class FinancialAccountBalanceListPageResponseTest { val financialAccountBalanceListPageResponse = FinancialAccountBalanceListPageResponse.builder() .addData( - BalanceListResponse.builder() + FinancialAccountBalance.builder() .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") .availableAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -24,7 +24,7 @@ internal class FinancialAccountBalanceListPageResponseTest { .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .totalAmount(0L) - .type(BalanceListResponse.Type.ISSUING) + .type(FinancialAccountBalance.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -33,7 +33,7 @@ internal class FinancialAccountBalanceListPageResponseTest { assertThat(financialAccountBalanceListPageResponse.data()) .containsExactly( - BalanceListResponse.builder() + FinancialAccountBalance.builder() .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") .availableAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -42,7 +42,7 @@ internal class FinancialAccountBalanceListPageResponseTest { .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .totalAmount(0L) - .type(BalanceListResponse.Type.ISSUING) + .type(FinancialAccountBalance.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) @@ -55,7 +55,7 @@ internal class FinancialAccountBalanceListPageResponseTest { val financialAccountBalanceListPageResponse = FinancialAccountBalanceListPageResponse.builder() .addData( - BalanceListResponse.builder() + FinancialAccountBalance.builder() .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") .availableAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -64,7 +64,7 @@ internal class FinancialAccountBalanceListPageResponseTest { .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .totalAmount(0L) - .type(BalanceListResponse.Type.ISSUING) + .type(FinancialAccountBalance.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BalanceListResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountBalanceTest.kt similarity index 57% rename from lithic-java-core/src/test/kotlin/com/lithic/api/models/BalanceListResponseTest.kt rename to lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountBalanceTest.kt index e5705a828..08108f569 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BalanceListResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountBalanceTest.kt @@ -8,12 +8,12 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class BalanceListResponseTest { +internal class FinancialAccountBalanceTest { @Test fun create() { - val balanceListResponse = - BalanceListResponse.builder() + val financialAccountBalance = + FinancialAccountBalance.builder() .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") .availableAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -22,31 +22,32 @@ internal class BalanceListResponseTest { .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .totalAmount(0L) - .type(BalanceListResponse.Type.ISSUING) + .type(FinancialAccountBalance.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() - assertThat(balanceListResponse.token()).isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") - assertThat(balanceListResponse.availableAmount()).isEqualTo(0L) - assertThat(balanceListResponse.created()) + assertThat(financialAccountBalance.token()) + .isEqualTo("3fa85f64-5717-4562-b3fc-2c963f66afa6") + assertThat(financialAccountBalance.availableAmount()).isEqualTo(0L) + assertThat(financialAccountBalance.created()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(balanceListResponse.currency()).isEqualTo("currency") - assertThat(balanceListResponse.lastTransactionEventToken()) + assertThat(financialAccountBalance.currency()).isEqualTo("currency") + assertThat(financialAccountBalance.lastTransactionEventToken()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(balanceListResponse.lastTransactionToken()) + assertThat(financialAccountBalance.lastTransactionToken()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(balanceListResponse.pendingAmount()).isEqualTo(0L) - assertThat(balanceListResponse.totalAmount()).isEqualTo(0L) - assertThat(balanceListResponse.type()).isEqualTo(BalanceListResponse.Type.ISSUING) - assertThat(balanceListResponse.updated()) + assertThat(financialAccountBalance.pendingAmount()).isEqualTo(0L) + assertThat(financialAccountBalance.totalAmount()).isEqualTo(0L) + assertThat(financialAccountBalance.type()).isEqualTo(FinancialAccountBalance.Type.ISSUING) + assertThat(financialAccountBalance.updated()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val balanceListResponse = - BalanceListResponse.builder() + val financialAccountBalance = + FinancialAccountBalance.builder() .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") .availableAmount(0L) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -55,16 +56,16 @@ internal class BalanceListResponseTest { .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .pendingAmount(0L) .totalAmount(0L) - .type(BalanceListResponse.Type.ISSUING) + .type(FinancialAccountBalance.Type.ISSUING) .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() - val roundtrippedBalanceListResponse = + val roundtrippedFinancialAccountBalance = jsonMapper.readValue( - jsonMapper.writeValueAsString(balanceListResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(financialAccountBalance), + jacksonTypeRef(), ) - assertThat(roundtrippedBalanceListResponse).isEqualTo(balanceListResponse) + assertThat(roundtrippedFinancialAccountBalance).isEqualTo(financialAccountBalance) } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventListPageResponseTest.kt index 857f0f7dc..0e87acf7c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventListPageResponseTest.kt @@ -16,16 +16,14 @@ internal class FundingEventListPageResponseTest { val fundingEventListPageResponse = FundingEventListPageResponse.builder() .addData( - FundingEventListResponse.builder() + FundingEvent.builder() .token("b68b7424-aa69-4cbc-a946-30d90181b621") - .collectionResourceType( - FundingEventListResponse.CollectionResourceType.PAYMENT - ) + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .addNetworkSettlementSummary( - FundingEventListResponse.FundingEventSettlement.builder() + FundingEvent.FundingEventSettlement.builder() .networkSettlementDate(LocalDate.parse("2024-01-01")) .settledGrossAmount(0L) .build() @@ -39,14 +37,14 @@ internal class FundingEventListPageResponseTest { assertThat(fundingEventListPageResponse.data()) .containsExactly( - FundingEventListResponse.builder() + FundingEvent.builder() .token("b68b7424-aa69-4cbc-a946-30d90181b621") - .collectionResourceType(FundingEventListResponse.CollectionResourceType.PAYMENT) + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .addNetworkSettlementSummary( - FundingEventListResponse.FundingEventSettlement.builder() + FundingEvent.FundingEventSettlement.builder() .networkSettlementDate(LocalDate.parse("2024-01-01")) .settledGrossAmount(0L) .build() @@ -64,16 +62,14 @@ internal class FundingEventListPageResponseTest { val fundingEventListPageResponse = FundingEventListPageResponse.builder() .addData( - FundingEventListResponse.builder() + FundingEvent.builder() .token("b68b7424-aa69-4cbc-a946-30d90181b621") - .collectionResourceType( - FundingEventListResponse.CollectionResourceType.PAYMENT - ) + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .addNetworkSettlementSummary( - FundingEventListResponse.FundingEventSettlement.builder() + FundingEvent.FundingEventSettlement.builder() .networkSettlementDate(LocalDate.parse("2024-01-01")) .settledGrossAmount(0L) .build() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventRetrieveResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventRetrieveResponseTest.kt deleted file mode 100644 index e78d5e146..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventRetrieveResponseTest.kt +++ /dev/null @@ -1,84 +0,0 @@ -// 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.LocalDate -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class FundingEventRetrieveResponseTest { - - @Test - fun create() { - val fundingEventRetrieveResponse = - FundingEventRetrieveResponse.builder() - .token("b68b7424-aa69-4cbc-a946-30d90181b621") - .collectionResourceType(FundingEventRetrieveResponse.CollectionResourceType.PAYMENT) - .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") - .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - .addNetworkSettlementSummary( - FundingEventRetrieveResponse.FundingEventSettlement.builder() - .networkSettlementDate(LocalDate.parse("2024-01-01")) - .settledGrossAmount(0L) - .build() - ) - .previousHighWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - .updated(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - .build() - - assertThat(fundingEventRetrieveResponse.token()) - .isEqualTo("b68b7424-aa69-4cbc-a946-30d90181b621") - assertThat(fundingEventRetrieveResponse.collectionResourceType()) - .isEqualTo(FundingEventRetrieveResponse.CollectionResourceType.PAYMENT) - assertThat(fundingEventRetrieveResponse.collectionTokens()) - .containsExactly("b68b7424-aa69-4cbc-a946-30d90181b621") - assertThat(fundingEventRetrieveResponse.created()) - .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - assertThat(fundingEventRetrieveResponse.highWatermark()) - .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - assertThat(fundingEventRetrieveResponse.networkSettlementSummary()) - .containsExactly( - FundingEventRetrieveResponse.FundingEventSettlement.builder() - .networkSettlementDate(LocalDate.parse("2024-01-01")) - .settledGrossAmount(0L) - .build() - ) - assertThat(fundingEventRetrieveResponse.previousHighWatermark()) - .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - assertThat(fundingEventRetrieveResponse.updated()) - .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val fundingEventRetrieveResponse = - FundingEventRetrieveResponse.builder() - .token("b68b7424-aa69-4cbc-a946-30d90181b621") - .collectionResourceType(FundingEventRetrieveResponse.CollectionResourceType.PAYMENT) - .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") - .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - .addNetworkSettlementSummary( - FundingEventRetrieveResponse.FundingEventSettlement.builder() - .networkSettlementDate(LocalDate.parse("2024-01-01")) - .settledGrossAmount(0L) - .build() - ) - .previousHighWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - .updated(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - .build() - - val roundtrippedFundingEventRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(fundingEventRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFundingEventRetrieveResponse).isEqualTo(fundingEventRetrieveResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventListResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventTest.kt similarity index 57% rename from lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventListResponseTest.kt rename to lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventTest.kt index 6df41f1a0..7d4825c31 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventListResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventTest.kt @@ -9,19 +9,19 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FundingEventListResponseTest { +internal class FundingEventTest { @Test fun create() { - val fundingEventListResponse = - FundingEventListResponse.builder() + val fundingEvent = + FundingEvent.builder() .token("b68b7424-aa69-4cbc-a946-30d90181b621") - .collectionResourceType(FundingEventListResponse.CollectionResourceType.PAYMENT) + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .addNetworkSettlementSummary( - FundingEventListResponse.FundingEventSettlement.builder() + FundingEvent.FundingEventSettlement.builder() .networkSettlementDate(LocalDate.parse("2024-01-01")) .settledGrossAmount(0L) .build() @@ -30,41 +30,38 @@ internal class FundingEventListResponseTest { .updated(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .build() - assertThat(fundingEventListResponse.token()) - .isEqualTo("b68b7424-aa69-4cbc-a946-30d90181b621") - assertThat(fundingEventListResponse.collectionResourceType()) - .isEqualTo(FundingEventListResponse.CollectionResourceType.PAYMENT) - assertThat(fundingEventListResponse.collectionTokens()) + assertThat(fundingEvent.token()).isEqualTo("b68b7424-aa69-4cbc-a946-30d90181b621") + assertThat(fundingEvent.collectionResourceType()) + .isEqualTo(FundingEvent.CollectionResourceType.PAYMENT) + assertThat(fundingEvent.collectionTokens()) .containsExactly("b68b7424-aa69-4cbc-a946-30d90181b621") - assertThat(fundingEventListResponse.created()) + assertThat(fundingEvent.created()).isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + assertThat(fundingEvent.highWatermark()) .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - assertThat(fundingEventListResponse.highWatermark()) - .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - assertThat(fundingEventListResponse.networkSettlementSummary()) + assertThat(fundingEvent.networkSettlementSummary()) .containsExactly( - FundingEventListResponse.FundingEventSettlement.builder() + FundingEvent.FundingEventSettlement.builder() .networkSettlementDate(LocalDate.parse("2024-01-01")) .settledGrossAmount(0L) .build() ) - assertThat(fundingEventListResponse.previousHighWatermark()) - .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) - assertThat(fundingEventListResponse.updated()) + assertThat(fundingEvent.previousHighWatermark()) .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + assertThat(fundingEvent.updated()).isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val fundingEventListResponse = - FundingEventListResponse.builder() + val fundingEvent = + FundingEvent.builder() .token("b68b7424-aa69-4cbc-a946-30d90181b621") - .collectionResourceType(FundingEventListResponse.CollectionResourceType.PAYMENT) + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .addNetworkSettlementSummary( - FundingEventListResponse.FundingEventSettlement.builder() + FundingEvent.FundingEventSettlement.builder() .networkSettlementDate(LocalDate.parse("2024-01-01")) .settledGrossAmount(0L) .build() @@ -73,12 +70,12 @@ internal class FundingEventListResponseTest { .updated(OffsetDateTime.parse("2024-01-01T00:00:00Z")) .build() - val roundtrippedFundingEventListResponse = + val roundtrippedFundingEvent = jsonMapper.readValue( - jsonMapper.writeValueAsString(fundingEventListResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(fundingEvent), + jacksonTypeRef(), ) - assertThat(roundtrippedFundingEventListResponse).isEqualTo(fundingEventListResponse) + assertThat(roundtrippedFundingEvent).isEqualTo(fundingEvent) } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionTest.kt new file mode 100644 index 000000000..572c68f47 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionTest.kt @@ -0,0 +1,102 @@ +// 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 InternalTransactionTest { + + @Test + fun create() { + val internalTransaction = + InternalTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED + ) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(internalTransaction.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(internalTransaction.category()).isEqualTo(InternalTransaction.Category.INTERNAL) + assertThat(internalTransaction.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(internalTransaction.currency()).isEqualTo("currency") + assertThat(internalTransaction.descriptor()).isEqualTo("descriptor") + assertThat(internalTransaction.events()) + .containsExactly( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result(InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + assertThat(internalTransaction.pendingAmount()).isEqualTo(0L) + assertThat(internalTransaction.result()) + .isEqualTo(InternalTransaction.TransactionResult.APPROVED) + assertThat(internalTransaction.settledAmount()).isEqualTo(0L) + assertThat(internalTransaction.status()) + .isEqualTo(InternalTransaction.TransactionStatus.PENDING) + assertThat(internalTransaction.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val internalTransaction = + InternalTransaction.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED + ) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedInternalTransaction = + jsonMapper.readValue( + jsonMapper.writeValueAsString(internalTransaction), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInternalTransaction).isEqualTo(internalTransaction) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalRetrieveResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalRetrieveResponseTest.kt deleted file mode 100644 index 256d8da4f..000000000 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalRetrieveResponseTest.kt +++ /dev/null @@ -1,100 +0,0 @@ -// 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.LocalDate -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NetworkTotalRetrieveResponseTest { - - @Test - fun create() { - val networkTotalRetrieveResponse = - NetworkTotalRetrieveResponse.builder() - .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") - .amounts( - NetworkTotalRetrieveResponse.Amounts.builder() - .grossSettlement(100L) - .interchangeFees(-25L) - .netSettlement(85L) - .visaCharges(10L) - .build() - ) - .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) - .currency("CAD") - .institutionId("1000000000") - .isComplete(true) - .network(NetworkTotalRetrieveResponse.Network.VISA) - .reportDate(LocalDate.parse("2025-02-25")) - .settlementInstitutionId("1000000001") - .settlementService("015") - .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) - .cycle(0L) - .build() - - assertThat(networkTotalRetrieveResponse.token()) - .isEqualTo("12cf7505-06a8-435e-b1c7-4c430d02f6c3") - assertThat(networkTotalRetrieveResponse.amounts()) - .isEqualTo( - NetworkTotalRetrieveResponse.Amounts.builder() - .grossSettlement(100L) - .interchangeFees(-25L) - .netSettlement(85L) - .visaCharges(10L) - .build() - ) - assertThat(networkTotalRetrieveResponse.created()) - .isEqualTo(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) - assertThat(networkTotalRetrieveResponse.currency()).isEqualTo("CAD") - assertThat(networkTotalRetrieveResponse.institutionId()).isEqualTo("1000000000") - assertThat(networkTotalRetrieveResponse.isComplete()).isEqualTo(true) - assertThat(networkTotalRetrieveResponse.network()) - .isEqualTo(NetworkTotalRetrieveResponse.Network.VISA) - assertThat(networkTotalRetrieveResponse.reportDate()) - .isEqualTo(LocalDate.parse("2025-02-25")) - assertThat(networkTotalRetrieveResponse.settlementInstitutionId()).isEqualTo("1000000001") - assertThat(networkTotalRetrieveResponse.settlementService()).isEqualTo("015") - assertThat(networkTotalRetrieveResponse.updated()) - .isEqualTo(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) - assertThat(networkTotalRetrieveResponse.cycle()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val networkTotalRetrieveResponse = - NetworkTotalRetrieveResponse.builder() - .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") - .amounts( - NetworkTotalRetrieveResponse.Amounts.builder() - .grossSettlement(100L) - .interchangeFees(-25L) - .netSettlement(85L) - .visaCharges(10L) - .build() - ) - .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) - .currency("CAD") - .institutionId("1000000000") - .isComplete(true) - .network(NetworkTotalRetrieveResponse.Network.VISA) - .reportDate(LocalDate.parse("2025-02-25")) - .settlementInstitutionId("1000000001") - .settlementService("015") - .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) - .cycle(0L) - .build() - - val roundtrippedNetworkTotalRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(networkTotalRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNetworkTotalRetrieveResponse).isEqualTo(networkTotalRetrieveResponse) - } -} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalListResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalTest.kt similarity index 58% rename from lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalListResponseTest.kt rename to lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalTest.kt index 58d139032..8288d354b 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalListResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalTest.kt @@ -9,15 +9,15 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class NetworkTotalListResponseTest { +internal class NetworkTotalTest { @Test fun create() { - val networkTotalListResponse = - NetworkTotalListResponse.builder() + val networkTotal = + NetworkTotal.builder() .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(85L) @@ -28,7 +28,7 @@ internal class NetworkTotalListResponseTest { .currency("CAD") .institutionId("1000000000") .isComplete(true) - .network(NetworkTotalListResponse.Network.VISA) + .network(NetworkTotal.Network.VISA) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("1000000001") .settlementService("015") @@ -36,40 +36,38 @@ internal class NetworkTotalListResponseTest { .cycle(0L) .build() - assertThat(networkTotalListResponse.token()) - .isEqualTo("12cf7505-06a8-435e-b1c7-4c430d02f6c3") - assertThat(networkTotalListResponse.amounts()) + assertThat(networkTotal.token()).isEqualTo("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + assertThat(networkTotal.amounts()) .isEqualTo( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(85L) .visaCharges(10L) .build() ) - assertThat(networkTotalListResponse.created()) + assertThat(networkTotal.created()) .isEqualTo(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) - assertThat(networkTotalListResponse.currency()).isEqualTo("CAD") - assertThat(networkTotalListResponse.institutionId()).isEqualTo("1000000000") - assertThat(networkTotalListResponse.isComplete()).isEqualTo(true) - assertThat(networkTotalListResponse.network()) - .isEqualTo(NetworkTotalListResponse.Network.VISA) - assertThat(networkTotalListResponse.reportDate()).isEqualTo(LocalDate.parse("2025-02-25")) - assertThat(networkTotalListResponse.settlementInstitutionId()).isEqualTo("1000000001") - assertThat(networkTotalListResponse.settlementService()).isEqualTo("015") - assertThat(networkTotalListResponse.updated()) + assertThat(networkTotal.currency()).isEqualTo("CAD") + assertThat(networkTotal.institutionId()).isEqualTo("1000000000") + assertThat(networkTotal.isComplete()).isEqualTo(true) + assertThat(networkTotal.network()).isEqualTo(NetworkTotal.Network.VISA) + assertThat(networkTotal.reportDate()).isEqualTo(LocalDate.parse("2025-02-25")) + assertThat(networkTotal.settlementInstitutionId()).isEqualTo("1000000001") + assertThat(networkTotal.settlementService()).isEqualTo("015") + assertThat(networkTotal.updated()) .isEqualTo(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) - assertThat(networkTotalListResponse.cycle()).contains(0L) + assertThat(networkTotal.cycle()).contains(0L) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val networkTotalListResponse = - NetworkTotalListResponse.builder() + val networkTotal = + NetworkTotal.builder() .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(85L) @@ -80,7 +78,7 @@ internal class NetworkTotalListResponseTest { .currency("CAD") .institutionId("1000000000") .isComplete(true) - .network(NetworkTotalListResponse.Network.VISA) + .network(NetworkTotal.Network.VISA) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("1000000001") .settlementService("015") @@ -88,12 +86,12 @@ internal class NetworkTotalListResponseTest { .cycle(0L) .build() - val roundtrippedNetworkTotalListResponse = + val roundtrippedNetworkTotal = jsonMapper.readValue( - jsonMapper.writeValueAsString(networkTotalListResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(networkTotal), + jacksonTypeRef(), ) - assertThat(roundtrippedNetworkTotalListResponse).isEqualTo(networkTotalListResponse) + assertThat(roundtrippedNetworkTotal).isEqualTo(networkTotal) } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt index 75f6cc4c9..c9e11ef66 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NonPciCardTest.kt @@ -37,6 +37,7 @@ internal class NonPciCardTest { .state(NonPciCard.State.CLOSED) .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardholderCurrency("USD") .comment("comment") .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -74,6 +75,7 @@ internal class NonPciCardTest { assertThat(nonPciCard.state()).isEqualTo(NonPciCard.State.CLOSED) assertThat(nonPciCard.type()).isEqualTo(NonPciCard.Type.MERCHANT_LOCKED) assertThat(nonPciCard.authRuleTokens().getOrNull()).containsExactly("string") + assertThat(nonPciCard.bulkOrderToken()).contains("5e9483eb-8103-4e16-9794-2106111b2eca") assertThat(nonPciCard.cardholderCurrency()).contains("USD") assertThat(nonPciCard.comment()).contains("comment") assertThat(nonPciCard.digitalCardArtToken()) @@ -117,6 +119,7 @@ internal class NonPciCardTest { .state(NonPciCard.State.CLOSED) .type(NonPciCard.Type.MERCHANT_LOCKED) .addAuthRuleToken("string") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardholderCurrency("USD") .comment("comment") .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageResponseTest.kt index 37e894b87..85dde2d4a 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ReportSettlementNetworkTotalListPageResponseTest.kt @@ -17,10 +17,10 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { ReportSettlementNetworkTotalListPageResponse.builder() .data( listOf( - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(85L) @@ -31,17 +31,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("CAD") .institutionId("1000000000") .isComplete(true) - .network(NetworkTotalListResponse.Network.VISA) + .network(NetworkTotal.Network.VISA) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("1000000001") .settlementService("015") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(0L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("0604c316-17f0-456d-9ac7-7d94252acb1a") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(200L) .interchangeFees(-50L) .netSettlement(160L) @@ -52,17 +52,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("1000000000") .isComplete(true) - .network(NetworkTotalListResponse.Network.INTERLINK) + .network(NetworkTotal.Network.INTERLINK) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("1000000001") .settlementService("001") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(0L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("700a1c78-04ed-47e2-8160-b1e18914ec7b") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(75L) @@ -73,17 +73,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("031511") .isComplete(false) - .network(NetworkTotalListResponse.Network.MASTERCARD) + .network(NetworkTotal.Network.MASTERCARD) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("031511") .settlementService("US00000001") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(1L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("e05d5448-210e-4cc3-bd0d-d54d3c6c9a9f") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(75L) @@ -94,7 +94,7 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("031511") .isComplete(true) - .network(NetworkTotalListResponse.Network.MASTERCARD) + .network(NetworkTotal.Network.MASTERCARD) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("031511") .settlementService("US00000001") @@ -108,10 +108,10 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { assertThat(reportSettlementNetworkTotalListPageResponse.data()) .containsExactly( - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(85L) @@ -122,17 +122,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("CAD") .institutionId("1000000000") .isComplete(true) - .network(NetworkTotalListResponse.Network.VISA) + .network(NetworkTotal.Network.VISA) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("1000000001") .settlementService("015") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(0L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("0604c316-17f0-456d-9ac7-7d94252acb1a") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(200L) .interchangeFees(-50L) .netSettlement(160L) @@ -143,17 +143,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("1000000000") .isComplete(true) - .network(NetworkTotalListResponse.Network.INTERLINK) + .network(NetworkTotal.Network.INTERLINK) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("1000000001") .settlementService("001") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(0L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("700a1c78-04ed-47e2-8160-b1e18914ec7b") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(75L) @@ -164,17 +164,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("031511") .isComplete(false) - .network(NetworkTotalListResponse.Network.MASTERCARD) + .network(NetworkTotal.Network.MASTERCARD) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("031511") .settlementService("US00000001") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(1L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("e05d5448-210e-4cc3-bd0d-d54d3c6c9a9f") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(75L) @@ -185,7 +185,7 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("031511") .isComplete(true) - .network(NetworkTotalListResponse.Network.MASTERCARD) + .network(NetworkTotal.Network.MASTERCARD) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("031511") .settlementService("US00000001") @@ -203,10 +203,10 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { ReportSettlementNetworkTotalListPageResponse.builder() .data( listOf( - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(85L) @@ -217,17 +217,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("CAD") .institutionId("1000000000") .isComplete(true) - .network(NetworkTotalListResponse.Network.VISA) + .network(NetworkTotal.Network.VISA) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("1000000001") .settlementService("015") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(0L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("0604c316-17f0-456d-9ac7-7d94252acb1a") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(200L) .interchangeFees(-50L) .netSettlement(160L) @@ -238,17 +238,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("1000000000") .isComplete(true) - .network(NetworkTotalListResponse.Network.INTERLINK) + .network(NetworkTotal.Network.INTERLINK) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("1000000001") .settlementService("001") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(0L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("700a1c78-04ed-47e2-8160-b1e18914ec7b") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(75L) @@ -259,17 +259,17 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("031511") .isComplete(false) - .network(NetworkTotalListResponse.Network.MASTERCARD) + .network(NetworkTotal.Network.MASTERCARD) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("031511") .settlementService("US00000001") .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) .cycle(1L) .build(), - NetworkTotalListResponse.builder() + NetworkTotal.builder() .token("e05d5448-210e-4cc3-bd0d-d54d3c6c9a9f") .amounts( - NetworkTotalListResponse.Amounts.builder() + NetworkTotal.Amounts.builder() .grossSettlement(100L) .interchangeFees(-25L) .netSettlement(75L) @@ -280,7 +280,7 @@ internal class ReportSettlementNetworkTotalListPageResponseTest { .currency("USD") .institutionId("031511") .isComplete(true) - .network(NetworkTotalListResponse.Network.MASTERCARD) + .network(NetworkTotal.Network.MASTERCARD) .reportDate(LocalDate.parse("2025-02-25")) .settlementInstitutionId("031511") .settlementService("US00000001") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthenticationRetrieveResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationTest.kt similarity index 55% rename from lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthenticationRetrieveResponseTest.kt rename to lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationTest.kt index bcda66924..e8028ae8a 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthenticationRetrieveResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationTest.kt @@ -8,25 +8,25 @@ import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class AuthenticationRetrieveResponseTest { +internal class ThreeDSAuthenticationTest { @Test fun create() { - val authenticationRetrieveResponse = - AuthenticationRetrieveResponse.builder() + val threeDSAuthentication = + ThreeDSAuthentication.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountType(AuthenticationRetrieveResponse.AccountType.CREDIT) - .authenticationResult(AuthenticationRetrieveResponse.AuthenticationResult.DECLINE) - .cardExpiryCheck(AuthenticationRetrieveResponse.CardExpiryCheck.MATCH) + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cardholder( - AuthenticationRetrieveResponse.Cardholder.builder() + ThreeDSAuthentication.Cardholder.builder() .addressMatch(true) .addressOnFileMatch( - AuthenticationRetrieveResponse.Cardholder.AddressMatchResult.MATCH + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH ) .billingAddress( - AuthenticationRetrieveResponse.Cardholder.BillingAddress.builder() + ThreeDSAuthentication.Cardholder.BillingAddress.builder() .address1("address1") .address2("address2") .address3("address3") @@ -41,7 +41,7 @@ internal class AuthenticationRetrieveResponseTest { .phoneNumberMobile("x") .phoneNumberWork("x") .shippingAddress( - AuthenticationRetrieveResponse.Cardholder.ShippingAddress.builder() + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() .address1("address1") .address2("address2") .address3("address3") @@ -52,37 +52,33 @@ internal class AuthenticationRetrieveResponseTest { ) .build() ) - .channel(AuthenticationRetrieveResponse.Channel.APP_BASED) + .channel(ThreeDSAuthentication.Channel.APP_BASED) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .merchant( - AuthenticationRetrieveResponse.Merchant.builder() + ThreeDSAuthentication.Merchant.builder() .riskIndicator( - AuthenticationRetrieveResponse.Merchant.RiskIndicator.builder() + ThreeDSAuthentication.Merchant.RiskIndicator.builder() .deliveryEmailAddress("delivery_email_address") .deliveryTimeFrame( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .DeliveryTimeFrame + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame .ELECTRONIC_DELIVERY ) .giftCardAmount(0L) .giftCardCount(0L) .giftCardCurrency("xxx") .orderAvailability( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .OrderAvailability + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability .FUTURE_AVAILABILITY ) .preOrderAvailableDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .reorderItems( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .ReorderItems + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems .FIRST_TIME_ORDERED ) .shippingMethod( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .ShippingMethod + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod .DIGITAL_GOODS ) .build() @@ -93,22 +89,20 @@ internal class AuthenticationRetrieveResponseTest { .name("name") .build() ) - .messageCategory( - AuthenticationRetrieveResponse.MessageCategory.NON_PAYMENT_AUTHENTICATION - ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) .threeDSRequestorChallengeIndicator( - AuthenticationRetrieveResponse.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE ) .additionalData( - AuthenticationRetrieveResponse.AdditionalData.builder() + ThreeDSAuthentication.AdditionalData.builder() .networkDecision( - AuthenticationRetrieveResponse.AdditionalData.NetworkDecision.LOW_RISK + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK ) .networkRiskScore(0L) .build() ) .app( - AuthenticationRetrieveResponse.App.builder() + ThreeDSAuthentication.App.builder() .device("device") .deviceInfo("device_info") .ip("ip") @@ -122,11 +116,9 @@ internal class AuthenticationRetrieveResponseTest { .timeZone("time_zone") .build() ) - .authenticationRequestType( - AuthenticationRetrieveResponse.AuthenticationRequestType.ADD_CARD - ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) .browser( - AuthenticationRetrieveResponse.Browser.builder() + ThreeDSAuthentication.Browser.builder() .acceptHeader("accept_header") .ip("ip") .javaEnabled(true) @@ -137,52 +129,43 @@ internal class AuthenticationRetrieveResponseTest { .build() ) .challengeMetadata( - AuthenticationRetrieveResponse.ChallengeMetadata.builder() - .methodType( - AuthenticationRetrieveResponse.ChallengeMetadata.MethodType.SMS_OTP - ) - .status(AuthenticationRetrieveResponse.ChallengeMetadata.Status.SUCCESS) + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) .phoneNumber("phone_number") .build() ) - .challengeOrchestratedBy( - AuthenticationRetrieveResponse.ChallengeOrchestratedBy.LITHIC - ) - .decisionMadeBy(AuthenticationRetrieveResponse.DecisionMadeBy.LITHIC_RULES) - .threeRiRequestType( - AuthenticationRetrieveResponse.ThreeRiRequestType.ACCOUNT_VERIFICATION - ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) .transaction( - AuthenticationRetrieveResponse.Transaction.builder() + ThreeDSAuthentication.Transaction.builder() .amount(0.0) .cardholderAmount(0.0) .currency("xxx") .currencyExponent(0.0) .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .type(AuthenticationRetrieveResponse.Transaction.Type.ACCOUNT_FUNDING) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) .build() ) .build() - assertThat(authenticationRetrieveResponse.token()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(authenticationRetrieveResponse.accountType()) - .contains(AuthenticationRetrieveResponse.AccountType.CREDIT) - assertThat(authenticationRetrieveResponse.authenticationResult()) - .isEqualTo(AuthenticationRetrieveResponse.AuthenticationResult.DECLINE) - assertThat(authenticationRetrieveResponse.cardExpiryCheck()) - .isEqualTo(AuthenticationRetrieveResponse.CardExpiryCheck.MATCH) - assertThat(authenticationRetrieveResponse.cardToken()) + assertThat(threeDSAuthentication.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(threeDSAuthentication.accountType()) + .contains(ThreeDSAuthentication.AccountType.CREDIT) + assertThat(threeDSAuthentication.authenticationResult()) + .isEqualTo(ThreeDSAuthentication.AuthenticationResult.DECLINE) + assertThat(threeDSAuthentication.cardExpiryCheck()) + .isEqualTo(ThreeDSAuthentication.CardExpiryCheck.MATCH) + assertThat(threeDSAuthentication.cardToken()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(authenticationRetrieveResponse.cardholder()) + assertThat(threeDSAuthentication.cardholder()) .isEqualTo( - AuthenticationRetrieveResponse.Cardholder.builder() + ThreeDSAuthentication.Cardholder.builder() .addressMatch(true) - .addressOnFileMatch( - AuthenticationRetrieveResponse.Cardholder.AddressMatchResult.MATCH - ) + .addressOnFileMatch(ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH) .billingAddress( - AuthenticationRetrieveResponse.Cardholder.BillingAddress.builder() + ThreeDSAuthentication.Cardholder.BillingAddress.builder() .address1("address1") .address2("address2") .address3("address3") @@ -197,7 +180,7 @@ internal class AuthenticationRetrieveResponseTest { .phoneNumberMobile("x") .phoneNumberWork("x") .shippingAddress( - AuthenticationRetrieveResponse.Cardholder.ShippingAddress.builder() + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() .address1("address1") .address2("address2") .address3("address3") @@ -208,36 +191,34 @@ internal class AuthenticationRetrieveResponseTest { ) .build() ) - assertThat(authenticationRetrieveResponse.channel()) - .isEqualTo(AuthenticationRetrieveResponse.Channel.APP_BASED) - assertThat(authenticationRetrieveResponse.created()) + assertThat(threeDSAuthentication.channel()) + .isEqualTo(ThreeDSAuthentication.Channel.APP_BASED) + assertThat(threeDSAuthentication.created()) .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(authenticationRetrieveResponse.merchant()) + assertThat(threeDSAuthentication.merchant()) .isEqualTo( - AuthenticationRetrieveResponse.Merchant.builder() + ThreeDSAuthentication.Merchant.builder() .riskIndicator( - AuthenticationRetrieveResponse.Merchant.RiskIndicator.builder() + ThreeDSAuthentication.Merchant.RiskIndicator.builder() .deliveryEmailAddress("delivery_email_address") .deliveryTimeFrame( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .DeliveryTimeFrame + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame .ELECTRONIC_DELIVERY ) .giftCardAmount(0L) .giftCardCount(0L) .giftCardCurrency("xxx") .orderAvailability( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .OrderAvailability + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability .FUTURE_AVAILABILITY ) .preOrderAvailableDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .reorderItems( - AuthenticationRetrieveResponse.Merchant.RiskIndicator.ReorderItems + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems .FIRST_TIME_ORDERED ) .shippingMethod( - AuthenticationRetrieveResponse.Merchant.RiskIndicator.ShippingMethod + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod .DIGITAL_GOODS ) .build() @@ -248,24 +229,20 @@ internal class AuthenticationRetrieveResponseTest { .name("name") .build() ) - assertThat(authenticationRetrieveResponse.messageCategory()) - .isEqualTo(AuthenticationRetrieveResponse.MessageCategory.NON_PAYMENT_AUTHENTICATION) - assertThat(authenticationRetrieveResponse.threeDSRequestorChallengeIndicator()) - .isEqualTo( - AuthenticationRetrieveResponse.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE - ) - assertThat(authenticationRetrieveResponse.additionalData()) + assertThat(threeDSAuthentication.messageCategory()) + .isEqualTo(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + assertThat(threeDSAuthentication.threeDSRequestorChallengeIndicator()) + .isEqualTo(ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE) + assertThat(threeDSAuthentication.additionalData()) .contains( - AuthenticationRetrieveResponse.AdditionalData.builder() - .networkDecision( - AuthenticationRetrieveResponse.AdditionalData.NetworkDecision.LOW_RISK - ) + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision(ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK) .networkRiskScore(0L) .build() ) - assertThat(authenticationRetrieveResponse.app()) + assertThat(threeDSAuthentication.app()) .contains( - AuthenticationRetrieveResponse.App.builder() + ThreeDSAuthentication.App.builder() .device("device") .deviceInfo("device_info") .ip("ip") @@ -279,11 +256,11 @@ internal class AuthenticationRetrieveResponseTest { .timeZone("time_zone") .build() ) - assertThat(authenticationRetrieveResponse.authenticationRequestType()) - .contains(AuthenticationRetrieveResponse.AuthenticationRequestType.ADD_CARD) - assertThat(authenticationRetrieveResponse.browser()) + assertThat(threeDSAuthentication.authenticationRequestType()) + .contains(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + assertThat(threeDSAuthentication.browser()) .contains( - AuthenticationRetrieveResponse.Browser.builder() + ThreeDSAuthentication.Browser.builder() .acceptHeader("accept_header") .ip("ip") .javaEnabled(true) @@ -293,29 +270,29 @@ internal class AuthenticationRetrieveResponseTest { .userAgent("user_agent") .build() ) - assertThat(authenticationRetrieveResponse.challengeMetadata()) + assertThat(threeDSAuthentication.challengeMetadata()) .contains( - AuthenticationRetrieveResponse.ChallengeMetadata.builder() - .methodType(AuthenticationRetrieveResponse.ChallengeMetadata.MethodType.SMS_OTP) - .status(AuthenticationRetrieveResponse.ChallengeMetadata.Status.SUCCESS) + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) .phoneNumber("phone_number") .build() ) - assertThat(authenticationRetrieveResponse.challengeOrchestratedBy()) - .contains(AuthenticationRetrieveResponse.ChallengeOrchestratedBy.LITHIC) - assertThat(authenticationRetrieveResponse.decisionMadeBy()) - .contains(AuthenticationRetrieveResponse.DecisionMadeBy.LITHIC_RULES) - assertThat(authenticationRetrieveResponse.threeRiRequestType()) - .contains(AuthenticationRetrieveResponse.ThreeRiRequestType.ACCOUNT_VERIFICATION) - assertThat(authenticationRetrieveResponse.transaction()) + assertThat(threeDSAuthentication.challengeOrchestratedBy()) + .contains(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + assertThat(threeDSAuthentication.decisionMadeBy()) + .contains(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + assertThat(threeDSAuthentication.threeRiRequestType()) + .contains(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + assertThat(threeDSAuthentication.transaction()) .contains( - AuthenticationRetrieveResponse.Transaction.builder() + ThreeDSAuthentication.Transaction.builder() .amount(0.0) .cardholderAmount(0.0) .currency("xxx") .currencyExponent(0.0) .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .type(AuthenticationRetrieveResponse.Transaction.Type.ACCOUNT_FUNDING) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) .build() ) } @@ -323,21 +300,21 @@ internal class AuthenticationRetrieveResponseTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val authenticationRetrieveResponse = - AuthenticationRetrieveResponse.builder() + val threeDSAuthentication = + ThreeDSAuthentication.builder() .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountType(AuthenticationRetrieveResponse.AccountType.CREDIT) - .authenticationResult(AuthenticationRetrieveResponse.AuthenticationResult.DECLINE) - .cardExpiryCheck(AuthenticationRetrieveResponse.CardExpiryCheck.MATCH) + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cardholder( - AuthenticationRetrieveResponse.Cardholder.builder() + ThreeDSAuthentication.Cardholder.builder() .addressMatch(true) .addressOnFileMatch( - AuthenticationRetrieveResponse.Cardholder.AddressMatchResult.MATCH + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH ) .billingAddress( - AuthenticationRetrieveResponse.Cardholder.BillingAddress.builder() + ThreeDSAuthentication.Cardholder.BillingAddress.builder() .address1("address1") .address2("address2") .address3("address3") @@ -352,7 +329,7 @@ internal class AuthenticationRetrieveResponseTest { .phoneNumberMobile("x") .phoneNumberWork("x") .shippingAddress( - AuthenticationRetrieveResponse.Cardholder.ShippingAddress.builder() + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() .address1("address1") .address2("address2") .address3("address3") @@ -363,37 +340,33 @@ internal class AuthenticationRetrieveResponseTest { ) .build() ) - .channel(AuthenticationRetrieveResponse.Channel.APP_BASED) + .channel(ThreeDSAuthentication.Channel.APP_BASED) .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .merchant( - AuthenticationRetrieveResponse.Merchant.builder() + ThreeDSAuthentication.Merchant.builder() .riskIndicator( - AuthenticationRetrieveResponse.Merchant.RiskIndicator.builder() + ThreeDSAuthentication.Merchant.RiskIndicator.builder() .deliveryEmailAddress("delivery_email_address") .deliveryTimeFrame( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .DeliveryTimeFrame + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame .ELECTRONIC_DELIVERY ) .giftCardAmount(0L) .giftCardCount(0L) .giftCardCurrency("xxx") .orderAvailability( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .OrderAvailability + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability .FUTURE_AVAILABILITY ) .preOrderAvailableDate( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .reorderItems( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .ReorderItems + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems .FIRST_TIME_ORDERED ) .shippingMethod( - AuthenticationRetrieveResponse.Merchant.RiskIndicator - .ShippingMethod + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod .DIGITAL_GOODS ) .build() @@ -404,22 +377,20 @@ internal class AuthenticationRetrieveResponseTest { .name("name") .build() ) - .messageCategory( - AuthenticationRetrieveResponse.MessageCategory.NON_PAYMENT_AUTHENTICATION - ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) .threeDSRequestorChallengeIndicator( - AuthenticationRetrieveResponse.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE ) .additionalData( - AuthenticationRetrieveResponse.AdditionalData.builder() + ThreeDSAuthentication.AdditionalData.builder() .networkDecision( - AuthenticationRetrieveResponse.AdditionalData.NetworkDecision.LOW_RISK + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK ) .networkRiskScore(0L) .build() ) .app( - AuthenticationRetrieveResponse.App.builder() + ThreeDSAuthentication.App.builder() .device("device") .deviceInfo("device_info") .ip("ip") @@ -433,11 +404,9 @@ internal class AuthenticationRetrieveResponseTest { .timeZone("time_zone") .build() ) - .authenticationRequestType( - AuthenticationRetrieveResponse.AuthenticationRequestType.ADD_CARD - ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) .browser( - AuthenticationRetrieveResponse.Browser.builder() + ThreeDSAuthentication.Browser.builder() .acceptHeader("accept_header") .ip("ip") .javaEnabled(true) @@ -448,40 +417,33 @@ internal class AuthenticationRetrieveResponseTest { .build() ) .challengeMetadata( - AuthenticationRetrieveResponse.ChallengeMetadata.builder() - .methodType( - AuthenticationRetrieveResponse.ChallengeMetadata.MethodType.SMS_OTP - ) - .status(AuthenticationRetrieveResponse.ChallengeMetadata.Status.SUCCESS) + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) .phoneNumber("phone_number") .build() ) - .challengeOrchestratedBy( - AuthenticationRetrieveResponse.ChallengeOrchestratedBy.LITHIC - ) - .decisionMadeBy(AuthenticationRetrieveResponse.DecisionMadeBy.LITHIC_RULES) - .threeRiRequestType( - AuthenticationRetrieveResponse.ThreeRiRequestType.ACCOUNT_VERIFICATION - ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) .transaction( - AuthenticationRetrieveResponse.Transaction.builder() + ThreeDSAuthentication.Transaction.builder() .amount(0.0) .cardholderAmount(0.0) .currency("xxx") .currencyExponent(0.0) .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .type(AuthenticationRetrieveResponse.Transaction.Type.ACCOUNT_FUNDING) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) .build() ) .build() - val roundtrippedAuthenticationRetrieveResponse = + val roundtrippedThreeDSAuthentication = jsonMapper.readValue( - jsonMapper.writeValueAsString(authenticationRetrieveResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(threeDSAuthentication), + jacksonTypeRef(), ) - assertThat(roundtrippedAuthenticationRetrieveResponse) - .isEqualTo(authenticationRetrieveResponse) + assertThat(roundtrippedThreeDSAuthentication).isEqualTo(threeDSAuthentication) } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenInfoTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenInfoTest.kt new file mode 100644 index 000000000..1257b4ccc --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenInfoTest.kt @@ -0,0 +1,32 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenInfoTest { + + @Test + fun create() { + val tokenInfo = TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() + + assertThat(tokenInfo.walletType()).isEqualTo(TokenInfo.WalletType.APPLE_PAY) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenInfo = TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() + + val roundtrippedTokenInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenInfo), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenInfo).isEqualTo(tokenInfo) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationListPageResponseTest.kt index e4b98ccd6..6eed7203f 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationListPageResponseTest.kt @@ -37,24 +37,18 @@ internal class TokenizationListPageResponseTest { Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED ) .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() + TokenizationRuleResult.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .explanation("explanation") .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult - .Result - .APPROVED - ) + .result(TokenizationRuleResult.Result.APPROVED) .build() ) .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 + TokenizationDeclineReason.ACCOUNT_SCORE_1 ) .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA + TokenizationTfaReason.WALLET_RECOMMENDED_TFA ) .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) .build() @@ -88,24 +82,15 @@ internal class TokenizationListPageResponseTest { Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED ) .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() + TokenizationRuleResult.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .explanation("explanation") .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult.Result - .APPROVED - ) + .result(TokenizationRuleResult.Result.APPROVED) .build() ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) .build() ) @@ -142,24 +127,18 @@ internal class TokenizationListPageResponseTest { Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED ) .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() + TokenizationRuleResult.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .explanation("explanation") .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult - .Result - .APPROVED - ) + .result(TokenizationRuleResult.Result.APPROVED) .build() ) .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason - .ACCOUNT_SCORE_1 + TokenizationDeclineReason.ACCOUNT_SCORE_1 ) .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA + TokenizationTfaReason.WALLET_RECOMMENDED_TFA ) .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) .build() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationRuleResultTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationRuleResultTest.kt new file mode 100644 index 000000000..ed937f9ae --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationRuleResultTest.kt @@ -0,0 +1,49 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenizationRuleResultTest { + + @Test + fun create() { + val tokenizationRuleResult = + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + + assertThat(tokenizationRuleResult.authRuleToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(tokenizationRuleResult.explanation()).contains("explanation") + assertThat(tokenizationRuleResult.name()).contains("name") + assertThat(tokenizationRuleResult.result()) + .isEqualTo(TokenizationRuleResult.Result.APPROVED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenizationRuleResult = + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + + val roundtrippedTokenizationRuleResult = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenizationRuleResult), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenizationRuleResult).isEqualTo(tokenizationRuleResult) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTest.kt index bac8f19be..552190bd0 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTest.kt @@ -33,23 +33,15 @@ internal class TokenizationTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED) .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() + TokenizationRuleResult.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .explanation("explanation") .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult.Result - .APPROVED - ) + .result(TokenizationRuleResult.Result.APPROVED) .build() ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason.ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) .build() ) @@ -80,22 +72,15 @@ internal class TokenizationTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED) .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() + TokenizationRuleResult.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .explanation("explanation") .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult.Result - .APPROVED - ) + .result(TokenizationRuleResult.Result.APPROVED) .build() ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason.ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason.WALLET_RECOMMENDED_TFA - ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) .build() ) @@ -126,23 +111,15 @@ internal class TokenizationTest { .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .result(Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED) .addRuleResult( - Tokenization.TokenizationEvent.TokenizationRuleResult.builder() + TokenizationRuleResult.builder() .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .explanation("explanation") .name("name") - .result( - Tokenization.TokenizationEvent.TokenizationRuleResult.Result - .APPROVED - ) + .result(TokenizationRuleResult.Result.APPROVED) .build() ) - .addTokenizationDeclineReason( - Tokenization.TokenizationEvent.TokenizationDeclineReason.ACCOUNT_SCORE_1 - ) - .addTokenizationTfaReason( - Tokenization.TokenizationEvent.TokenizationTfaReason - .WALLET_RECOMMENDED_TFA - ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionListPageResponseTest.kt index c45f7ac63..4f9b292ac 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionListPageResponseTest.kt @@ -61,21 +61,16 @@ internal class TransactionListPageResponseTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod - .FRICTIONLESS + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult - .SUCCESS - ) - .decisionMadeBy( - Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK + CardholderAuthentication.AuthenticationResult.SUCCESS ) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift - ._3DS_AUTHENTICATED + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED ) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() @@ -130,9 +125,7 @@ internal class TransactionListPageResponseTest { .settledAmount(0L) .status(Transaction.Status.PENDING) .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() ) .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) .addEvent( @@ -305,20 +298,16 @@ internal class TransactionListPageResponseTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod - .FRICTIONLESS + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS - ) - .decisionMadeBy( - Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK + CardholderAuthentication.AuthenticationResult.SUCCESS ) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift - ._3DS_AUTHENTICATED + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED ) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() @@ -371,9 +360,7 @@ internal class TransactionListPageResponseTest { .settledAmount(0L) .status(Transaction.Status.PENDING) .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() ) .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) .addEvent( @@ -545,21 +532,16 @@ internal class TransactionListPageResponseTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod - .FRICTIONLESS + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult - .SUCCESS - ) - .decisionMadeBy( - Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK + CardholderAuthentication.AuthenticationResult.SUCCESS ) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift - ._3DS_AUTHENTICATED + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED ) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() @@ -614,9 +596,7 @@ internal class TransactionListPageResponseTest { .settledAmount(0L) .status(Transaction.Status.PENDING) .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() ) .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) .addEvent( diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionTest.kt index 5f7d563a5..ff471573f 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionTest.kt @@ -59,17 +59,13 @@ internal class TransactionTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod.FRICTIONLESS - ) - .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS - ) - .decisionMadeBy(Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK) - .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() ) @@ -120,11 +116,7 @@ internal class TransactionTest { .result(Transaction.DeclineResult.APPROVED) .settledAmount(0L) .status(Transaction.Status.PENDING) - .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() - ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) .addEvent( Transaction.TransactionEvent.builder() @@ -280,17 +272,13 @@ internal class TransactionTest { assertThat(transaction.cardToken()).isEqualTo("aac502f9-aecc-458a-954e-4bcf6edb6123") assertThat(transaction.cardholderAuthentication()) .contains( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod.FRICTIONLESS - ) - .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS - ) - .decisionMadeBy(Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK) - .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() ) @@ -343,11 +331,7 @@ internal class TransactionTest { assertThat(transaction.settledAmount()).isEqualTo(0L) assertThat(transaction.status()).isEqualTo(Transaction.Status.PENDING) assertThat(transaction.tokenInfo()) - .contains( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() - ) + .contains(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) assertThat(transaction.updated()).isEqualTo(OffsetDateTime.parse("2023-08-03T18:42:30Z")) assertThat(transaction.events().getOrNull()) .containsExactly( @@ -507,17 +491,13 @@ internal class TransactionTest { ) .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") .cardholderAuthentication( - Transaction.CardholderAuthentication.builder() + CardholderAuthentication.builder() .authenticationMethod( - Transaction.CardholderAuthentication.AuthenticationMethod.FRICTIONLESS - ) - .authenticationResult( - Transaction.CardholderAuthentication.AuthenticationResult.SUCCESS - ) - .decisionMadeBy(Transaction.CardholderAuthentication.DecisionMadeBy.NETWORK) - .liabilityShift( - Transaction.CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") .build() ) @@ -568,11 +548,7 @@ internal class TransactionTest { .result(Transaction.DeclineResult.APPROVED) .settledAmount(0L) .status(Transaction.Status.PENDING) - .tokenInfo( - Transaction.TokenInfo.builder() - .walletType(Transaction.TokenInfo.WalletType.APPLE_PAY) - .build() - ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) .addEvent( Transaction.TransactionEvent.builder() diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/WalletDecisioningInfoTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/WalletDecisioningInfoTest.kt new file mode 100644 index 000000000..c15fb6f1e --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/WalletDecisioningInfoTest.kt @@ -0,0 +1,49 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WalletDecisioningInfoTest { + + @Test + fun create() { + val walletDecisioningInfo = + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + + assertThat(walletDecisioningInfo.accountScore()).contains("100") + assertThat(walletDecisioningInfo.deviceScore()).contains("100") + assertThat(walletDecisioningInfo.recommendedDecision()).contains("Decision1") + assertThat(walletDecisioningInfo.recommendationReasons().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val walletDecisioningInfo = + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + + val roundtrippedWalletDecisioningInfo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(walletDecisioningInfo), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWalletDecisioningInfo).isEqualTo(walletDecisioningInfo) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt index ee633e9be..29d4f88bb 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ErrorHandlingTest.kt @@ -77,6 +77,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -133,6 +134,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -189,6 +191,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -245,6 +248,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -301,6 +305,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -357,6 +362,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -413,6 +419,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -469,6 +476,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -525,6 +533,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -581,6 +590,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -637,6 +647,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -693,6 +704,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -749,6 +761,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -805,6 +818,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -861,6 +875,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -917,6 +932,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") @@ -971,6 +987,7 @@ internal class ErrorHandlingTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt index f180893b4..4e1916e3c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/ServiceParamsTest.kt @@ -47,6 +47,7 @@ internal class ServiceParamsTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsyncTest.kt new file mode 100644 index 000000000..3f784bf91 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardBulkOrderServiceAsyncTest.kt @@ -0,0 +1,101 @@ +// 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.core.JsonValue +import com.lithic.api.models.CardBulkOrderCreateParams +import com.lithic.api.models.CardBulkOrderUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardBulkOrderServiceAsyncTest { + + @Test + fun create() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardBulkOrderServiceAsync = client.cardBulkOrders() + + val cardBulkOrderFuture = + cardBulkOrderServiceAsync.create( + CardBulkOrderCreateParams.builder() + .customerProductId("custom-card-design-123") + .shippingAddress( + JsonValue.from( + mapOf( + "address1" to "123 Main Street", + "city" to "NEW YORK", + "country" to "USA", + "first_name" to "Johnny", + "last_name" to "Appleseed", + "postal_code" to "10001", + "state" to "NY", + ) + ) + ) + .shippingMethod(CardBulkOrderCreateParams.ShippingMethod.BULK_EXPEDITED) + .build() + ) + + val cardBulkOrder = cardBulkOrderFuture.get() + cardBulkOrder.validate() + } + + @Test + fun retrieve() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardBulkOrderServiceAsync = client.cardBulkOrders() + + val cardBulkOrderFuture = + cardBulkOrderServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + val cardBulkOrder = cardBulkOrderFuture.get() + cardBulkOrder.validate() + } + + @Test + fun update() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardBulkOrderServiceAsync = client.cardBulkOrders() + + val cardBulkOrderFuture = + cardBulkOrderServiceAsync.update( + CardBulkOrderUpdateParams.builder() + .bulkOrderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(CardBulkOrderUpdateParams.Status.LOCKED) + .build() + ) + + val cardBulkOrder = cardBulkOrderFuture.get() + cardBulkOrder.validate() + } + + @Test + fun list() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardBulkOrderServiceAsync = client.cardBulkOrders() + + val pageFuture = cardBulkOrderServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt index 2ea072311..f0265b2a9 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt @@ -36,6 +36,7 @@ internal class CardServiceAsyncTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncTest.kt index eebfe0891..0f695a6fd 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/ExternalBankAccountServiceAsyncTest.kt @@ -172,7 +172,7 @@ internal class ExternalBankAccountServiceAsyncTest { .build() val externalBankAccountServiceAsync = client.externalBankAccounts() - val responseFuture = + val externalBankAccountFuture = externalBankAccountServiceAsync.retryPrenote( ExternalBankAccountRetryPrenoteParams.builder() .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -180,8 +180,8 @@ internal class ExternalBankAccountServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val externalBankAccount = externalBankAccountFuture.get() + externalBankAccount.validate() } @Test @@ -193,10 +193,10 @@ internal class ExternalBankAccountServiceAsyncTest { .build() val externalBankAccountServiceAsync = client.externalBankAccounts() - val responseFuture = + val externalBankAccountFuture = externalBankAccountServiceAsync.unpause("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - val response = responseFuture.get() - response.validate() + val externalBankAccount = externalBankAccountFuture.get() + externalBankAccount.validate() } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncTest.kt index bf29cc15e..1aacf201c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/threeDS/AuthenticationServiceAsyncTest.kt @@ -21,11 +21,11 @@ internal class AuthenticationServiceAsyncTest { .build() val authenticationServiceAsync = client.threeDS().authentication() - val authenticationFuture = + val threeDSAuthenticationFuture = authenticationServiceAsync.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - val authentication = authenticationFuture.get() - authentication.validate() + val threeDSAuthentication = threeDSAuthenticationFuture.get() + threeDSAuthentication.validate() } @Test diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardBulkOrderServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardBulkOrderServiceTest.kt new file mode 100644 index 000000000..61e20abbe --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardBulkOrderServiceTest.kt @@ -0,0 +1,96 @@ +// 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.core.JsonValue +import com.lithic.api.models.CardBulkOrderCreateParams +import com.lithic.api.models.CardBulkOrderUpdateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardBulkOrderServiceTest { + + @Test + fun create() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardBulkOrderService = client.cardBulkOrders() + + val cardBulkOrder = + cardBulkOrderService.create( + CardBulkOrderCreateParams.builder() + .customerProductId("custom-card-design-123") + .shippingAddress( + JsonValue.from( + mapOf( + "address1" to "123 Main Street", + "city" to "NEW YORK", + "country" to "USA", + "first_name" to "Johnny", + "last_name" to "Appleseed", + "postal_code" to "10001", + "state" to "NY", + ) + ) + ) + .shippingMethod(CardBulkOrderCreateParams.ShippingMethod.BULK_EXPEDITED) + .build() + ) + + cardBulkOrder.validate() + } + + @Test + fun retrieve() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardBulkOrderService = client.cardBulkOrders() + + val cardBulkOrder = cardBulkOrderService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + + cardBulkOrder.validate() + } + + @Test + fun update() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardBulkOrderService = client.cardBulkOrders() + + val cardBulkOrder = + cardBulkOrderService.update( + CardBulkOrderUpdateParams.builder() + .bulkOrderToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(CardBulkOrderUpdateParams.Status.LOCKED) + .build() + ) + + cardBulkOrder.validate() + } + + @Test + fun list() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val cardBulkOrderService = client.cardBulkOrders() + + val page = cardBulkOrderService.list() + + page.response().validate() + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt index e9a299d20..5d1d2ab0d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt @@ -36,6 +36,7 @@ internal class CardServiceTest { CardCreateParams.builder() .type(CardCreateParams.Type.VIRTUAL) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .bulkOrderToken("5e9483eb-8103-4e16-9794-2106111b2eca") .cardProgramToken("5e9483eb-8103-4e16-9794-2106111b2eca") .carrier(Carrier.builder().qrCodeUrl("qr_code_url").build()) .digitalCardArtToken("5e9483eb-8103-4e16-9794-2106111b2eca") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceTest.kt index f4867a3b2..6b141dfa1 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/ExternalBankAccountServiceTest.kt @@ -167,7 +167,7 @@ internal class ExternalBankAccountServiceTest { .build() val externalBankAccountService = client.externalBankAccounts() - val response = + val externalBankAccount = externalBankAccountService.retryPrenote( ExternalBankAccountRetryPrenoteParams.builder() .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -175,7 +175,7 @@ internal class ExternalBankAccountServiceTest { .build() ) - response.validate() + externalBankAccount.validate() } @Test @@ -187,8 +187,9 @@ internal class ExternalBankAccountServiceTest { .build() val externalBankAccountService = client.externalBankAccounts() - val response = externalBankAccountService.unpause("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val externalBankAccount = + externalBankAccountService.unpause("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - response.validate() + externalBankAccount.validate() } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceTest.kt index 87446c47f..d5a28f1bb 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/threeDS/AuthenticationServiceTest.kt @@ -21,9 +21,10 @@ internal class AuthenticationServiceTest { .build() val authenticationService = client.threeDS().authentication() - val authentication = authenticationService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + val threeDSAuthentication = + authenticationService.retrieve("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - authentication.validate() + threeDSAuthentication.validate() } @Test 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 cd6e5f2db..f014312c9 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 @@ -59,6 +59,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.tokenizationDecisioning()).isNotNull() assertThat(client.tokenizations()).isNotNull() assertThat(client.cards()).isNotNull() + assertThat(client.cardBulkOrders()).isNotNull() assertThat(client.balances()).isNotNull() assertThat(client.aggregateBalances()).isNotNull() assertThat(client.disputes()).isNotNull() @@ -78,6 +79,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.creditProducts()).isNotNull() assertThat(client.externalPayments()).isNotNull() assertThat(client.managementOperations()).isNotNull() + assertThat(client.internalTransaction()).isNotNull() assertThat(client.fundingEvents()).isNotNull() assertThat(client.fraud()).isNotNull() assertThat(client.networkPrograms()).isNotNull() From d0cd05742ef5c0bc6c3ac80b3f94a2ade0be2d24 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 09:38:23 +0000 Subject: [PATCH 06/12] feat(api): Add new fee types feat(api): Add optional ach_hold_period feat(api): Add event_streams to auth rules APIs --- .stats.yml | 4 +- .../api/models/AccountActivityListParams.kt | 12 ++ .../api/models/AccountActivityListResponse.kt | 12 ++ ...ountActivityRetrieveTransactionResponse.kt | 12 ++ .../lithic/api/models/AuthRuleV2ListParams.kt | 199 +++++++++++++++++- .../com/lithic/api/models/ExternalPayment.kt | 72 +++++++ .../api/models/ExternalPaymentCreateParams.kt | 12 ++ .../api/models/ExternalPaymentListParams.kt | 12 ++ .../com/lithic/api/models/FinancialEvent.kt | 96 +++++++++ .../models/ManagementOperationCreateParams.kt | 36 ++++ .../models/ManagementOperationTransaction.kt | 36 ++++ .../kotlin/com/lithic/api/models/Payment.kt | 70 +++++- .../lithic/api/models/PaymentCreateParams.kt | 50 ++++- .../lithic/api/models/StatementLineItems.kt | 108 ++++++++++ .../models/AccountActivityListResponseTest.kt | 2 + ...ActivityRetrieveTransactionResponseTest.kt | 2 + .../api/models/AuthRuleV2ListParamsTest.kt | 3 + .../api/models/PaymentCreateParamsTest.kt | 3 + .../api/models/PaymentCreateResponseTest.kt | 3 + .../api/models/PaymentListPageResponseTest.kt | 3 + .../api/models/PaymentRetryResponseTest.kt | 3 + .../com/lithic/api/models/PaymentTest.kt | 3 + .../services/async/PaymentServiceAsyncTest.kt | 1 + .../services/blocking/PaymentServiceTest.kt | 1 + 24 files changed, 745 insertions(+), 10 deletions(-) diff --git a/.stats.yml b/.stats.yml index 284673ed2..225dcbad7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 176 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-6d54fb5bba49d761acf9d62a7e105443a80a0d34dda61932ff1d1cb8fe214393.yml -openapi_spec_hash: 20da53572fec9742df4a6d403464521b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-3e50857d2b8f4c85922abf83df7b3c6894f5bd500d6226ff589476029bbb258b.yml +openapi_spec_hash: 6bef8b283eb7292ad6f3f62d40fda699 config_hash: ba3fbfc99a1b8635d9e79e9e49d12952 diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListParams.kt index 94d194022..eb2aa72b3 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListParams.kt @@ -406,6 +406,10 @@ private constructor( @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmField val EXTERNAL_FEDNOW = of("EXTERNAL_FEDNOW") + + @JvmField val EXTERNAL_RTP = of("EXTERNAL_RTP") + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") @@ -437,6 +441,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -467,6 +473,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -501,6 +509,8 @@ private constructor( CARD -> Value.CARD EXTERNAL_ACH -> Value.EXTERNAL_ACH EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Value.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Value.EXTERNAL_RTP EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Value.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT @@ -533,6 +543,8 @@ private constructor( CARD -> Known.CARD EXTERNAL_ACH -> Known.EXTERNAL_ACH EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Known.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Known.EXTERNAL_RTP EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Known.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt index 9423d092f..24b758684 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityListResponse.kt @@ -1036,6 +1036,10 @@ private constructor( @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmField val EXTERNAL_FEDNOW = of("EXTERNAL_FEDNOW") + + @JvmField val EXTERNAL_RTP = of("EXTERNAL_RTP") + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") @@ -1067,6 +1071,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -1099,6 +1105,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -1133,6 +1141,8 @@ private constructor( CARD -> Value.CARD EXTERNAL_ACH -> Value.EXTERNAL_ACH EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Value.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Value.EXTERNAL_RTP EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Value.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT @@ -1165,6 +1175,8 @@ private constructor( CARD -> Known.CARD EXTERNAL_ACH -> Known.EXTERNAL_ACH EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Known.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Known.EXTERNAL_RTP EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Known.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt index 2990eb9af..fd6f20446 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponse.kt @@ -1058,6 +1058,10 @@ private constructor( @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmField val EXTERNAL_FEDNOW = of("EXTERNAL_FEDNOW") + + @JvmField val EXTERNAL_RTP = of("EXTERNAL_RTP") + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") @@ -1089,6 +1093,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -1121,6 +1127,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -1155,6 +1163,8 @@ private constructor( CARD -> Value.CARD EXTERNAL_ACH -> Value.EXTERNAL_ACH EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Value.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Value.EXTERNAL_RTP EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Value.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT @@ -1187,6 +1197,8 @@ private constructor( CARD -> Known.CARD EXTERNAL_ACH -> Known.EXTERNAL_ACH EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Known.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Known.EXTERNAL_RTP EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Known.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt index 56b4c09b8..cf1623671 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt @@ -8,6 +8,7 @@ import com.lithic.api.core.JsonField import com.lithic.api.core.Params import com.lithic.api.core.http.Headers import com.lithic.api.core.http.QueryParams +import com.lithic.api.core.toImmutable import com.lithic.api.errors.LithicInvalidDataException import java.util.Objects import java.util.Optional @@ -21,6 +22,7 @@ private constructor( private val cardToken: String?, private val endingBefore: String?, private val eventStream: EventStream?, + private val eventStreams: List?, private val pageSize: Long?, private val scope: Scope?, private val startingAfter: String?, @@ -43,9 +45,18 @@ private constructor( */ fun endingBefore(): Optional = Optional.ofNullable(endingBefore) - /** Only return Auth rules that are executed during the provided event stream. */ + /** + * Deprecated: Use event_streams instead. Only return Auth rules that are executed during the + * provided event stream. + */ fun eventStream(): Optional = Optional.ofNullable(eventStream) + /** + * Only return Auth rules that are executed during any of the provided event streams. If + * event_streams and event_stream are specified, the values will be combined. + */ + fun eventStreams(): Optional> = Optional.ofNullable(eventStreams) + /** Page size (for pagination). */ fun pageSize(): Optional = Optional.ofNullable(pageSize) @@ -82,6 +93,7 @@ private constructor( private var cardToken: String? = null private var endingBefore: String? = null private var eventStream: EventStream? = null + private var eventStreams: MutableList? = null private var pageSize: Long? = null private var scope: Scope? = null private var startingAfter: String? = null @@ -95,6 +107,7 @@ private constructor( cardToken = authRuleV2ListParams.cardToken endingBefore = authRuleV2ListParams.endingBefore eventStream = authRuleV2ListParams.eventStream + eventStreams = authRuleV2ListParams.eventStreams?.toMutableList() pageSize = authRuleV2ListParams.pageSize scope = authRuleV2ListParams.scope startingAfter = authRuleV2ListParams.startingAfter @@ -135,12 +148,36 @@ private constructor( /** Alias for calling [Builder.endingBefore] with `endingBefore.orElse(null)`. */ fun endingBefore(endingBefore: Optional) = endingBefore(endingBefore.getOrNull()) - /** Only return Auth rules that are executed during the provided event stream. */ + /** + * Deprecated: Use event_streams instead. Only return Auth rules that are executed during + * the provided event stream. + */ fun eventStream(eventStream: EventStream?) = apply { this.eventStream = eventStream } /** Alias for calling [Builder.eventStream] with `eventStream.orElse(null)`. */ fun eventStream(eventStream: Optional) = eventStream(eventStream.getOrNull()) + /** + * Only return Auth rules that are executed during any of the provided event streams. If + * event_streams and event_stream are specified, the values will be combined. + */ + fun eventStreams(eventStreams: List?) = apply { + this.eventStreams = eventStreams?.toMutableList() + } + + /** Alias for calling [Builder.eventStreams] with `eventStreams.orElse(null)`. */ + fun eventStreams(eventStreams: Optional>) = + eventStreams(eventStreams.getOrNull()) + + /** + * Adds a single [EventStream] to [eventStreams]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEventStream(eventStream: EventStream) = apply { + eventStreams = (eventStreams ?: mutableListOf()).apply { add(eventStream) } + } + /** Page size (for pagination). */ fun pageSize(pageSize: Long?) = apply { this.pageSize = pageSize } @@ -280,6 +317,7 @@ private constructor( cardToken, endingBefore, eventStream, + eventStreams?.toImmutable(), pageSize, scope, startingAfter, @@ -298,6 +336,7 @@ private constructor( cardToken?.let { put("card_token", it) } endingBefore?.let { put("ending_before", it) } eventStream?.let { put("event_stream", it.toString()) } + eventStreams?.let { put("event_streams", it.joinToString(",") { it.toString() }) } pageSize?.let { put("page_size", it.toString()) } scope?.let { put("scope", it.toString()) } startingAfter?.let { put("starting_after", it) } @@ -305,7 +344,157 @@ private constructor( } .build() - /** Only return Auth rules that are executed during the provided event stream. */ + /** + * Deprecated: Use event_streams instead. Only return Auth rules that are executed during the + * provided event stream. + */ + class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") + + @JvmField val TOKENIZATION = of("TOKENIZATION") + + @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") + + @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") + + @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) + } + + /** An enum containing [EventStream]'s known values. */ + enum class Known { + AUTHORIZATION, + THREE_DS_AUTHENTICATION, + TOKENIZATION, + ACH_CREDIT_RECEIPT, + ACH_DEBIT_RECEIPT, + } + + /** + * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventStream] 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, + THREE_DS_AUTHENTICATION, + TOKENIZATION, + ACH_CREDIT_RECEIPT, + ACH_DEBIT_RECEIPT, + /** + * An enum member indicating that [EventStream] 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 + THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION + TOKENIZATION -> Value.TOKENIZATION + ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT + ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT + 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 + THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION + TOKENIZATION -> Known.TOKENIZATION + ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT + ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT + else -> throw LithicInvalidDataException("Unknown EventStream: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): EventStream = 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 EventStream && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The event stream during which the rule will be evaluated. */ class EventStream @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -607,6 +796,7 @@ private constructor( cardToken == other.cardToken && endingBefore == other.endingBefore && eventStream == other.eventStream && + eventStreams == other.eventStreams && pageSize == other.pageSize && scope == other.scope && startingAfter == other.startingAfter && @@ -621,6 +811,7 @@ private constructor( cardToken, endingBefore, eventStream, + eventStreams, pageSize, scope, startingAfter, @@ -629,5 +820,5 @@ private constructor( ) override fun toString() = - "AuthRuleV2ListParams{accountToken=$accountToken, businessAccountToken=$businessAccountToken, cardToken=$cardToken, endingBefore=$endingBefore, eventStream=$eventStream, pageSize=$pageSize, scope=$scope, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "AuthRuleV2ListParams{accountToken=$accountToken, businessAccountToken=$businessAccountToken, cardToken=$cardToken, endingBefore=$endingBefore, eventStream=$eventStream, eventStreams=$eventStreams, pageSize=$pageSize, scope=$scope, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt index 66f6df7a2..d3190bb8c 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPayment.kt @@ -845,6 +845,10 @@ private constructor( @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmField val EXTERNAL_FEDNOW = of("EXTERNAL_FEDNOW") + + @JvmField val EXTERNAL_RTP = of("EXTERNAL_RTP") + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") @JvmStatic fun of(value: String) = ExternalPaymentCategory(JsonField.of(value)) @@ -855,6 +859,8 @@ private constructor( EXTERNAL_WIRE, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, } @@ -873,6 +879,8 @@ private constructor( EXTERNAL_WIRE, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, /** * An enum member indicating that [ExternalPaymentCategory] was instantiated with an @@ -893,6 +901,8 @@ private constructor( EXTERNAL_WIRE -> Value.EXTERNAL_WIRE EXTERNAL_ACH -> Value.EXTERNAL_ACH EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Value.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Value.EXTERNAL_RTP EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER else -> Value._UNKNOWN } @@ -911,6 +921,8 @@ private constructor( EXTERNAL_WIRE -> Known.EXTERNAL_WIRE EXTERNAL_ACH -> Known.EXTERNAL_ACH EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Known.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Known.EXTERNAL_RTP EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER else -> throw LithicInvalidDataException("Unknown ExternalPaymentCategory: $value") } @@ -1705,6 +1717,26 @@ private constructor( @JvmField val EXTERNAL_CHECK_RELEASED = of("EXTERNAL_CHECK_RELEASED") + @JvmField val EXTERNAL_FEDNOW_INITIATED = of("EXTERNAL_FEDNOW_INITIATED") + + @JvmField val EXTERNAL_FEDNOW_CANCELED = of("EXTERNAL_FEDNOW_CANCELED") + + @JvmField val EXTERNAL_FEDNOW_SETTLED = of("EXTERNAL_FEDNOW_SETTLED") + + @JvmField val EXTERNAL_FEDNOW_REVERSED = of("EXTERNAL_FEDNOW_REVERSED") + + @JvmField val EXTERNAL_FEDNOW_RELEASED = of("EXTERNAL_FEDNOW_RELEASED") + + @JvmField val EXTERNAL_RTP_INITIATED = of("EXTERNAL_RTP_INITIATED") + + @JvmField val EXTERNAL_RTP_CANCELED = of("EXTERNAL_RTP_CANCELED") + + @JvmField val EXTERNAL_RTP_SETTLED = of("EXTERNAL_RTP_SETTLED") + + @JvmField val EXTERNAL_RTP_REVERSED = of("EXTERNAL_RTP_REVERSED") + + @JvmField val EXTERNAL_RTP_RELEASED = of("EXTERNAL_RTP_RELEASED") + @JvmStatic fun of(value: String) = ExternalPaymentEventType(JsonField.of(value)) } @@ -1730,6 +1762,16 @@ private constructor( EXTERNAL_CHECK_SETTLED, EXTERNAL_CHECK_REVERSED, EXTERNAL_CHECK_RELEASED, + EXTERNAL_FEDNOW_INITIATED, + EXTERNAL_FEDNOW_CANCELED, + EXTERNAL_FEDNOW_SETTLED, + EXTERNAL_FEDNOW_REVERSED, + EXTERNAL_FEDNOW_RELEASED, + EXTERNAL_RTP_INITIATED, + EXTERNAL_RTP_CANCELED, + EXTERNAL_RTP_SETTLED, + EXTERNAL_RTP_REVERSED, + EXTERNAL_RTP_RELEASED, } /** @@ -1764,6 +1806,16 @@ private constructor( EXTERNAL_CHECK_SETTLED, EXTERNAL_CHECK_REVERSED, EXTERNAL_CHECK_RELEASED, + EXTERNAL_FEDNOW_INITIATED, + EXTERNAL_FEDNOW_CANCELED, + EXTERNAL_FEDNOW_SETTLED, + EXTERNAL_FEDNOW_REVERSED, + EXTERNAL_FEDNOW_RELEASED, + EXTERNAL_RTP_INITIATED, + EXTERNAL_RTP_CANCELED, + EXTERNAL_RTP_SETTLED, + EXTERNAL_RTP_REVERSED, + EXTERNAL_RTP_RELEASED, /** * An enum member indicating that [ExternalPaymentEventType] was instantiated with * an unknown value. @@ -1800,6 +1852,16 @@ private constructor( EXTERNAL_CHECK_SETTLED -> Value.EXTERNAL_CHECK_SETTLED EXTERNAL_CHECK_REVERSED -> Value.EXTERNAL_CHECK_REVERSED EXTERNAL_CHECK_RELEASED -> Value.EXTERNAL_CHECK_RELEASED + EXTERNAL_FEDNOW_INITIATED -> Value.EXTERNAL_FEDNOW_INITIATED + EXTERNAL_FEDNOW_CANCELED -> Value.EXTERNAL_FEDNOW_CANCELED + EXTERNAL_FEDNOW_SETTLED -> Value.EXTERNAL_FEDNOW_SETTLED + EXTERNAL_FEDNOW_REVERSED -> Value.EXTERNAL_FEDNOW_REVERSED + EXTERNAL_FEDNOW_RELEASED -> Value.EXTERNAL_FEDNOW_RELEASED + EXTERNAL_RTP_INITIATED -> Value.EXTERNAL_RTP_INITIATED + EXTERNAL_RTP_CANCELED -> Value.EXTERNAL_RTP_CANCELED + EXTERNAL_RTP_SETTLED -> Value.EXTERNAL_RTP_SETTLED + EXTERNAL_RTP_REVERSED -> Value.EXTERNAL_RTP_REVERSED + EXTERNAL_RTP_RELEASED -> Value.EXTERNAL_RTP_RELEASED else -> Value._UNKNOWN } @@ -1834,6 +1896,16 @@ private constructor( EXTERNAL_CHECK_SETTLED -> Known.EXTERNAL_CHECK_SETTLED EXTERNAL_CHECK_REVERSED -> Known.EXTERNAL_CHECK_REVERSED EXTERNAL_CHECK_RELEASED -> Known.EXTERNAL_CHECK_RELEASED + EXTERNAL_FEDNOW_INITIATED -> Known.EXTERNAL_FEDNOW_INITIATED + EXTERNAL_FEDNOW_CANCELED -> Known.EXTERNAL_FEDNOW_CANCELED + EXTERNAL_FEDNOW_SETTLED -> Known.EXTERNAL_FEDNOW_SETTLED + EXTERNAL_FEDNOW_REVERSED -> Known.EXTERNAL_FEDNOW_REVERSED + EXTERNAL_FEDNOW_RELEASED -> Known.EXTERNAL_FEDNOW_RELEASED + EXTERNAL_RTP_INITIATED -> Known.EXTERNAL_RTP_INITIATED + EXTERNAL_RTP_CANCELED -> Known.EXTERNAL_RTP_CANCELED + EXTERNAL_RTP_SETTLED -> Known.EXTERNAL_RTP_SETTLED + EXTERNAL_RTP_REVERSED -> Known.EXTERNAL_RTP_REVERSED + EXTERNAL_RTP_RELEASED -> Known.EXTERNAL_RTP_RELEASED else -> throw LithicInvalidDataException("Unknown ExternalPaymentEventType: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt index 763d2d274..71dcbce80 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreateParams.kt @@ -979,6 +979,10 @@ private constructor( @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmField val EXTERNAL_FEDNOW = of("EXTERNAL_FEDNOW") + + @JvmField val EXTERNAL_RTP = of("EXTERNAL_RTP") + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") @JvmStatic fun of(value: String) = ExternalPaymentCategory(JsonField.of(value)) @@ -989,6 +993,8 @@ private constructor( EXTERNAL_WIRE, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, } @@ -1007,6 +1013,8 @@ private constructor( EXTERNAL_WIRE, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, /** * An enum member indicating that [ExternalPaymentCategory] was instantiated with an @@ -1027,6 +1035,8 @@ private constructor( EXTERNAL_WIRE -> Value.EXTERNAL_WIRE EXTERNAL_ACH -> Value.EXTERNAL_ACH EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Value.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Value.EXTERNAL_RTP EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER else -> Value._UNKNOWN } @@ -1045,6 +1055,8 @@ private constructor( EXTERNAL_WIRE -> Known.EXTERNAL_WIRE EXTERNAL_ACH -> Known.EXTERNAL_ACH EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Known.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Known.EXTERNAL_RTP EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER else -> throw LithicInvalidDataException("Unknown ExternalPaymentCategory: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListParams.kt index 53ccb3803..40205f39d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentListParams.kt @@ -382,6 +382,10 @@ private constructor( @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmField val EXTERNAL_FEDNOW = of("EXTERNAL_FEDNOW") + + @JvmField val EXTERNAL_RTP = of("EXTERNAL_RTP") + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") @JvmStatic fun of(value: String) = ExternalPaymentCategory(JsonField.of(value)) @@ -392,6 +396,8 @@ private constructor( EXTERNAL_WIRE, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, } @@ -410,6 +416,8 @@ private constructor( EXTERNAL_WIRE, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, /** * An enum member indicating that [ExternalPaymentCategory] was instantiated with an @@ -430,6 +438,8 @@ private constructor( EXTERNAL_WIRE -> Value.EXTERNAL_WIRE EXTERNAL_ACH -> Value.EXTERNAL_ACH EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Value.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Value.EXTERNAL_RTP EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER else -> Value._UNKNOWN } @@ -448,6 +458,8 @@ private constructor( EXTERNAL_WIRE -> Known.EXTERNAL_WIRE EXTERNAL_ACH -> Known.EXTERNAL_ACH EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Known.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Known.EXTERNAL_RTP EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER else -> throw LithicInvalidDataException("Unknown ExternalPaymentCategory: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialEvent.kt index e79f4f5d8..018609405 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialEvent.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialEvent.kt @@ -518,6 +518,26 @@ private constructor( @JvmField val EXTERNAL_CHECK_SETTLED = of("EXTERNAL_CHECK_SETTLED") + @JvmField val EXTERNAL_FEDNOW_CANCELED = of("EXTERNAL_FEDNOW_CANCELED") + + @JvmField val EXTERNAL_FEDNOW_INITIATED = of("EXTERNAL_FEDNOW_INITIATED") + + @JvmField val EXTERNAL_FEDNOW_RELEASED = of("EXTERNAL_FEDNOW_RELEASED") + + @JvmField val EXTERNAL_FEDNOW_REVERSED = of("EXTERNAL_FEDNOW_REVERSED") + + @JvmField val EXTERNAL_FEDNOW_SETTLED = of("EXTERNAL_FEDNOW_SETTLED") + + @JvmField val EXTERNAL_RTP_CANCELED = of("EXTERNAL_RTP_CANCELED") + + @JvmField val EXTERNAL_RTP_INITIATED = of("EXTERNAL_RTP_INITIATED") + + @JvmField val EXTERNAL_RTP_RELEASED = of("EXTERNAL_RTP_RELEASED") + + @JvmField val EXTERNAL_RTP_REVERSED = of("EXTERNAL_RTP_REVERSED") + + @JvmField val EXTERNAL_RTP_SETTLED = of("EXTERNAL_RTP_SETTLED") + @JvmField val EXTERNAL_TRANSFER_CANCELED = of("EXTERNAL_TRANSFER_CANCELED") @JvmField val EXTERNAL_TRANSFER_INITIATED = of("EXTERNAL_TRANSFER_INITIATED") @@ -574,6 +594,18 @@ private constructor( @JvmField val LITHIC_NETWORK_PAYMENT = of("LITHIC_NETWORK_PAYMENT") + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val ANNUAL_REVERSAL = of("ANNUAL_REVERSAL") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val QUARTERLY_REVERSAL = of("QUARTERLY_REVERSAL") + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val MONTHLY_REVERSAL = of("MONTHLY_REVERSAL") + @JvmStatic fun of(value: String) = FinancialEventType(JsonField.of(value)) } @@ -622,6 +654,16 @@ private constructor( EXTERNAL_CHECK_RELEASED, EXTERNAL_CHECK_REVERSED, EXTERNAL_CHECK_SETTLED, + EXTERNAL_FEDNOW_CANCELED, + EXTERNAL_FEDNOW_INITIATED, + EXTERNAL_FEDNOW_RELEASED, + EXTERNAL_FEDNOW_REVERSED, + EXTERNAL_FEDNOW_SETTLED, + EXTERNAL_RTP_CANCELED, + EXTERNAL_RTP_INITIATED, + EXTERNAL_RTP_RELEASED, + EXTERNAL_RTP_REVERSED, + EXTERNAL_RTP_SETTLED, EXTERNAL_TRANSFER_CANCELED, EXTERNAL_TRANSFER_INITIATED, EXTERNAL_TRANSFER_RELEASED, @@ -650,6 +692,12 @@ private constructor( RETURNED_PAYMENT, RETURNED_PAYMENT_REVERSAL, LITHIC_NETWORK_PAYMENT, + ANNUAL, + ANNUAL_REVERSAL, + QUARTERLY, + QUARTERLY_REVERSAL, + MONTHLY, + MONTHLY_REVERSAL, } /** @@ -705,6 +753,16 @@ private constructor( EXTERNAL_CHECK_RELEASED, EXTERNAL_CHECK_REVERSED, EXTERNAL_CHECK_SETTLED, + EXTERNAL_FEDNOW_CANCELED, + EXTERNAL_FEDNOW_INITIATED, + EXTERNAL_FEDNOW_RELEASED, + EXTERNAL_FEDNOW_REVERSED, + EXTERNAL_FEDNOW_SETTLED, + EXTERNAL_RTP_CANCELED, + EXTERNAL_RTP_INITIATED, + EXTERNAL_RTP_RELEASED, + EXTERNAL_RTP_REVERSED, + EXTERNAL_RTP_SETTLED, EXTERNAL_TRANSFER_CANCELED, EXTERNAL_TRANSFER_INITIATED, EXTERNAL_TRANSFER_RELEASED, @@ -733,6 +791,12 @@ private constructor( RETURNED_PAYMENT, RETURNED_PAYMENT_REVERSAL, LITHIC_NETWORK_PAYMENT, + ANNUAL, + ANNUAL_REVERSAL, + QUARTERLY, + QUARTERLY_REVERSAL, + MONTHLY, + MONTHLY_REVERSAL, /** * An enum member indicating that [FinancialEventType] was instantiated with an unknown * value. @@ -792,6 +856,16 @@ private constructor( EXTERNAL_CHECK_RELEASED -> Value.EXTERNAL_CHECK_RELEASED EXTERNAL_CHECK_REVERSED -> Value.EXTERNAL_CHECK_REVERSED EXTERNAL_CHECK_SETTLED -> Value.EXTERNAL_CHECK_SETTLED + EXTERNAL_FEDNOW_CANCELED -> Value.EXTERNAL_FEDNOW_CANCELED + EXTERNAL_FEDNOW_INITIATED -> Value.EXTERNAL_FEDNOW_INITIATED + EXTERNAL_FEDNOW_RELEASED -> Value.EXTERNAL_FEDNOW_RELEASED + EXTERNAL_FEDNOW_REVERSED -> Value.EXTERNAL_FEDNOW_REVERSED + EXTERNAL_FEDNOW_SETTLED -> Value.EXTERNAL_FEDNOW_SETTLED + EXTERNAL_RTP_CANCELED -> Value.EXTERNAL_RTP_CANCELED + EXTERNAL_RTP_INITIATED -> Value.EXTERNAL_RTP_INITIATED + EXTERNAL_RTP_RELEASED -> Value.EXTERNAL_RTP_RELEASED + EXTERNAL_RTP_REVERSED -> Value.EXTERNAL_RTP_REVERSED + EXTERNAL_RTP_SETTLED -> Value.EXTERNAL_RTP_SETTLED EXTERNAL_TRANSFER_CANCELED -> Value.EXTERNAL_TRANSFER_CANCELED EXTERNAL_TRANSFER_INITIATED -> Value.EXTERNAL_TRANSFER_INITIATED EXTERNAL_TRANSFER_RELEASED -> Value.EXTERNAL_TRANSFER_RELEASED @@ -820,6 +894,12 @@ private constructor( RETURNED_PAYMENT -> Value.RETURNED_PAYMENT RETURNED_PAYMENT_REVERSAL -> Value.RETURNED_PAYMENT_REVERSAL LITHIC_NETWORK_PAYMENT -> Value.LITHIC_NETWORK_PAYMENT + ANNUAL -> Value.ANNUAL + ANNUAL_REVERSAL -> Value.ANNUAL_REVERSAL + QUARTERLY -> Value.QUARTERLY + QUARTERLY_REVERSAL -> Value.QUARTERLY_REVERSAL + MONTHLY -> Value.MONTHLY + MONTHLY_REVERSAL -> Value.MONTHLY_REVERSAL else -> Value._UNKNOWN } @@ -877,6 +957,16 @@ private constructor( EXTERNAL_CHECK_RELEASED -> Known.EXTERNAL_CHECK_RELEASED EXTERNAL_CHECK_REVERSED -> Known.EXTERNAL_CHECK_REVERSED EXTERNAL_CHECK_SETTLED -> Known.EXTERNAL_CHECK_SETTLED + EXTERNAL_FEDNOW_CANCELED -> Known.EXTERNAL_FEDNOW_CANCELED + EXTERNAL_FEDNOW_INITIATED -> Known.EXTERNAL_FEDNOW_INITIATED + EXTERNAL_FEDNOW_RELEASED -> Known.EXTERNAL_FEDNOW_RELEASED + EXTERNAL_FEDNOW_REVERSED -> Known.EXTERNAL_FEDNOW_REVERSED + EXTERNAL_FEDNOW_SETTLED -> Known.EXTERNAL_FEDNOW_SETTLED + EXTERNAL_RTP_CANCELED -> Known.EXTERNAL_RTP_CANCELED + EXTERNAL_RTP_INITIATED -> Known.EXTERNAL_RTP_INITIATED + EXTERNAL_RTP_RELEASED -> Known.EXTERNAL_RTP_RELEASED + EXTERNAL_RTP_REVERSED -> Known.EXTERNAL_RTP_REVERSED + EXTERNAL_RTP_SETTLED -> Known.EXTERNAL_RTP_SETTLED EXTERNAL_TRANSFER_CANCELED -> Known.EXTERNAL_TRANSFER_CANCELED EXTERNAL_TRANSFER_INITIATED -> Known.EXTERNAL_TRANSFER_INITIATED EXTERNAL_TRANSFER_RELEASED -> Known.EXTERNAL_TRANSFER_RELEASED @@ -905,6 +995,12 @@ private constructor( RETURNED_PAYMENT -> Known.RETURNED_PAYMENT RETURNED_PAYMENT_REVERSAL -> Known.RETURNED_PAYMENT_REVERSAL LITHIC_NETWORK_PAYMENT -> Known.LITHIC_NETWORK_PAYMENT + ANNUAL -> Known.ANNUAL + ANNUAL_REVERSAL -> Known.ANNUAL_REVERSAL + QUARTERLY -> Known.QUARTERLY + QUARTERLY_REVERSAL -> Known.QUARTERLY_REVERSAL + MONTHLY -> Known.MONTHLY + MONTHLY_REVERSAL -> Known.MONTHLY_REVERSAL else -> throw LithicInvalidDataException("Unknown FinancialEventType: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt index 8415b8596..1e8bb83aa 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreateParams.kt @@ -1432,6 +1432,18 @@ private constructor( @JvmField val DISBURSE_REVERSAL = of("DISBURSE_REVERSAL") + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val ANNUAL_REVERSAL = of("ANNUAL_REVERSAL") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val QUARTERLY_REVERSAL = of("QUARTERLY_REVERSAL") + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val MONTHLY_REVERSAL = of("MONTHLY_REVERSAL") + @JvmStatic fun of(value: String) = ManagementOperationEventType(JsonField.of(value)) } @@ -1456,6 +1468,12 @@ private constructor( DISPUTE_WON_REVERSAL, DISBURSE, DISBURSE_REVERSAL, + ANNUAL, + ANNUAL_REVERSAL, + QUARTERLY, + QUARTERLY_REVERSAL, + MONTHLY, + MONTHLY_REVERSAL, } /** @@ -1489,6 +1507,12 @@ private constructor( DISPUTE_WON_REVERSAL, DISBURSE, DISBURSE_REVERSAL, + ANNUAL, + ANNUAL_REVERSAL, + QUARTERLY, + QUARTERLY_REVERSAL, + MONTHLY, + MONTHLY_REVERSAL, /** * An enum member indicating that [ManagementOperationEventType] was instantiated with * an unknown value. @@ -1524,6 +1548,12 @@ private constructor( DISPUTE_WON_REVERSAL -> Value.DISPUTE_WON_REVERSAL DISBURSE -> Value.DISBURSE DISBURSE_REVERSAL -> Value.DISBURSE_REVERSAL + ANNUAL -> Value.ANNUAL + ANNUAL_REVERSAL -> Value.ANNUAL_REVERSAL + QUARTERLY -> Value.QUARTERLY + QUARTERLY_REVERSAL -> Value.QUARTERLY_REVERSAL + MONTHLY -> Value.MONTHLY + MONTHLY_REVERSAL -> Value.MONTHLY_REVERSAL else -> Value._UNKNOWN } @@ -1557,6 +1587,12 @@ private constructor( DISPUTE_WON_REVERSAL -> Known.DISPUTE_WON_REVERSAL DISBURSE -> Known.DISBURSE DISBURSE_REVERSAL -> Known.DISBURSE_REVERSAL + ANNUAL -> Known.ANNUAL + ANNUAL_REVERSAL -> Known.ANNUAL_REVERSAL + QUARTERLY -> Known.QUARTERLY + QUARTERLY_REVERSAL -> Known.QUARTERLY_REVERSAL + MONTHLY -> Known.MONTHLY + MONTHLY_REVERSAL -> Known.MONTHLY_REVERSAL else -> throw LithicInvalidDataException("Unknown ManagementOperationEventType: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt index 7d47c146b..b47a6e808 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationTransaction.kt @@ -1973,6 +1973,18 @@ private constructor( @JvmField val DISBURSE_REVERSAL = of("DISBURSE_REVERSAL") + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val ANNUAL_REVERSAL = of("ANNUAL_REVERSAL") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val QUARTERLY_REVERSAL = of("QUARTERLY_REVERSAL") + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val MONTHLY_REVERSAL = of("MONTHLY_REVERSAL") + @JvmStatic fun of(value: String) = ManagementOperationEventType(JsonField.of(value)) } @@ -1997,6 +2009,12 @@ private constructor( DISPUTE_WON_REVERSAL, DISBURSE, DISBURSE_REVERSAL, + ANNUAL, + ANNUAL_REVERSAL, + QUARTERLY, + QUARTERLY_REVERSAL, + MONTHLY, + MONTHLY_REVERSAL, } /** @@ -2030,6 +2048,12 @@ private constructor( DISPUTE_WON_REVERSAL, DISBURSE, DISBURSE_REVERSAL, + ANNUAL, + ANNUAL_REVERSAL, + QUARTERLY, + QUARTERLY_REVERSAL, + MONTHLY, + MONTHLY_REVERSAL, /** * An enum member indicating that [ManagementOperationEventType] was instantiated * with an unknown value. @@ -2065,6 +2089,12 @@ private constructor( DISPUTE_WON_REVERSAL -> Value.DISPUTE_WON_REVERSAL DISBURSE -> Value.DISBURSE DISBURSE_REVERSAL -> Value.DISBURSE_REVERSAL + ANNUAL -> Value.ANNUAL + ANNUAL_REVERSAL -> Value.ANNUAL_REVERSAL + QUARTERLY -> Value.QUARTERLY + QUARTERLY_REVERSAL -> Value.QUARTERLY_REVERSAL + MONTHLY -> Value.MONTHLY + MONTHLY_REVERSAL -> Value.MONTHLY_REVERSAL else -> Value._UNKNOWN } @@ -2098,6 +2128,12 @@ private constructor( DISPUTE_WON_REVERSAL -> Known.DISPUTE_WON_REVERSAL DISBURSE -> Known.DISBURSE DISBURSE_REVERSAL -> Known.DISBURSE_REVERSAL + ANNUAL -> Known.ANNUAL + ANNUAL_REVERSAL -> Known.ANNUAL_REVERSAL + QUARTERLY -> Known.QUARTERLY + QUARTERLY_REVERSAL -> Known.QUARTERLY_REVERSAL + MONTHLY -> Known.MONTHLY + MONTHLY_REVERSAL -> Known.MONTHLY_REVERSAL else -> throw LithicInvalidDataException( "Unknown ManagementOperationEventType: $value" diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt index 229b5a287..aa49240b6 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/Payment.kt @@ -1102,6 +1102,10 @@ private constructor( @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmField val EXTERNAL_FEDNOW = of("EXTERNAL_FEDNOW") + + @JvmField val EXTERNAL_RTP = of("EXTERNAL_RTP") + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") @@ -1133,6 +1137,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -1163,6 +1169,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -1197,6 +1205,8 @@ private constructor( CARD -> Value.CARD EXTERNAL_ACH -> Value.EXTERNAL_ACH EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Value.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Value.EXTERNAL_RTP EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Value.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT @@ -1229,6 +1239,8 @@ private constructor( CARD -> Known.CARD EXTERNAL_ACH -> Known.EXTERNAL_ACH EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Known.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Known.EXTERNAL_RTP EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Known.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT @@ -2807,6 +2819,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val secCode: JsonField, + private val achHoldPeriod: JsonField, private val addenda: JsonField, private val companyId: JsonField, private val receiptRoutingNumber: JsonField, @@ -2821,6 +2834,9 @@ private constructor( @JsonProperty("sec_code") @ExcludeMissing secCode: JsonField = JsonMissing.of(), + @JsonProperty("ach_hold_period") + @ExcludeMissing + achHoldPeriod: JsonField = JsonMissing.of(), @JsonProperty("addenda") @ExcludeMissing addenda: JsonField = JsonMissing.of(), @@ -2841,6 +2857,7 @@ private constructor( traceNumbers: JsonField> = JsonMissing.of(), ) : this( secCode, + achHoldPeriod, addenda, companyId, receiptRoutingNumber, @@ -2859,6 +2876,14 @@ private constructor( */ fun secCode(): SecCode = secCode.getRequired("sec_code") + /** + * Number of days the ACH transaction is on hold + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun achHoldPeriod(): Optional = achHoldPeriod.getOptional("ach_hold_period") + /** * Addenda information * @@ -2916,6 +2941,16 @@ private constructor( */ @JsonProperty("sec_code") @ExcludeMissing fun _secCode(): JsonField = secCode + /** + * Returns the raw JSON value of [achHoldPeriod]. + * + * Unlike [achHoldPeriod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ach_hold_period") + @ExcludeMissing + fun _achHoldPeriod(): JsonField = achHoldPeriod + /** * Returns the raw JSON value of [addenda]. * @@ -2999,6 +3034,7 @@ private constructor( class Builder internal constructor() { private var secCode: JsonField? = null + private var achHoldPeriod: JsonField = JsonMissing.of() private var addenda: JsonField = JsonMissing.of() private var companyId: JsonField = JsonMissing.of() private var receiptRoutingNumber: JsonField = JsonMissing.of() @@ -3010,6 +3046,7 @@ private constructor( @JvmSynthetic internal fun from(achMethodAttributes: AchMethodAttributes) = apply { secCode = achMethodAttributes.secCode + achHoldPeriod = achMethodAttributes.achHoldPeriod addenda = achMethodAttributes.addenda companyId = achMethodAttributes.companyId receiptRoutingNumber = achMethodAttributes.receiptRoutingNumber @@ -3031,6 +3068,32 @@ private constructor( */ fun secCode(secCode: JsonField) = apply { this.secCode = secCode } + /** Number of days the ACH transaction is on hold */ + fun achHoldPeriod(achHoldPeriod: Long?) = + achHoldPeriod(JsonField.ofNullable(achHoldPeriod)) + + /** + * Alias for [Builder.achHoldPeriod]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun achHoldPeriod(achHoldPeriod: Long) = achHoldPeriod(achHoldPeriod as Long?) + + /** Alias for calling [Builder.achHoldPeriod] with `achHoldPeriod.orElse(null)`. */ + fun achHoldPeriod(achHoldPeriod: Optional) = + achHoldPeriod(achHoldPeriod.getOrNull()) + + /** + * Sets [Builder.achHoldPeriod] to an arbitrary JSON value. + * + * You should usually call [Builder.achHoldPeriod] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun achHoldPeriod(achHoldPeriod: JsonField) = apply { + this.achHoldPeriod = achHoldPeriod + } + /** Addenda information */ fun addenda(addenda: String?) = addenda(JsonField.ofNullable(addenda)) @@ -3191,6 +3254,7 @@ private constructor( fun build(): AchMethodAttributes = AchMethodAttributes( checkRequired("secCode", secCode), + achHoldPeriod, addenda, companyId, receiptRoutingNumber, @@ -3209,6 +3273,7 @@ private constructor( } secCode().validate() + achHoldPeriod() addenda() companyId() receiptRoutingNumber() @@ -3235,6 +3300,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (secCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (achHoldPeriod.asKnown().isPresent) 1 else 0) + (if (addenda.asKnown().isPresent) 1 else 0) + (if (companyId.asKnown().isPresent) 1 else 0) + (if (receiptRoutingNumber.asKnown().isPresent) 1 else 0) + @@ -3405,6 +3471,7 @@ private constructor( return other is AchMethodAttributes && secCode == other.secCode && + achHoldPeriod == other.achHoldPeriod && addenda == other.addenda && companyId == other.companyId && receiptRoutingNumber == other.receiptRoutingNumber && @@ -3417,6 +3484,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( secCode, + achHoldPeriod, addenda, companyId, receiptRoutingNumber, @@ -3430,7 +3498,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AchMethodAttributes{secCode=$secCode, addenda=$addenda, companyId=$companyId, receiptRoutingNumber=$receiptRoutingNumber, retries=$retries, returnReasonCode=$returnReasonCode, traceNumbers=$traceNumbers, additionalProperties=$additionalProperties}" + "AchMethodAttributes{secCode=$secCode, achHoldPeriod=$achHoldPeriod, addenda=$addenda, companyId=$companyId, receiptRoutingNumber=$receiptRoutingNumber, retries=$retries, returnReasonCode=$returnReasonCode, traceNumbers=$traceNumbers, additionalProperties=$additionalProperties}" } class WireMethodAttributes diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt index fe60370e5..5c7703b56 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentCreateParams.kt @@ -1087,6 +1087,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val secCode: JsonField, + private val achHoldPeriod: JsonField, private val addenda: JsonField, private val additionalProperties: MutableMap, ) { @@ -1096,8 +1097,11 @@ private constructor( @JsonProperty("sec_code") @ExcludeMissing secCode: JsonField = JsonMissing.of(), + @JsonProperty("ach_hold__period") + @ExcludeMissing + achHoldPeriod: JsonField = JsonMissing.of(), @JsonProperty("addenda") @ExcludeMissing addenda: JsonField = JsonMissing.of(), - ) : this(secCode, addenda, mutableMapOf()) + ) : this(secCode, achHoldPeriod, addenda, mutableMapOf()) /** * @throws LithicInvalidDataException if the JSON field has an unexpected type or is @@ -1105,6 +1109,14 @@ private constructor( */ fun secCode(): SecCode = secCode.getRequired("sec_code") + /** + * Number of days to hold the ACH payment + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun achHoldPeriod(): Optional = achHoldPeriod.getOptional("ach_hold__period") + /** * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1118,6 +1130,16 @@ private constructor( */ @JsonProperty("sec_code") @ExcludeMissing fun _secCode(): JsonField = secCode + /** + * Returns the raw JSON value of [achHoldPeriod]. + * + * Unlike [achHoldPeriod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("ach_hold__period") + @ExcludeMissing + fun _achHoldPeriod(): JsonField = achHoldPeriod + /** * Returns the raw JSON value of [addenda]. * @@ -1155,6 +1177,7 @@ private constructor( class Builder internal constructor() { private var secCode: JsonField? = null + private var achHoldPeriod: JsonField = JsonMissing.of() private var addenda: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1162,6 +1185,7 @@ private constructor( internal fun from(paymentMethodRequestAttributes: PaymentMethodRequestAttributes) = apply { secCode = paymentMethodRequestAttributes.secCode + achHoldPeriod = paymentMethodRequestAttributes.achHoldPeriod addenda = paymentMethodRequestAttributes.addenda additionalProperties = paymentMethodRequestAttributes.additionalProperties.toMutableMap() @@ -1178,6 +1202,20 @@ private constructor( */ fun secCode(secCode: JsonField) = apply { this.secCode = secCode } + /** Number of days to hold the ACH payment */ + fun achHoldPeriod(achHoldPeriod: Long) = achHoldPeriod(JsonField.of(achHoldPeriod)) + + /** + * Sets [Builder.achHoldPeriod] to an arbitrary JSON value. + * + * You should usually call [Builder.achHoldPeriod] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun achHoldPeriod(achHoldPeriod: JsonField) = apply { + this.achHoldPeriod = achHoldPeriod + } + fun addenda(addenda: String?) = addenda(JsonField.ofNullable(addenda)) /** Alias for calling [Builder.addenda] with `addenda.orElse(null)`. */ @@ -1226,6 +1264,7 @@ private constructor( fun build(): PaymentMethodRequestAttributes = PaymentMethodRequestAttributes( checkRequired("secCode", secCode), + achHoldPeriod, addenda, additionalProperties.toMutableMap(), ) @@ -1239,6 +1278,7 @@ private constructor( } secCode().validate() + achHoldPeriod() addenda() validated = true } @@ -1260,6 +1300,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (secCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (achHoldPeriod.asKnown().isPresent) 1 else 0) + (if (addenda.asKnown().isPresent) 1 else 0) class SecCode @JsonCreator private constructor(private val value: JsonField) : @@ -1405,16 +1446,19 @@ private constructor( return other is PaymentMethodRequestAttributes && secCode == other.secCode && + achHoldPeriod == other.achHoldPeriod && addenda == other.addenda && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(secCode, addenda, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(secCode, achHoldPeriod, addenda, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "PaymentMethodRequestAttributes{secCode=$secCode, addenda=$addenda, additionalProperties=$additionalProperties}" + "PaymentMethodRequestAttributes{secCode=$secCode, achHoldPeriod=$achHoldPeriod, addenda=$addenda, additionalProperties=$additionalProperties}" } class Type @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/StatementLineItems.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/StatementLineItems.kt index c09ed53ac..e06eb4e36 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/StatementLineItems.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/StatementLineItems.kt @@ -846,6 +846,10 @@ private constructor( @JvmField val EXTERNAL_CHECK = of("EXTERNAL_CHECK") + @JvmField val EXTERNAL_FEDNOW = of("EXTERNAL_FEDNOW") + + @JvmField val EXTERNAL_RTP = of("EXTERNAL_RTP") + @JvmField val EXTERNAL_TRANSFER = of("EXTERNAL_TRANSFER") @JvmField val EXTERNAL_WIRE = of("EXTERNAL_WIRE") @@ -877,6 +881,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -909,6 +915,8 @@ private constructor( CARD, EXTERNAL_ACH, EXTERNAL_CHECK, + EXTERNAL_FEDNOW, + EXTERNAL_RTP, EXTERNAL_TRANSFER, EXTERNAL_WIRE, MANAGEMENT_ADJUSTMENT, @@ -943,6 +951,8 @@ private constructor( CARD -> Value.CARD EXTERNAL_ACH -> Value.EXTERNAL_ACH EXTERNAL_CHECK -> Value.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Value.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Value.EXTERNAL_RTP EXTERNAL_TRANSFER -> Value.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Value.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Value.MANAGEMENT_ADJUSTMENT @@ -975,6 +985,8 @@ private constructor( CARD -> Known.CARD EXTERNAL_ACH -> Known.EXTERNAL_ACH EXTERNAL_CHECK -> Known.EXTERNAL_CHECK + EXTERNAL_FEDNOW -> Known.EXTERNAL_FEDNOW + EXTERNAL_RTP -> Known.EXTERNAL_RTP EXTERNAL_TRANSFER -> Known.EXTERNAL_TRANSFER EXTERNAL_WIRE -> Known.EXTERNAL_WIRE MANAGEMENT_ADJUSTMENT -> Known.MANAGEMENT_ADJUSTMENT @@ -1142,6 +1154,26 @@ private constructor( @JvmField val EXTERNAL_CHECK_SETTLED = of("EXTERNAL_CHECK_SETTLED") + @JvmField val EXTERNAL_FEDNOW_CANCELED = of("EXTERNAL_FEDNOW_CANCELED") + + @JvmField val EXTERNAL_FEDNOW_INITIATED = of("EXTERNAL_FEDNOW_INITIATED") + + @JvmField val EXTERNAL_FEDNOW_RELEASED = of("EXTERNAL_FEDNOW_RELEASED") + + @JvmField val EXTERNAL_FEDNOW_REVERSED = of("EXTERNAL_FEDNOW_REVERSED") + + @JvmField val EXTERNAL_FEDNOW_SETTLED = of("EXTERNAL_FEDNOW_SETTLED") + + @JvmField val EXTERNAL_RTP_CANCELED = of("EXTERNAL_RTP_CANCELED") + + @JvmField val EXTERNAL_RTP_INITIATED = of("EXTERNAL_RTP_INITIATED") + + @JvmField val EXTERNAL_RTP_RELEASED = of("EXTERNAL_RTP_RELEASED") + + @JvmField val EXTERNAL_RTP_REVERSED = of("EXTERNAL_RTP_REVERSED") + + @JvmField val EXTERNAL_RTP_SETTLED = of("EXTERNAL_RTP_SETTLED") + @JvmField val EXTERNAL_TRANSFER_CANCELED = of("EXTERNAL_TRANSFER_CANCELED") @JvmField val EXTERNAL_TRANSFER_INITIATED = of("EXTERNAL_TRANSFER_INITIATED") @@ -1198,6 +1230,18 @@ private constructor( @JvmField val LITHIC_NETWORK_PAYMENT = of("LITHIC_NETWORK_PAYMENT") + @JvmField val ANNUAL = of("ANNUAL") + + @JvmField val ANNUAL_REVERSAL = of("ANNUAL_REVERSAL") + + @JvmField val QUARTERLY = of("QUARTERLY") + + @JvmField val QUARTERLY_REVERSAL = of("QUARTERLY_REVERSAL") + + @JvmField val MONTHLY = of("MONTHLY") + + @JvmField val MONTHLY_REVERSAL = of("MONTHLY_REVERSAL") + @JvmStatic fun of(value: String) = FinancialEventType(JsonField.of(value)) } @@ -1246,6 +1290,16 @@ private constructor( EXTERNAL_CHECK_RELEASED, EXTERNAL_CHECK_REVERSED, EXTERNAL_CHECK_SETTLED, + EXTERNAL_FEDNOW_CANCELED, + EXTERNAL_FEDNOW_INITIATED, + EXTERNAL_FEDNOW_RELEASED, + EXTERNAL_FEDNOW_REVERSED, + EXTERNAL_FEDNOW_SETTLED, + EXTERNAL_RTP_CANCELED, + EXTERNAL_RTP_INITIATED, + EXTERNAL_RTP_RELEASED, + EXTERNAL_RTP_REVERSED, + EXTERNAL_RTP_SETTLED, EXTERNAL_TRANSFER_CANCELED, EXTERNAL_TRANSFER_INITIATED, EXTERNAL_TRANSFER_RELEASED, @@ -1274,6 +1328,12 @@ private constructor( RETURNED_PAYMENT, RETURNED_PAYMENT_REVERSAL, LITHIC_NETWORK_PAYMENT, + ANNUAL, + ANNUAL_REVERSAL, + QUARTERLY, + QUARTERLY_REVERSAL, + MONTHLY, + MONTHLY_REVERSAL, } /** @@ -1331,6 +1391,16 @@ private constructor( EXTERNAL_CHECK_RELEASED, EXTERNAL_CHECK_REVERSED, EXTERNAL_CHECK_SETTLED, + EXTERNAL_FEDNOW_CANCELED, + EXTERNAL_FEDNOW_INITIATED, + EXTERNAL_FEDNOW_RELEASED, + EXTERNAL_FEDNOW_REVERSED, + EXTERNAL_FEDNOW_SETTLED, + EXTERNAL_RTP_CANCELED, + EXTERNAL_RTP_INITIATED, + EXTERNAL_RTP_RELEASED, + EXTERNAL_RTP_REVERSED, + EXTERNAL_RTP_SETTLED, EXTERNAL_TRANSFER_CANCELED, EXTERNAL_TRANSFER_INITIATED, EXTERNAL_TRANSFER_RELEASED, @@ -1359,6 +1429,12 @@ private constructor( RETURNED_PAYMENT, RETURNED_PAYMENT_REVERSAL, LITHIC_NETWORK_PAYMENT, + ANNUAL, + ANNUAL_REVERSAL, + QUARTERLY, + QUARTERLY_REVERSAL, + MONTHLY, + MONTHLY_REVERSAL, /** * An enum member indicating that [FinancialEventType] was instantiated with an * unknown value. @@ -1418,6 +1494,16 @@ private constructor( EXTERNAL_CHECK_RELEASED -> Value.EXTERNAL_CHECK_RELEASED EXTERNAL_CHECK_REVERSED -> Value.EXTERNAL_CHECK_REVERSED EXTERNAL_CHECK_SETTLED -> Value.EXTERNAL_CHECK_SETTLED + EXTERNAL_FEDNOW_CANCELED -> Value.EXTERNAL_FEDNOW_CANCELED + EXTERNAL_FEDNOW_INITIATED -> Value.EXTERNAL_FEDNOW_INITIATED + EXTERNAL_FEDNOW_RELEASED -> Value.EXTERNAL_FEDNOW_RELEASED + EXTERNAL_FEDNOW_REVERSED -> Value.EXTERNAL_FEDNOW_REVERSED + EXTERNAL_FEDNOW_SETTLED -> Value.EXTERNAL_FEDNOW_SETTLED + EXTERNAL_RTP_CANCELED -> Value.EXTERNAL_RTP_CANCELED + EXTERNAL_RTP_INITIATED -> Value.EXTERNAL_RTP_INITIATED + EXTERNAL_RTP_RELEASED -> Value.EXTERNAL_RTP_RELEASED + EXTERNAL_RTP_REVERSED -> Value.EXTERNAL_RTP_REVERSED + EXTERNAL_RTP_SETTLED -> Value.EXTERNAL_RTP_SETTLED EXTERNAL_TRANSFER_CANCELED -> Value.EXTERNAL_TRANSFER_CANCELED EXTERNAL_TRANSFER_INITIATED -> Value.EXTERNAL_TRANSFER_INITIATED EXTERNAL_TRANSFER_RELEASED -> Value.EXTERNAL_TRANSFER_RELEASED @@ -1446,6 +1532,12 @@ private constructor( RETURNED_PAYMENT -> Value.RETURNED_PAYMENT RETURNED_PAYMENT_REVERSAL -> Value.RETURNED_PAYMENT_REVERSAL LITHIC_NETWORK_PAYMENT -> Value.LITHIC_NETWORK_PAYMENT + ANNUAL -> Value.ANNUAL + ANNUAL_REVERSAL -> Value.ANNUAL_REVERSAL + QUARTERLY -> Value.QUARTERLY + QUARTERLY_REVERSAL -> Value.QUARTERLY_REVERSAL + MONTHLY -> Value.MONTHLY + MONTHLY_REVERSAL -> Value.MONTHLY_REVERSAL else -> Value._UNKNOWN } @@ -1503,6 +1595,16 @@ private constructor( EXTERNAL_CHECK_RELEASED -> Known.EXTERNAL_CHECK_RELEASED EXTERNAL_CHECK_REVERSED -> Known.EXTERNAL_CHECK_REVERSED EXTERNAL_CHECK_SETTLED -> Known.EXTERNAL_CHECK_SETTLED + EXTERNAL_FEDNOW_CANCELED -> Known.EXTERNAL_FEDNOW_CANCELED + EXTERNAL_FEDNOW_INITIATED -> Known.EXTERNAL_FEDNOW_INITIATED + EXTERNAL_FEDNOW_RELEASED -> Known.EXTERNAL_FEDNOW_RELEASED + EXTERNAL_FEDNOW_REVERSED -> Known.EXTERNAL_FEDNOW_REVERSED + EXTERNAL_FEDNOW_SETTLED -> Known.EXTERNAL_FEDNOW_SETTLED + EXTERNAL_RTP_CANCELED -> Known.EXTERNAL_RTP_CANCELED + EXTERNAL_RTP_INITIATED -> Known.EXTERNAL_RTP_INITIATED + EXTERNAL_RTP_RELEASED -> Known.EXTERNAL_RTP_RELEASED + EXTERNAL_RTP_REVERSED -> Known.EXTERNAL_RTP_REVERSED + EXTERNAL_RTP_SETTLED -> Known.EXTERNAL_RTP_SETTLED EXTERNAL_TRANSFER_CANCELED -> Known.EXTERNAL_TRANSFER_CANCELED EXTERNAL_TRANSFER_INITIATED -> Known.EXTERNAL_TRANSFER_INITIATED EXTERNAL_TRANSFER_RELEASED -> Known.EXTERNAL_TRANSFER_RELEASED @@ -1531,6 +1633,12 @@ private constructor( RETURNED_PAYMENT -> Known.RETURNED_PAYMENT RETURNED_PAYMENT_REVERSAL -> Known.RETURNED_PAYMENT_REVERSAL LITHIC_NETWORK_PAYMENT -> Known.LITHIC_NETWORK_PAYMENT + ANNUAL -> Known.ANNUAL + ANNUAL_REVERSAL -> Known.ANNUAL_REVERSAL + QUARTERLY -> Known.QUARTERLY + QUARTERLY_REVERSAL -> Known.QUARTERLY_REVERSAL + MONTHLY -> Known.MONTHLY + MONTHLY_REVERSAL -> Known.MONTHLY_REVERSAL else -> throw LithicInvalidDataException("Unknown FinancialEventType: $value") } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt index 82191a81c..9798d1a0c 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityListResponseTest.kt @@ -726,6 +726,7 @@ internal class AccountActivityListResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -800,6 +801,7 @@ internal class AccountActivityListResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt index 5f44839a7..e5066f5d1 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountActivityRetrieveTransactionResponseTest.kt @@ -755,6 +755,7 @@ internal class AccountActivityRetrieveTransactionResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -830,6 +831,7 @@ internal class AccountActivityRetrieveTransactionResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt index 3fc3d9efd..617510a91 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt @@ -16,6 +16,7 @@ internal class AuthRuleV2ListParamsTest { .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .eventStream(AuthRuleV2ListParams.EventStream.AUTHORIZATION) + .addEventStream(AuthRuleV2ListParams.EventStream.AUTHORIZATION) .pageSize(1L) .scope(AuthRuleV2ListParams.Scope.PROGRAM) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -31,6 +32,7 @@ internal class AuthRuleV2ListParamsTest { .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .eventStream(AuthRuleV2ListParams.EventStream.AUTHORIZATION) + .addEventStream(AuthRuleV2ListParams.EventStream.AUTHORIZATION) .pageSize(1L) .scope(AuthRuleV2ListParams.Scope.PROGRAM) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -46,6 +48,7 @@ internal class AuthRuleV2ListParamsTest { .put("card_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .put("event_stream", "AUTHORIZATION") + .put("event_streams", listOf("AUTHORIZATION").joinToString(",")) .put("page_size", "1") .put("scope", "PROGRAM") .put("starting_after", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateParamsTest.kt index d371bbc7c..5538ea9dd 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateParamsTest.kt @@ -17,6 +17,7 @@ internal class PaymentCreateParamsTest { .methodAttributes( PaymentCreateParams.PaymentMethodRequestAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodRequestAttributes.SecCode.CCD) + .achHoldPeriod(0L) .addenda("addenda") .build() ) @@ -38,6 +39,7 @@ internal class PaymentCreateParamsTest { .methodAttributes( PaymentCreateParams.PaymentMethodRequestAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodRequestAttributes.SecCode.CCD) + .achHoldPeriod(0L) .addenda("addenda") .build() ) @@ -58,6 +60,7 @@ internal class PaymentCreateParamsTest { .isEqualTo( PaymentCreateParams.PaymentMethodRequestAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodRequestAttributes.SecCode.CCD) + .achHoldPeriod(0L) .addenda("addenda") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateResponseTest.kt index 371dc40ad..ea472e8e1 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentCreateResponseTest.kt @@ -45,6 +45,7 @@ internal class PaymentCreateResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -120,6 +121,7 @@ internal class PaymentCreateResponseTest { Payment.MethodAttributes.ofAch( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -202,6 +204,7 @@ internal class PaymentCreateResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentListPageResponseTest.kt index 1a5c6ac84..45d44caae 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentListPageResponseTest.kt @@ -51,6 +51,7 @@ internal class PaymentListPageResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -115,6 +116,7 @@ internal class PaymentListPageResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -187,6 +189,7 @@ internal class PaymentListPageResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentRetryResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentRetryResponseTest.kt index 2b8b37ee6..e403de9cd 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentRetryResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentRetryResponseTest.kt @@ -45,6 +45,7 @@ internal class PaymentRetryResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -120,6 +121,7 @@ internal class PaymentRetryResponseTest { Payment.MethodAttributes.ofAch( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -202,6 +204,7 @@ internal class PaymentRetryResponseTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTest.kt index 4bc0c6ddc..52406be1f 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTest.kt @@ -45,6 +45,7 @@ internal class PaymentTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -105,6 +106,7 @@ internal class PaymentTest { Payment.MethodAttributes.ofAch( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) @@ -171,6 +173,7 @@ internal class PaymentTest { .methodAttributes( Payment.MethodAttributes.AchMethodAttributes.builder() .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) .addenda(null) .companyId("1111111111") .receiptRoutingNumber(null) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/PaymentServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/PaymentServiceAsyncTest.kt index 5660d0af9..5d724cdda 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/PaymentServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/PaymentServiceAsyncTest.kt @@ -36,6 +36,7 @@ internal class PaymentServiceAsyncTest { .methodAttributes( PaymentCreateParams.PaymentMethodRequestAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodRequestAttributes.SecCode.CCD) + .achHoldPeriod(0L) .addenda("addenda") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/PaymentServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/PaymentServiceTest.kt index ed661980e..4f8b9f9a1 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/PaymentServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/PaymentServiceTest.kt @@ -36,6 +36,7 @@ internal class PaymentServiceTest { .methodAttributes( PaymentCreateParams.PaymentMethodRequestAttributes.builder() .secCode(PaymentCreateParams.PaymentMethodRequestAttributes.SecCode.CCD) + .achHoldPeriod(0L) .addenda("addenda") .build() ) From a8c67666f0575c873d3f8c0244c1f7747861ba98 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 9 Dec 2025 08:37:09 +0000 Subject: [PATCH 07/12] feat(api): add Google WPP to SDKs docs(api): clarify error 422 for 3DS challenge response feat(api): add IS_AFTER / IS_BEFORE operators to Auth Rule APIs --- .stats.yml | 4 +- .../lithic/api/models/AuthRuleCondition.kt | 4 + .../api/models/CardWebProvisionParams.kt | 288 ++++- .../api/models/CardWebProvisionResponse.kt | 1068 ++++++++++++----- .../models/Conditional3dsActionParameters.kt | 4 + .../models/ConditionalAchActionParameters.kt | 4 + ...onditionalAuthorizationActionParameters.kt | 4 + .../lithic/api/models/ConditionalOperation.kt | 12 + ...ConditionalTokenizationActionParameters.kt | 4 + .../com/lithic/api/models/ConditionalValue.kt | 32 +- .../api/models/CardWebProvisionParamsTest.kt | 9 + .../models/CardWebProvisionResponseTest.kt | 126 +- .../lithic/api/models/ConditionalValueTest.kt | 31 + .../services/async/CardServiceAsyncTest.kt | 3 + .../api/services/blocking/CardServiceTest.kt | 3 + .../api/proguard/ProGuardCompatibilityTest.kt | 176 +-- 16 files changed, 1260 insertions(+), 512 deletions(-) diff --git a/.stats.yml b/.stats.yml index 225dcbad7..f9b501854 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 176 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-3e50857d2b8f4c85922abf83df7b3c6894f5bd500d6226ff589476029bbb258b.yml -openapi_spec_hash: 6bef8b283eb7292ad6f3f62d40fda699 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-abe6a4f82f696099fa8ecb1cc44f08979e17d56578ae7ea68b0e9182e21df508.yml +openapi_spec_hash: d2ce51592a9a234c6f34a1168a31f91f config_hash: ba3fbfc99a1b8635d9e79e9e49d12952 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 ae1e77a4e..36cc454d0 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 @@ -12,6 +12,7 @@ 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 @@ -264,6 +265,9 @@ private constructor( fun valueOfListOfStrings(listOfStrings: List) = value(ConditionalValue.ofListOfStrings(listOfStrings)) + /** Alias for calling [value] with `ConditionalValue.ofTimestamp(timestamp)`. */ + fun value(timestamp: OffsetDateTime) = value(ConditionalValue.ofTimestamp(timestamp)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardWebProvisionParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardWebProvisionParams.kt index c10b2bcad..04df486dc 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardWebProvisionParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardWebProvisionParams.kt @@ -38,6 +38,24 @@ private constructor( fun cardToken(): Optional = Optional.ofNullable(cardToken) + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning device + * identifier required for the tokenization flow + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientDeviceId(): Optional = body.clientDeviceId() + + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning wallet + * account identifier required for the tokenization flow + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientWalletAccountId(): Optional = body.clientWalletAccountId() + /** * Name of digital wallet provider. * @@ -46,6 +64,30 @@ private constructor( */ fun digitalWallet(): Optional = body.digitalWallet() + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning session + * identifier required for the FPAN flow. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serverSessionId(): Optional = body.serverSessionId() + + /** + * Returns the raw JSON value of [clientDeviceId]. + * + * Unlike [clientDeviceId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _clientDeviceId(): JsonField = body._clientDeviceId() + + /** + * Returns the raw JSON value of [clientWalletAccountId]. + * + * Unlike [clientWalletAccountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _clientWalletAccountId(): JsonField = body._clientWalletAccountId() + /** * Returns the raw JSON value of [digitalWallet]. * @@ -53,6 +95,13 @@ private constructor( */ fun _digitalWallet(): JsonField = body._digitalWallet() + /** + * Returns the raw JSON value of [serverSessionId]. + * + * Unlike [serverSessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _serverSessionId(): JsonField = body._serverSessionId() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -97,10 +146,49 @@ private constructor( * * 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: + * - [clientDeviceId] + * - [clientWalletAccountId] * - [digitalWallet] + * - [serverSessionId] */ fun body(body: Body) = apply { this.body = body.toBuilder() } + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * device identifier required for the tokenization flow + */ + fun clientDeviceId(clientDeviceId: String) = apply { body.clientDeviceId(clientDeviceId) } + + /** + * Sets [Builder.clientDeviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.clientDeviceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clientDeviceId(clientDeviceId: JsonField) = apply { + body.clientDeviceId(clientDeviceId) + } + + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * wallet account identifier required for the tokenization flow + */ + fun clientWalletAccountId(clientWalletAccountId: String) = apply { + body.clientWalletAccountId(clientWalletAccountId) + } + + /** + * Sets [Builder.clientWalletAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.clientWalletAccountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clientWalletAccountId(clientWalletAccountId: JsonField) = apply { + body.clientWalletAccountId(clientWalletAccountId) + } + /** Name of digital wallet provider. */ fun digitalWallet(digitalWallet: DigitalWallet) = apply { body.digitalWallet(digitalWallet) @@ -117,6 +205,25 @@ private constructor( body.digitalWallet(digitalWallet) } + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * session identifier required for the FPAN flow. + */ + fun serverSessionId(serverSessionId: String) = apply { + body.serverSessionId(serverSessionId) + } + + /** + * Sets [Builder.serverSessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.serverSessionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serverSessionId(serverSessionId: JsonField) = apply { + body.serverSessionId(serverSessionId) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -263,16 +370,53 @@ private constructor( class Body @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val clientDeviceId: JsonField, + private val clientWalletAccountId: JsonField, private val digitalWallet: JsonField, + private val serverSessionId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( + @JsonProperty("client_device_id") + @ExcludeMissing + clientDeviceId: JsonField = JsonMissing.of(), + @JsonProperty("client_wallet_account_id") + @ExcludeMissing + clientWalletAccountId: JsonField = JsonMissing.of(), @JsonProperty("digital_wallet") @ExcludeMissing - digitalWallet: JsonField = JsonMissing.of() - ) : this(digitalWallet, mutableMapOf()) + digitalWallet: JsonField = JsonMissing.of(), + @JsonProperty("server_session_id") + @ExcludeMissing + serverSessionId: JsonField = JsonMissing.of(), + ) : this( + clientDeviceId, + clientWalletAccountId, + digitalWallet, + serverSessionId, + mutableMapOf(), + ) + + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * device identifier required for the tokenization flow + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientDeviceId(): Optional = clientDeviceId.getOptional("client_device_id") + + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * wallet account identifier required for the tokenization flow + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientWalletAccountId(): Optional = + clientWalletAccountId.getOptional("client_wallet_account_id") /** * Name of digital wallet provider. @@ -282,6 +426,35 @@ private constructor( */ fun digitalWallet(): Optional = digitalWallet.getOptional("digital_wallet") + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * session identifier required for the FPAN flow. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serverSessionId(): Optional = serverSessionId.getOptional("server_session_id") + + /** + * Returns the raw JSON value of [clientDeviceId]. + * + * Unlike [clientDeviceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("client_device_id") + @ExcludeMissing + fun _clientDeviceId(): JsonField = clientDeviceId + + /** + * Returns the raw JSON value of [clientWalletAccountId]. + * + * Unlike [clientWalletAccountId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("client_wallet_account_id") + @ExcludeMissing + fun _clientWalletAccountId(): JsonField = clientWalletAccountId + /** * Returns the raw JSON value of [digitalWallet]. * @@ -292,6 +465,16 @@ private constructor( @ExcludeMissing fun _digitalWallet(): JsonField = digitalWallet + /** + * Returns the raw JSON value of [serverSessionId]. + * + * Unlike [serverSessionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("server_session_id") + @ExcludeMissing + fun _serverSessionId(): JsonField = serverSessionId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -313,15 +496,57 @@ private constructor( /** A builder for [Body]. */ class Builder internal constructor() { + private var clientDeviceId: JsonField = JsonMissing.of() + private var clientWalletAccountId: JsonField = JsonMissing.of() private var digitalWallet: JsonField = JsonMissing.of() + private var serverSessionId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { + clientDeviceId = body.clientDeviceId + clientWalletAccountId = body.clientWalletAccountId digitalWallet = body.digitalWallet + serverSessionId = body.serverSessionId additionalProperties = body.additionalProperties.toMutableMap() } + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * device identifier required for the tokenization flow + */ + fun clientDeviceId(clientDeviceId: String) = + clientDeviceId(JsonField.of(clientDeviceId)) + + /** + * Sets [Builder.clientDeviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.clientDeviceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clientDeviceId(clientDeviceId: JsonField) = apply { + this.clientDeviceId = clientDeviceId + } + + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * wallet account identifier required for the tokenization flow + */ + fun clientWalletAccountId(clientWalletAccountId: String) = + clientWalletAccountId(JsonField.of(clientWalletAccountId)) + + /** + * Sets [Builder.clientWalletAccountId] to an arbitrary JSON value. + * + * You should usually call [Builder.clientWalletAccountId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun clientWalletAccountId(clientWalletAccountId: JsonField) = apply { + this.clientWalletAccountId = clientWalletAccountId + } + /** Name of digital wallet provider. */ fun digitalWallet(digitalWallet: DigitalWallet) = digitalWallet(JsonField.of(digitalWallet)) @@ -337,6 +562,24 @@ private constructor( this.digitalWallet = digitalWallet } + /** + * Only applicable if `digital_wallet` is GOOGLE_PAY. Google Pay Web Push Provisioning + * session identifier required for the FPAN flow. + */ + fun serverSessionId(serverSessionId: String) = + serverSessionId(JsonField.of(serverSessionId)) + + /** + * Sets [Builder.serverSessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.serverSessionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serverSessionId(serverSessionId: JsonField) = apply { + this.serverSessionId = serverSessionId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -361,7 +604,14 @@ private constructor( * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = Body(digitalWallet, additionalProperties.toMutableMap()) + fun build(): Body = + Body( + clientDeviceId, + clientWalletAccountId, + digitalWallet, + serverSessionId, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -371,7 +621,10 @@ private constructor( return@apply } + clientDeviceId() + clientWalletAccountId() digitalWallet().ifPresent { it.validate() } + serverSessionId() validated = true } @@ -390,7 +643,11 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = (digitalWallet.asKnown().getOrNull()?.validity() ?: 0) + internal fun validity(): Int = + (if (clientDeviceId.asKnown().isPresent) 1 else 0) + + (if (clientWalletAccountId.asKnown().isPresent) 1 else 0) + + (digitalWallet.asKnown().getOrNull()?.validity() ?: 0) + + (if (serverSessionId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -398,16 +655,27 @@ private constructor( } return other is Body && + clientDeviceId == other.clientDeviceId && + clientWalletAccountId == other.clientWalletAccountId && digitalWallet == other.digitalWallet && + serverSessionId == other.serverSessionId && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(digitalWallet, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash( + clientDeviceId, + clientWalletAccountId, + digitalWallet, + serverSessionId, + additionalProperties, + ) + } override fun hashCode(): Int = hashCode override fun toString() = - "Body{digitalWallet=$digitalWallet, additionalProperties=$additionalProperties}" + "Body{clientDeviceId=$clientDeviceId, clientWalletAccountId=$clientWalletAccountId, digitalWallet=$digitalWallet, serverSessionId=$serverSessionId, additionalProperties=$additionalProperties}" } /** Name of digital wallet provider. */ @@ -428,12 +696,15 @@ private constructor( @JvmField val APPLE_PAY = of("APPLE_PAY") + @JvmField val GOOGLE_PAY = of("GOOGLE_PAY") + @JvmStatic fun of(value: String) = DigitalWallet(JsonField.of(value)) } /** An enum containing [DigitalWallet]'s known values. */ enum class Known { - APPLE_PAY + APPLE_PAY, + GOOGLE_PAY, } /** @@ -447,6 +718,7 @@ private constructor( */ enum class Value { APPLE_PAY, + GOOGLE_PAY, /** * An enum member indicating that [DigitalWallet] was instantiated with an unknown * value. @@ -464,6 +736,7 @@ private constructor( fun value(): Value = when (this) { APPLE_PAY -> Value.APPLE_PAY + GOOGLE_PAY -> Value.GOOGLE_PAY else -> Value._UNKNOWN } @@ -479,6 +752,7 @@ private constructor( fun known(): Known = when (this) { APPLE_PAY -> Known.APPLE_PAY + GOOGLE_PAY -> Known.GOOGLE_PAY else -> throw LithicInvalidDataException("Unknown DigitalWallet: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardWebProvisionResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardWebProvisionResponse.kt index 62fa55bb6..687d915ae 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardWebProvisionResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardWebProvisionResponse.kt @@ -6,145 +6,63 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer import com.lithic.api.core.ExcludeMissing import com.lithic.api.core.JsonField import com.lithic.api.core.JsonMissing import com.lithic.api.core.JsonValue +import com.lithic.api.core.allMaxBy +import com.lithic.api.core.getOrThrow import com.lithic.api.errors.LithicInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +@JsonDeserialize(using = CardWebProvisionResponse.Deserializer::class) +@JsonSerialize(using = CardWebProvisionResponse.Serializer::class) class CardWebProvisionResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val jws: JsonField, - private val state: JsonField, - private val additionalProperties: MutableMap, + private val appleWebPushProvisioning: AppleWebPushProvisioningResponse? = null, + private val googleWebPushProvisioning: GoogleWebPushProvisioningResponse? = null, + private val _json: JsonValue? = null, ) { - @JsonCreator - private constructor( - @JsonProperty("jws") - @ExcludeMissing - jws: JsonField = JsonMissing.of(), - @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), - ) : this(jws, state, mutableMapOf()) - - /** - * JWS object required for handoff to Apple's script. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun jws(): Optional = jws.getOptional("jws") - - /** - * A unique identifier for the JWS object. - * - * @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") - - /** - * Returns the raw JSON value of [jws]. - * - * Unlike [jws], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("jws") @ExcludeMissing fun _jws(): JsonField = jws - - /** - * Returns the raw JSON value of [state]. - * - * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [CardWebProvisionResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CardWebProvisionResponse]. */ - class Builder internal constructor() { + fun appleWebPushProvisioning(): Optional = + Optional.ofNullable(appleWebPushProvisioning) - private var jws: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(cardWebProvisionResponse: CardWebProvisionResponse) = apply { - jws = cardWebProvisionResponse.jws - state = cardWebProvisionResponse.state - additionalProperties = cardWebProvisionResponse.additionalProperties.toMutableMap() - } - - /** JWS object required for handoff to Apple's script. */ - fun jws(jws: WebPushProvisioningResponseJws) = jws(JsonField.of(jws)) + fun googleWebPushProvisioning(): Optional = + Optional.ofNullable(googleWebPushProvisioning) - /** - * Sets [Builder.jws] to an arbitrary JSON value. - * - * You should usually call [Builder.jws] with a well-typed [WebPushProvisioningResponseJws] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun jws(jws: JsonField) = apply { this.jws = jws } - - /** A unique identifier for the JWS object. */ - fun state(state: String) = state(JsonField.of(state)) - - /** - * Sets [Builder.state] to an arbitrary JSON value. - * - * You should usually call [Builder.state] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun state(state: JsonField) = apply { this.state = state } + fun isAppleWebPushProvisioning(): Boolean = appleWebPushProvisioning != null - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun isGoogleWebPushProvisioning(): Boolean = googleWebPushProvisioning != null - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun asAppleWebPushProvisioning(): AppleWebPushProvisioningResponse = + appleWebPushProvisioning.getOrThrow("appleWebPushProvisioning") - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun asGoogleWebPushProvisioning(): GoogleWebPushProvisioningResponse = + googleWebPushProvisioning.getOrThrow("googleWebPushProvisioning") - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun _json(): Optional = Optional.ofNullable(_json) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun accept(visitor: Visitor): T = + when { + appleWebPushProvisioning != null -> + visitor.visitAppleWebPushProvisioning(appleWebPushProvisioning) + googleWebPushProvisioning != null -> + visitor.visitGoogleWebPushProvisioning(googleWebPushProvisioning) + else -> visitor.unknown(_json) } - /** - * Returns an immutable instance of [CardWebProvisionResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CardWebProvisionResponse = - CardWebProvisionResponse(jws, state, additionalProperties.toMutableMap()) - } - private var validated: Boolean = false fun validate(): CardWebProvisionResponse = apply { @@ -152,8 +70,21 @@ private constructor( return@apply } - jws().ifPresent { it.validate() } - state() + accept( + object : Visitor { + override fun visitAppleWebPushProvisioning( + appleWebPushProvisioning: AppleWebPushProvisioningResponse + ) { + appleWebPushProvisioning.validate() + } + + override fun visitGoogleWebPushProvisioning( + googleWebPushProvisioning: GoogleWebPushProvisioningResponse + ) { + googleWebPushProvisioning.validate() + } + } + ) validated = true } @@ -172,96 +103,187 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (jws.asKnown().getOrNull()?.validity() ?: 0) + (if (state.asKnown().isPresent) 1 else 0) + accept( + object : Visitor { + override fun visitAppleWebPushProvisioning( + appleWebPushProvisioning: AppleWebPushProvisioningResponse + ) = appleWebPushProvisioning.validity() + + override fun visitGoogleWebPushProvisioning( + googleWebPushProvisioning: GoogleWebPushProvisioningResponse + ) = googleWebPushProvisioning.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardWebProvisionResponse && + appleWebPushProvisioning == other.appleWebPushProvisioning && + googleWebPushProvisioning == other.googleWebPushProvisioning + } + + override fun hashCode(): Int = Objects.hash(appleWebPushProvisioning, googleWebPushProvisioning) + + override fun toString(): String = + when { + appleWebPushProvisioning != null -> + "CardWebProvisionResponse{appleWebPushProvisioning=$appleWebPushProvisioning}" + googleWebPushProvisioning != null -> + "CardWebProvisionResponse{googleWebPushProvisioning=$googleWebPushProvisioning}" + _json != null -> "CardWebProvisionResponse{_unknown=$_json}" + else -> throw IllegalStateException("Invalid CardWebProvisionResponse") + } + + companion object { + + @JvmStatic + fun ofAppleWebPushProvisioning(appleWebPushProvisioning: AppleWebPushProvisioningResponse) = + CardWebProvisionResponse(appleWebPushProvisioning = appleWebPushProvisioning) + + @JvmStatic + fun ofGoogleWebPushProvisioning( + googleWebPushProvisioning: GoogleWebPushProvisioningResponse + ) = CardWebProvisionResponse(googleWebPushProvisioning = googleWebPushProvisioning) + } + + /** + * An interface that defines how to map each variant of [CardWebProvisionResponse] to a value of + * type [T]. + */ + interface Visitor { + + fun visitAppleWebPushProvisioning( + appleWebPushProvisioning: AppleWebPushProvisioningResponse + ): T + + fun visitGoogleWebPushProvisioning( + googleWebPushProvisioning: GoogleWebPushProvisioningResponse + ): T - /** JWS object required for handoff to Apple's script. */ - class WebPushProvisioningResponseJws + /** + * Maps an unknown variant of [CardWebProvisionResponse] to a value of type [T]. + * + * An instance of [CardWebProvisionResponse] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown CardWebProvisionResponse: $json") + } + } + + internal class Deserializer : + BaseDeserializer(CardWebProvisionResponse::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): CardWebProvisionResponse { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CardWebProvisionResponse( + appleWebPushProvisioning = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + CardWebProvisionResponse( + googleWebPushProvisioning = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> CardWebProvisionResponse(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(CardWebProvisionResponse::class) { + + override fun serialize( + value: CardWebProvisionResponse, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.appleWebPushProvisioning != null -> + generator.writeObject(value.appleWebPushProvisioning) + value.googleWebPushProvisioning != null -> + generator.writeObject(value.googleWebPushProvisioning) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid CardWebProvisionResponse") + } + } + } + + class AppleWebPushProvisioningResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val header: JsonField, - private val payload: JsonField, - private val protected_: JsonField, - private val signature: JsonField, + private val jws: JsonField, + private val state: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("header") - @ExcludeMissing - header: JsonField = JsonMissing.of(), - @JsonProperty("payload") @ExcludeMissing payload: JsonField = JsonMissing.of(), - @JsonProperty("protected") - @ExcludeMissing - protected_: JsonField = JsonMissing.of(), - @JsonProperty("signature") + @JsonProperty("jws") @ExcludeMissing - signature: JsonField = JsonMissing.of(), - ) : this(header, payload, protected_, signature, mutableMapOf()) - - /** - * JWS unprotected headers containing header parameters that aren't integrity-protected by - * the JWS signature. - * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun header(): Optional = header.getOptional("header") + jws: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + ) : this(jws, state, mutableMapOf()) /** - * Base64url encoded JSON object containing the provisioning payload. + * JWS object required for handoff to Apple's script. * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun payload(): Optional = payload.getOptional("payload") + fun jws(): Optional = jws.getOptional("jws") /** - * Base64url encoded JWS protected headers containing the header parameters that are - * integrity-protected by the JWS signature. + * A unique identifier for the JWS object. * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun protected_(): Optional = protected_.getOptional("protected") + fun state(): Optional = state.getOptional("state") /** - * Base64url encoded signature of the JWS object. + * Returns the raw JSON value of [jws]. * - * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * Unlike [jws], this method doesn't throw if the JSON field has an unexpected type. */ - fun signature(): Optional = signature.getOptional("signature") - - /** - * Returns the raw JSON value of [header]. - * - * Unlike [header], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("header") + @JsonProperty("jws") @ExcludeMissing - fun _header(): JsonField = header - - /** - * Returns the raw JSON value of [payload]. - * - * Unlike [payload], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("payload") @ExcludeMissing fun _payload(): JsonField = payload + fun _jws(): JsonField = jws /** - * Returns the raw JSON value of [protected_]. + * Returns the raw JSON value of [state]. * - * Unlike [protected_], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("protected") @ExcludeMissing fun _protected_(): JsonField = protected_ - - /** - * Returns the raw JSON value of [signature]. - * - * Unlike [signature], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("signature") @ExcludeMissing fun _signature(): JsonField = signature + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -279,86 +301,50 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [WebPushProvisioningResponseJws]. + * [AppleWebPushProvisioningResponse]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [WebPushProvisioningResponseJws]. */ + /** A builder for [AppleWebPushProvisioningResponse]. */ class Builder internal constructor() { - private var header: JsonField = JsonMissing.of() - private var payload: JsonField = JsonMissing.of() - private var protected_: JsonField = JsonMissing.of() - private var signature: JsonField = JsonMissing.of() + private var jws: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(webPushProvisioningResponseJws: WebPushProvisioningResponseJws) = + internal fun from(appleWebPushProvisioningResponse: AppleWebPushProvisioningResponse) = apply { - header = webPushProvisioningResponseJws.header - payload = webPushProvisioningResponseJws.payload - protected_ = webPushProvisioningResponseJws.protected_ - signature = webPushProvisioningResponseJws.signature + jws = appleWebPushProvisioningResponse.jws + state = appleWebPushProvisioningResponse.state additionalProperties = - webPushProvisioningResponseJws.additionalProperties.toMutableMap() + appleWebPushProvisioningResponse.additionalProperties.toMutableMap() } - /** - * JWS unprotected headers containing header parameters that aren't integrity-protected - * by the JWS signature. - */ - fun header(header: WebPushProvisioningResponseHeader) = header(JsonField.of(header)) - - /** - * Sets [Builder.header] to an arbitrary JSON value. - * - * You should usually call [Builder.header] with a well-typed - * [WebPushProvisioningResponseHeader] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun header(header: JsonField) = apply { - this.header = header - } - - /** Base64url encoded JSON object containing the provisioning payload. */ - fun payload(payload: String) = payload(JsonField.of(payload)) - - /** - * Sets [Builder.payload] to an arbitrary JSON value. - * - * You should usually call [Builder.payload] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun payload(payload: JsonField) = apply { this.payload = payload } - - /** - * Base64url encoded JWS protected headers containing the header parameters that are - * integrity-protected by the JWS signature. - */ - fun protected_(protected_: String) = protected_(JsonField.of(protected_)) + /** JWS object required for handoff to Apple's script. */ + fun jws(jws: WebPushProvisioningResponseJws) = jws(JsonField.of(jws)) /** - * Sets [Builder.protected_] to an arbitrary JSON value. + * Sets [Builder.jws] to an arbitrary JSON value. * - * You should usually call [Builder.protected_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.jws] with a well-typed + * [WebPushProvisioningResponseJws] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. */ - fun protected_(protected_: JsonField) = apply { this.protected_ = protected_ } + fun jws(jws: JsonField) = apply { this.jws = jws } - /** Base64url encoded signature of the JWS object. */ - fun signature(signature: String) = signature(JsonField.of(signature)) + /** A unique identifier for the JWS object. */ + fun state(state: String) = state(JsonField.of(state)) /** - * Sets [Builder.signature] to an arbitrary JSON value. + * Sets [Builder.state] to an arbitrary JSON value. * - * You should usually call [Builder.signature] with a well-typed [String] value instead. + * 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 signature(signature: JsonField) = apply { this.signature = signature } + fun state(state: JsonField) = apply { this.state = state } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -380,31 +366,23 @@ private constructor( } /** - * Returns an immutable instance of [WebPushProvisioningResponseJws]. + * Returns an immutable instance of [AppleWebPushProvisioningResponse]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): WebPushProvisioningResponseJws = - WebPushProvisioningResponseJws( - header, - payload, - protected_, - signature, - additionalProperties.toMutableMap(), - ) + fun build(): AppleWebPushProvisioningResponse = + AppleWebPushProvisioningResponse(jws, state, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): WebPushProvisioningResponseJws = apply { + fun validate(): AppleWebPushProvisioningResponse = apply { if (validated) { return@apply } - header().ifPresent { it.validate() } - payload() - protected_() - signature() + jws().ifPresent { it.validate() } + state() validated = true } @@ -424,41 +402,104 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (header.asKnown().getOrNull()?.validity() ?: 0) + - (if (payload.asKnown().isPresent) 1 else 0) + - (if (protected_.asKnown().isPresent) 1 else 0) + - (if (signature.asKnown().isPresent) 1 else 0) + (jws.asKnown().getOrNull()?.validity() ?: 0) + (if (state.asKnown().isPresent) 1 else 0) - /** - * JWS unprotected headers containing header parameters that aren't integrity-protected by - * the JWS signature. - */ - class WebPushProvisioningResponseHeader + /** JWS object required for handoff to Apple's script. */ + class WebPushProvisioningResponseJws @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val kid: JsonField, + private val header: JsonField, + private val payload: JsonField, + private val protected_: JsonField, + private val signature: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("kid") @ExcludeMissing kid: JsonField = JsonMissing.of() - ) : this(kid, mutableMapOf()) + @JsonProperty("header") + @ExcludeMissing + header: JsonField = JsonMissing.of(), + @JsonProperty("payload") + @ExcludeMissing + payload: JsonField = JsonMissing.of(), + @JsonProperty("protected") + @ExcludeMissing + protected_: JsonField = JsonMissing.of(), + @JsonProperty("signature") + @ExcludeMissing + signature: JsonField = JsonMissing.of(), + ) : this(header, payload, protected_, signature, mutableMapOf()) /** - * The ID for the JWS Public Key of the key pair used to generate the signature. + * JWS unprotected headers containing header parameters that aren't integrity-protected + * by the JWS signature. * * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun kid(): Optional = kid.getOptional("kid") + fun header(): Optional = header.getOptional("header") /** - * Returns the raw JSON value of [kid]. + * Base64url encoded JSON object containing the provisioning payload. * - * Unlike [kid], this method doesn't throw if the JSON field has an unexpected type. + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("kid") @ExcludeMissing fun _kid(): JsonField = kid + fun payload(): Optional = payload.getOptional("payload") + + /** + * Base64url encoded JWS protected headers containing the header parameters that are + * integrity-protected by the JWS signature. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun protected_(): Optional = protected_.getOptional("protected") + + /** + * Base64url encoded signature of the JWS object. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun signature(): Optional = signature.getOptional("signature") + + /** + * Returns the raw JSON value of [header]. + * + * Unlike [header], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("header") + @ExcludeMissing + fun _header(): JsonField = header + + /** + * Returns the raw JSON value of [payload]. + * + * Unlike [payload], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payload") @ExcludeMissing fun _payload(): JsonField = payload + + /** + * Returns the raw JSON value of [protected_]. + * + * Unlike [protected_], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("protected") + @ExcludeMissing + fun _protected_(): JsonField = protected_ + + /** + * Returns the raw JSON value of [signature]. + * + * Unlike [signature], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("signature") + @ExcludeMissing + fun _signature(): JsonField = signature @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -476,37 +517,88 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [WebPushProvisioningResponseHeader]. + * [WebPushProvisioningResponseJws]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [WebPushProvisioningResponseHeader]. */ + /** A builder for [WebPushProvisioningResponseJws]. */ class Builder internal constructor() { - private var kid: JsonField = JsonMissing.of() + private var header: JsonField = JsonMissing.of() + private var payload: JsonField = JsonMissing.of() + private var protected_: JsonField = JsonMissing.of() + private var signature: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - webPushProvisioningResponseHeader: WebPushProvisioningResponseHeader - ) = apply { - kid = webPushProvisioningResponseHeader.kid - additionalProperties = - webPushProvisioningResponseHeader.additionalProperties.toMutableMap() + internal fun from(webPushProvisioningResponseJws: WebPushProvisioningResponseJws) = + apply { + header = webPushProvisioningResponseJws.header + payload = webPushProvisioningResponseJws.payload + protected_ = webPushProvisioningResponseJws.protected_ + signature = webPushProvisioningResponseJws.signature + additionalProperties = + webPushProvisioningResponseJws.additionalProperties.toMutableMap() + } + + /** + * JWS unprotected headers containing header parameters that aren't + * integrity-protected by the JWS signature. + */ + fun header(header: WebPushProvisioningResponseHeader) = header(JsonField.of(header)) + + /** + * Sets [Builder.header] to an arbitrary JSON value. + * + * You should usually call [Builder.header] with a well-typed + * [WebPushProvisioningResponseHeader] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun header(header: JsonField) = apply { + this.header = header } - /** The ID for the JWS Public Key of the key pair used to generate the signature. */ - fun kid(kid: String) = kid(JsonField.of(kid)) + /** Base64url encoded JSON object containing the provisioning payload. */ + fun payload(payload: String) = payload(JsonField.of(payload)) + + /** + * Sets [Builder.payload] to an arbitrary JSON value. + * + * You should usually call [Builder.payload] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun payload(payload: JsonField) = apply { this.payload = payload } + + /** + * Base64url encoded JWS protected headers containing the header parameters that are + * integrity-protected by the JWS signature. + */ + fun protected_(protected_: String) = protected_(JsonField.of(protected_)) /** - * Sets [Builder.kid] to an arbitrary JSON value. + * Sets [Builder.protected_] to an arbitrary JSON value. * - * You should usually call [Builder.kid] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.protected_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun kid(kid: JsonField) = apply { this.kid = kid } + fun protected_(protected_: JsonField) = apply { + this.protected_ = protected_ + } + + /** Base64url encoded signature of the JWS object. */ + fun signature(signature: String) = signature(JsonField.of(signature)) + + /** + * Sets [Builder.signature] to an arbitrary JSON value. + * + * You should usually call [Builder.signature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun signature(signature: JsonField) = apply { this.signature = signature } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -531,22 +623,31 @@ private constructor( } /** - * Returns an immutable instance of [WebPushProvisioningResponseHeader]. + * Returns an immutable instance of [WebPushProvisioningResponseJws]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): WebPushProvisioningResponseHeader = - WebPushProvisioningResponseHeader(kid, additionalProperties.toMutableMap()) + fun build(): WebPushProvisioningResponseJws = + WebPushProvisioningResponseJws( + header, + payload, + protected_, + signature, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false - fun validate(): WebPushProvisioningResponseHeader = apply { + fun validate(): WebPushProvisioningResponseJws = apply { if (validated) { return@apply } - kid() + header().ifPresent { it.validate() } + payload() + protected_() + signature() validated = true } @@ -564,24 +665,191 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (kid.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (header.asKnown().getOrNull()?.validity() ?: 0) + + (if (payload.asKnown().isPresent) 1 else 0) + + (if (protected_.asKnown().isPresent) 1 else 0) + + (if (signature.asKnown().isPresent) 1 else 0) + + /** + * JWS unprotected headers containing header parameters that aren't integrity-protected + * by the JWS signature. + */ + class WebPushProvisioningResponseHeader + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val kid: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("kid") @ExcludeMissing kid: JsonField = JsonMissing.of() + ) : this(kid, mutableMapOf()) + + /** + * The ID for the JWS Public Key of the key pair used to generate the signature. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun kid(): Optional = kid.getOptional("kid") + + /** + * Returns the raw JSON value of [kid]. + * + * Unlike [kid], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("kid") @ExcludeMissing fun _kid(): JsonField = kid + + @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 + * [WebPushProvisioningResponseHeader]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebPushProvisioningResponseHeader]. */ + class Builder internal constructor() { + + private var kid: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + webPushProvisioningResponseHeader: WebPushProvisioningResponseHeader + ) = apply { + kid = webPushProvisioningResponseHeader.kid + additionalProperties = + webPushProvisioningResponseHeader.additionalProperties.toMutableMap() + } + + /** + * The ID for the JWS Public Key of the key pair used to generate the signature. + */ + fun kid(kid: String) = kid(JsonField.of(kid)) + + /** + * Sets [Builder.kid] to an arbitrary JSON value. + * + * You should usually call [Builder.kid] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun kid(kid: JsonField) = apply { this.kid = kid } + + 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 [WebPushProvisioningResponseHeader]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebPushProvisioningResponseHeader = + WebPushProvisioningResponseHeader(kid, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): WebPushProvisioningResponseHeader = apply { + if (validated) { + return@apply + } + + kid() + 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 (kid.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebPushProvisioningResponseHeader && + kid == other.kid && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(kid, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebPushProvisioningResponseHeader{kid=$kid, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is WebPushProvisioningResponseHeader && - kid == other.kid && + return other is WebPushProvisioningResponseJws && + header == other.header && + payload == other.payload && + protected_ == other.protected_ && + signature == other.signature && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(kid, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(header, payload, protected_, signature, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "WebPushProvisioningResponseHeader{kid=$kid, additionalProperties=$additionalProperties}" + "WebPushProvisioningResponseJws{header=$header, payload=$payload, protected_=$protected_, signature=$signature, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -589,39 +857,215 @@ private constructor( return true } - return other is WebPushProvisioningResponseJws && - header == other.header && - payload == other.payload && - protected_ == other.protected_ && - signature == other.signature && + return other is AppleWebPushProvisioningResponse && + jws == other.jws && + state == other.state && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(header, payload, protected_, signature, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(jws, state, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "WebPushProvisioningResponseJws{header=$header, payload=$payload, protected_=$protected_, signature=$signature, additionalProperties=$additionalProperties}" + "AppleWebPushProvisioningResponse{jws=$jws, state=$state, additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + class GoogleWebPushProvisioningResponse + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val googleOpc: JsonField, + private val tspOpc: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("google_opc") + @ExcludeMissing + googleOpc: JsonField = JsonMissing.of(), + @JsonProperty("tsp_opc") @ExcludeMissing tspOpc: JsonField = JsonMissing.of(), + ) : this(googleOpc, tspOpc, mutableMapOf()) + + /** + * A base64 encoded and encrypted payload representing card data for the Google Pay UWPP + * FPAN flow. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun googleOpc(): Optional = googleOpc.getOptional("google_opc") + + /** + * A base64 encoded and encrypted payload representing card data for the Google Pay UWPP + * tokenization flow. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tspOpc(): Optional = tspOpc.getOptional("tsp_opc") + + /** + * Returns the raw JSON value of [googleOpc]. + * + * Unlike [googleOpc], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("google_opc") @ExcludeMissing fun _googleOpc(): JsonField = googleOpc + + /** + * Returns the raw JSON value of [tspOpc]. + * + * Unlike [tspOpc], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tsp_opc") @ExcludeMissing fun _tspOpc(): JsonField = tspOpc + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - return other is CardWebProvisionResponse && - jws == other.jws && - state == other.state && - additionalProperties == other.additionalProperties - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [GoogleWebPushProvisioningResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GoogleWebPushProvisioningResponse]. */ + class Builder internal constructor() { + + private var googleOpc: JsonField = JsonMissing.of() + private var tspOpc: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + googleWebPushProvisioningResponse: GoogleWebPushProvisioningResponse + ) = apply { + googleOpc = googleWebPushProvisioningResponse.googleOpc + tspOpc = googleWebPushProvisioningResponse.tspOpc + additionalProperties = + googleWebPushProvisioningResponse.additionalProperties.toMutableMap() + } + + /** + * A base64 encoded and encrypted payload representing card data for the Google Pay UWPP + * FPAN flow. + */ + fun googleOpc(googleOpc: String) = googleOpc(JsonField.of(googleOpc)) + + /** + * Sets [Builder.googleOpc] to an arbitrary JSON value. + * + * You should usually call [Builder.googleOpc] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun googleOpc(googleOpc: JsonField) = apply { this.googleOpc = googleOpc } + + /** + * A base64 encoded and encrypted payload representing card data for the Google Pay UWPP + * tokenization flow. + */ + fun tspOpc(tspOpc: String) = tspOpc(JsonField.of(tspOpc)) + + /** + * Sets [Builder.tspOpc] to an arbitrary JSON value. + * + * You should usually call [Builder.tspOpc] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tspOpc(tspOpc: JsonField) = apply { this.tspOpc = tspOpc } + + 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) + } - private val hashCode: Int by lazy { Objects.hash(jws, state, additionalProperties) } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [GoogleWebPushProvisioningResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): GoogleWebPushProvisioningResponse = + GoogleWebPushProvisioningResponse( + googleOpc, + tspOpc, + additionalProperties.toMutableMap(), + ) + } - override fun hashCode(): Int = hashCode + private var validated: Boolean = false - override fun toString() = - "CardWebProvisionResponse{jws=$jws, state=$state, additionalProperties=$additionalProperties}" + fun validate(): GoogleWebPushProvisioningResponse = apply { + if (validated) { + return@apply + } + + googleOpc() + tspOpc() + 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 (googleOpc.asKnown().isPresent) 1 else 0) + + (if (tspOpc.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is GoogleWebPushProvisioningResponse && + googleOpc == other.googleOpc && + tspOpc == other.tspOpc && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(googleOpc, tspOpc, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GoogleWebPushProvisioningResponse{googleOpc=$googleOpc, tspOpc=$tspOpc, 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 2c6d3e330..dac7a0795 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 @@ -15,6 +15,7 @@ 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 kotlin.jvm.optionals.getOrNull @@ -545,6 +546,9 @@ private constructor( fun valueOfListOfStrings(listOfStrings: List) = value(ConditionalValue.ofListOfStrings(listOfStrings)) + /** Alias for calling [value] with `ConditionalValue.ofTimestamp(timestamp)`. */ + fun value(timestamp: OffsetDateTime) = value(ConditionalValue.ofTimestamp(timestamp)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) 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 4e76f408e..cebf84be6 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 @@ -26,6 +26,7 @@ import com.lithic.api.core.checkRequired import com.lithic.api.core.getOrThrow import com.lithic.api.core.toImmutable import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -1753,6 +1754,9 @@ private constructor( fun valueOfListOfStrings(listOfStrings: List) = value(ConditionalValue.ofListOfStrings(listOfStrings)) + /** Alias for calling [value] with `ConditionalValue.ofTimestamp(timestamp)`. */ + fun value(timestamp: OffsetDateTime) = value(ConditionalValue.ofTimestamp(timestamp)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) 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 bd315b394..183eefd75 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 @@ -15,6 +15,7 @@ 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 kotlin.jvm.optionals.getOrNull @@ -605,6 +606,9 @@ private constructor( fun valueOfListOfStrings(listOfStrings: List) = value(ConditionalValue.ofListOfStrings(listOfStrings)) + /** Alias for calling [value] with `ConditionalValue.ofTimestamp(timestamp)`. */ + fun value(timestamp: OffsetDateTime) = value(ConditionalValue.ofTimestamp(timestamp)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalOperation.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalOperation.kt index 0bfde670d..6acf65f7e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalOperation.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalOperation.kt @@ -42,6 +42,10 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J @JvmField val IS_LESS_THAN_OR_EQUAL_TO = of("IS_LESS_THAN_OR_EQUAL_TO") + @JvmField val IS_AFTER = of("IS_AFTER") + + @JvmField val IS_BEFORE = of("IS_BEFORE") + @JvmField val CONTAINS_ANY = of("CONTAINS_ANY") @JvmField val CONTAINS_ALL = of("CONTAINS_ALL") @@ -63,6 +67,8 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J IS_GREATER_THAN_OR_EQUAL_TO, IS_LESS_THAN, IS_LESS_THAN_OR_EQUAL_TO, + IS_AFTER, + IS_BEFORE, CONTAINS_ANY, CONTAINS_ALL, CONTAINS_NONE, @@ -88,6 +94,8 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J IS_GREATER_THAN_OR_EQUAL_TO, IS_LESS_THAN, IS_LESS_THAN_OR_EQUAL_TO, + IS_AFTER, + IS_BEFORE, CONTAINS_ANY, CONTAINS_ALL, CONTAINS_NONE, @@ -117,6 +125,8 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J IS_GREATER_THAN_OR_EQUAL_TO -> Value.IS_GREATER_THAN_OR_EQUAL_TO IS_LESS_THAN -> Value.IS_LESS_THAN IS_LESS_THAN_OR_EQUAL_TO -> Value.IS_LESS_THAN_OR_EQUAL_TO + IS_AFTER -> Value.IS_AFTER + IS_BEFORE -> Value.IS_BEFORE CONTAINS_ANY -> Value.CONTAINS_ANY CONTAINS_ALL -> Value.CONTAINS_ALL CONTAINS_NONE -> Value.CONTAINS_NONE @@ -143,6 +153,8 @@ class ConditionalOperation @JsonCreator private constructor(private val value: J IS_GREATER_THAN_OR_EQUAL_TO -> Known.IS_GREATER_THAN_OR_EQUAL_TO IS_LESS_THAN -> Known.IS_LESS_THAN IS_LESS_THAN_OR_EQUAL_TO -> Known.IS_LESS_THAN_OR_EQUAL_TO + IS_AFTER -> Known.IS_AFTER + IS_BEFORE -> Known.IS_BEFORE CONTAINS_ANY -> Known.CONTAINS_ANY CONTAINS_ALL -> Known.CONTAINS_ALL CONTAINS_NONE -> Known.CONTAINS_NONE 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 f0f1bdc5a..b7753b123 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 @@ -26,6 +26,7 @@ import com.lithic.api.core.checkRequired import com.lithic.api.core.getOrThrow import com.lithic.api.core.toImmutable import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -1689,6 +1690,9 @@ private constructor( fun valueOfListOfStrings(listOfStrings: List) = value(ConditionalValue.ofListOfStrings(listOfStrings)) + /** Alias for calling [value] with `ConditionalValue.ofTimestamp(timestamp)`. */ + fun value(timestamp: OffsetDateTime) = value(ConditionalValue.ofTimestamp(timestamp)) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) 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 1b8c652d6..37cfcec64 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 @@ -16,6 +16,7 @@ import com.lithic.api.core.allMaxBy import com.lithic.api.core.getOrThrow import com.lithic.api.core.toImmutable import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime import java.util.Objects import java.util.Optional @@ -27,6 +28,7 @@ private constructor( private val regex: String? = null, private val number: Long? = null, private val listOfStrings: List? = null, + private val timestamp: OffsetDateTime? = null, private val _json: JsonValue? = null, ) { @@ -42,12 +44,17 @@ private constructor( /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ fun listOfStrings(): Optional> = Optional.ofNullable(listOfStrings) + /** A timestamp, to be used with `IS_AFTER` or `IS_BEFORE` */ + fun timestamp(): Optional = Optional.ofNullable(timestamp) + fun isRegex(): Boolean = regex != null fun isNumber(): Boolean = number != null fun isListOfStrings(): Boolean = listOfStrings != null + fun isTimestamp(): Boolean = timestamp != null + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ fun asRegex(): String = regex.getOrThrow("regex") @@ -60,6 +67,9 @@ private constructor( /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ fun asListOfStrings(): List = listOfStrings.getOrThrow("listOfStrings") + /** A timestamp, to be used with `IS_AFTER` or `IS_BEFORE` */ + fun asTimestamp(): OffsetDateTime = timestamp.getOrThrow("timestamp") + fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = @@ -67,6 +77,7 @@ private constructor( regex != null -> visitor.visitRegex(regex) number != null -> visitor.visitNumber(number) listOfStrings != null -> visitor.visitListOfStrings(listOfStrings) + timestamp != null -> visitor.visitTimestamp(timestamp) else -> visitor.unknown(_json) } @@ -84,6 +95,8 @@ private constructor( override fun visitNumber(number: Long) {} override fun visitListOfStrings(listOfStrings: List) {} + + override fun visitTimestamp(timestamp: OffsetDateTime) {} } ) validated = true @@ -112,6 +125,8 @@ private constructor( override fun visitListOfStrings(listOfStrings: List) = listOfStrings.size + override fun visitTimestamp(timestamp: OffsetDateTime) = 1 + override fun unknown(json: JsonValue?) = 0 } ) @@ -124,16 +139,18 @@ private constructor( return other is ConditionalValue && regex == other.regex && number == other.number && - listOfStrings == other.listOfStrings + listOfStrings == other.listOfStrings && + timestamp == other.timestamp } - override fun hashCode(): Int = Objects.hash(regex, number, listOfStrings) + override fun hashCode(): Int = Objects.hash(regex, number, listOfStrings, timestamp) override fun toString(): String = when { regex != null -> "ConditionalValue{regex=$regex}" number != null -> "ConditionalValue{number=$number}" listOfStrings != null -> "ConditionalValue{listOfStrings=$listOfStrings}" + timestamp != null -> "ConditionalValue{timestamp=$timestamp}" _json != null -> "ConditionalValue{_unknown=$_json}" else -> throw IllegalStateException("Invalid ConditionalValue") } @@ -153,6 +170,10 @@ private constructor( @JvmStatic fun ofListOfStrings(listOfStrings: List) = ConditionalValue(listOfStrings = listOfStrings.toImmutable()) + + /** A timestamp, to be used with `IS_AFTER` or `IS_BEFORE` */ + @JvmStatic + fun ofTimestamp(timestamp: OffsetDateTime) = ConditionalValue(timestamp = timestamp) } /** @@ -173,6 +194,9 @@ private constructor( /** An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF` */ fun visitListOfStrings(listOfStrings: List): T + /** A timestamp, to be used with `IS_AFTER` or `IS_BEFORE` */ + fun visitTimestamp(timestamp: OffsetDateTime): T + /** * Maps an unknown variant of [ConditionalValue] to a value of type [T]. * @@ -216,6 +240,9 @@ private constructor( } else { null }, + tryDeserialize(node, jacksonTypeRef())?.let { + ConditionalValue(timestamp = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -243,6 +270,7 @@ private constructor( value.regex != null -> generator.writeObject(value.regex) value.number != null -> generator.writeObject(value.number) value.listOfStrings != null -> generator.writeObject(value.listOfStrings) + value.timestamp != null -> generator.writeObject(value.timestamp) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid ConditionalValue") } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardWebProvisionParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardWebProvisionParamsTest.kt index 1968c97a2..808db5834 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardWebProvisionParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardWebProvisionParamsTest.kt @@ -11,7 +11,10 @@ internal class CardWebProvisionParamsTest { fun create() { CardWebProvisionParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientDeviceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientWalletAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .digitalWallet(CardWebProvisionParams.DigitalWallet.APPLE_PAY) + .serverSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @@ -32,12 +35,18 @@ internal class CardWebProvisionParamsTest { val params = CardWebProvisionParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientDeviceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientWalletAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .digitalWallet(CardWebProvisionParams.DigitalWallet.APPLE_PAY) + .serverSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val body = params._body() + assertThat(body.clientDeviceId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(body.clientWalletAccountId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(body.digitalWallet()).contains(CardWebProvisionParams.DigitalWallet.APPLE_PAY) + assertThat(body.serverSessionId()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardWebProvisionResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardWebProvisionResponseTest.kt index 8f60a10a3..f5977c1f5 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardWebProvisionResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardWebProvisionResponseTest.kt @@ -3,20 +3,28 @@ package com.lithic.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue import com.lithic.api.core.jsonMapper +import com.lithic.api.errors.LithicInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class CardWebProvisionResponseTest { @Test - fun create() { - val cardWebProvisionResponse = - CardWebProvisionResponse.builder() + fun ofAppleWebPushProvisioning() { + val appleWebPushProvisioning = + CardWebProvisionResponse.AppleWebPushProvisioningResponse.builder() .jws( - CardWebProvisionResponse.WebPushProvisioningResponseJws.builder() + CardWebProvisionResponse.AppleWebPushProvisioningResponse + .WebPushProvisioningResponseJws + .builder() .header( - CardWebProvisionResponse.WebPushProvisioningResponseJws + CardWebProvisionResponse.AppleWebPushProvisioningResponse + .WebPushProvisioningResponseJws .WebPushProvisioningResponseHeader .builder() .kid("8dc7aed4-29e3-41e4-9cdb-673a05e6615c") @@ -30,46 +38,76 @@ internal class CardWebProvisionResponseTest { .state("3cc4c292-727b-4ca8-b9a8-f96c15485f4e") .build() - assertThat(cardWebProvisionResponse.jws()) - .contains( - CardWebProvisionResponse.WebPushProvisioningResponseJws.builder() - .header( - CardWebProvisionResponse.WebPushProvisioningResponseJws - .WebPushProvisioningResponseHeader + val cardWebProvisionResponse = + CardWebProvisionResponse.ofAppleWebPushProvisioning(appleWebPushProvisioning) + + assertThat(cardWebProvisionResponse.appleWebPushProvisioning()) + .contains(appleWebPushProvisioning) + assertThat(cardWebProvisionResponse.googleWebPushProvisioning()).isEmpty + } + + @Test + fun ofAppleWebPushProvisioningRoundtrip() { + val jsonMapper = jsonMapper() + val cardWebProvisionResponse = + CardWebProvisionResponse.ofAppleWebPushProvisioning( + CardWebProvisionResponse.AppleWebPushProvisioningResponse.builder() + .jws( + CardWebProvisionResponse.AppleWebPushProvisioningResponse + .WebPushProvisioningResponseJws .builder() - .kid("8dc7aed4-29e3-41e4-9cdb-673a05e6615c") + .header( + CardWebProvisionResponse.AppleWebPushProvisioningResponse + .WebPushProvisioningResponseJws + .WebPushProvisioningResponseHeader + .builder() + .kid("8dc7aed4-29e3-41e4-9cdb-673a05e6615c") + .build() + ) + .payload("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9") + .protected_("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9") + .signature("SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c") .build() ) - .payload("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9") - .protected_("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9") - .signature("SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c") + .state("3cc4c292-727b-4ca8-b9a8-f96c15485f4e") .build() ) - assertThat(cardWebProvisionResponse.state()) - .contains("3cc4c292-727b-4ca8-b9a8-f96c15485f4e") + + val roundtrippedCardWebProvisionResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardWebProvisionResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardWebProvisionResponse).isEqualTo(cardWebProvisionResponse) + } + + @Test + fun ofGoogleWebPushProvisioning() { + val googleWebPushProvisioning = + CardWebProvisionResponse.GoogleWebPushProvisioningResponse.builder() + .googleOpc("WW91ciBTdHJpbmcgSGVyZQ==") + .tspOpc("WW91ciBTdHJpbmcgSGVyZQ==") + .build() + + val cardWebProvisionResponse = + CardWebProvisionResponse.ofGoogleWebPushProvisioning(googleWebPushProvisioning) + + assertThat(cardWebProvisionResponse.appleWebPushProvisioning()).isEmpty + assertThat(cardWebProvisionResponse.googleWebPushProvisioning()) + .contains(googleWebPushProvisioning) } @Test - fun roundtrip() { + fun ofGoogleWebPushProvisioningRoundtrip() { val jsonMapper = jsonMapper() val cardWebProvisionResponse = - CardWebProvisionResponse.builder() - .jws( - CardWebProvisionResponse.WebPushProvisioningResponseJws.builder() - .header( - CardWebProvisionResponse.WebPushProvisioningResponseJws - .WebPushProvisioningResponseHeader - .builder() - .kid("8dc7aed4-29e3-41e4-9cdb-673a05e6615c") - .build() - ) - .payload("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9") - .protected_("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9") - .signature("SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c") - .build() - ) - .state("3cc4c292-727b-4ca8-b9a8-f96c15485f4e") - .build() + CardWebProvisionResponse.ofGoogleWebPushProvisioning( + CardWebProvisionResponse.GoogleWebPushProvisioningResponse.builder() + .googleOpc("WW91ciBTdHJpbmcgSGVyZQ==") + .tspOpc("WW91ciBTdHJpbmcgSGVyZQ==") + .build() + ) val roundtrippedCardWebProvisionResponse = jsonMapper.readValue( @@ -79,4 +117,22 @@ internal class CardWebProvisionResponseTest { assertThat(roundtrippedCardWebProvisionResponse).isEqualTo(cardWebProvisionResponse) } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val cardWebProvisionResponse = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { cardWebProvisionResponse.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } 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 098004ffa..2c02b8bd8 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 @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.lithic.api.core.JsonValue import com.lithic.api.core.jsonMapper import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -21,6 +22,7 @@ internal class ConditionalValueTest { assertThat(conditionalValue.regex()).contains(regex) assertThat(conditionalValue.number()).isEmpty assertThat(conditionalValue.listOfStrings()).isEmpty + assertThat(conditionalValue.timestamp()).isEmpty } @Test @@ -46,6 +48,7 @@ internal class ConditionalValueTest { assertThat(conditionalValue.regex()).isEmpty assertThat(conditionalValue.number()).contains(number) assertThat(conditionalValue.listOfStrings()).isEmpty + assertThat(conditionalValue.timestamp()).isEmpty } @Test @@ -71,6 +74,7 @@ internal class ConditionalValueTest { assertThat(conditionalValue.regex()).isEmpty assertThat(conditionalValue.number()).isEmpty assertThat(conditionalValue.listOfStrings()).contains(listOfStrings) + assertThat(conditionalValue.timestamp()).isEmpty } @Test @@ -87,6 +91,33 @@ internal class ConditionalValueTest { assertThat(roundtrippedConditionalValue).isEqualTo(conditionalValue) } + @Test + fun ofTimestamp() { + val timestamp = OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + + val conditionalValue = ConditionalValue.ofTimestamp(timestamp) + + assertThat(conditionalValue.regex()).isEmpty + assertThat(conditionalValue.number()).isEmpty + assertThat(conditionalValue.listOfStrings()).isEmpty + assertThat(conditionalValue.timestamp()).contains(timestamp) + } + + @Test + fun ofTimestampRoundtrip() { + val jsonMapper = jsonMapper() + val conditionalValue = + ConditionalValue.ofTimestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + + val roundtrippedConditionalValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(conditionalValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedConditionalValue).isEqualTo(conditionalValue) + } + @Test fun incompatibleJsonShapeDeserializesToUnknown() { val value = JsonValue.from(mapOf("invalid" to "object")) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt index f0265b2a9..0c172028d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/CardServiceAsyncTest.kt @@ -347,7 +347,10 @@ internal class CardServiceAsyncTest { cardServiceAsync.webProvision( CardWebProvisionParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientDeviceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientWalletAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .digitalWallet(CardWebProvisionParams.DigitalWallet.APPLE_PAY) + .serverSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt index 5d1d2ab0d..133e2da41 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/CardServiceTest.kt @@ -332,7 +332,10 @@ internal class CardServiceTest { cardService.webProvision( CardWebProvisionParams.builder() .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientDeviceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .clientWalletAccountId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .digitalWallet(CardWebProvisionParams.DigitalWallet.APPLE_PAY) + .serverSessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .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 f014312c9..75b13fb98 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 @@ -5,12 +5,9 @@ package com.lithic.api.proguard import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.lithic.api.client.okhttp.LithicOkHttpClient import com.lithic.api.core.jsonMapper -import com.lithic.api.models.AccountHolderUpdateResponse import com.lithic.api.models.CardSpendLimits -import com.lithic.api.models.KybBusinessEntity -import com.lithic.api.models.RequiredDocument +import com.lithic.api.models.CardWebProvisionResponse import com.lithic.api.models.SpendLimitDuration -import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod import org.assertj.core.api.Assertions.assertThat @@ -124,168 +121,39 @@ internal class ProGuardCompatibilityTest { } @Test - fun accountHolderUpdateResponseRoundtrip() { + fun cardWebProvisionResponseRoundtrip() { val jsonMapper = jsonMapper() - val accountHolderUpdateResponse = - AccountHolderUpdateResponse.ofKybKycPatch( - AccountHolderUpdateResponse.KybKycPatchResponse.builder() - .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addBeneficialOwnerEntity( - KybBusinessEntity.builder() - .address( - KybBusinessEntity.Address.builder() - .address1("123 Old Forest Way") - .city("Omaha") - .country("USA") - .postalCode("68022") - .state("NE") - .address2("address2") - .build() - ) - .governmentId("114-123-1513") - .legalBusinessName("Acme, Inc.") - .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") - .parentCompany("parent_company") - .build() - ) - .addBeneficialOwnerIndividual( - AccountHolderUpdateResponse.KybKycPatchResponse.Individual.builder() - .address( - AccountHolderUpdateResponse.KybKycPatchResponse.Individual.Address - .builder() - .address1("123 Old Forest Way") - .city("Omaha") - .country("USA") - .postalCode("68022") - .state("NE") - .address2("address2") - .build() - ) - .dob("1991-03-08 08:00:00") - .email("tom@middle-earth.com") - .firstName("Tom") - .governmentId("111-23-1412") - .lastName("Bombadil") - .phoneNumber("+15555555555") - .build() - ) - .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .businessEntity( - KybBusinessEntity.builder() - .address( - KybBusinessEntity.Address.builder() - .address1("123 Old Forest Way") - .city("Omaha") - .country("USA") - .postalCode("68022") - .state("NE") - .address2("address2") - .build() - ) - .governmentId("114-123-1513") - .legalBusinessName("Acme, Inc.") - .addPhoneNumber("+15555555555") - .dbaBusinessName("dba_business_name") - .parentCompany("parent_company") - .build() - ) - .controlPerson( - AccountHolderUpdateResponse.KybKycPatchResponse.Individual.builder() - .address( - AccountHolderUpdateResponse.KybKycPatchResponse.Individual.Address - .builder() - .address1("123 Old Forest Way") - .city("Omaha") - .country("USA") - .postalCode("68022") - .state("NE") - .address2("address2") - .build() - ) - .dob("1991-03-08 08:00:00") - .email("tom@middle-earth.com") - .firstName("Tom") - .governmentId("111-23-1412") - .lastName("Bombadil") - .phoneNumber("+15555555555") - .build() - ) - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .email("email") - .exemptionType( - AccountHolderUpdateResponse.KybKycPatchResponse.ExemptionType - .AUTHORIZED_USER - ) - .externalId("external_id") - .individual( - AccountHolderUpdateResponse.KybKycPatchResponse.Individual.builder() - .address( - AccountHolderUpdateResponse.KybKycPatchResponse.Individual.Address + val cardWebProvisionResponse = + CardWebProvisionResponse.ofAppleWebPushProvisioning( + CardWebProvisionResponse.AppleWebPushProvisioningResponse.builder() + .jws( + CardWebProvisionResponse.AppleWebPushProvisioningResponse + .WebPushProvisioningResponseJws + .builder() + .header( + CardWebProvisionResponse.AppleWebPushProvisioningResponse + .WebPushProvisioningResponseJws + .WebPushProvisioningResponseHeader .builder() - .address1("123 Old Forest Way") - .city("Omaha") - .country("USA") - .postalCode("68022") - .state("NE") - .address2("address2") + .kid("8dc7aed4-29e3-41e4-9cdb-673a05e6615c") .build() ) - .dob("1991-03-08 08:00:00") - .email("tom@middle-earth.com") - .firstName("Tom") - .governmentId("111-23-1412") - .lastName("Bombadil") - .phoneNumber("+15555555555") - .build() - ) - .natureOfBusiness("nature_of_business") - .phoneNumber("phone_number") - .addRequiredDocument( - RequiredDocument.builder() - .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .addStatusReason("string") - .addValidDocument("string") - .build() - ) - .status(AccountHolderUpdateResponse.KybKycPatchResponse.Status.ACCEPTED) - .addStatusReason( - AccountHolderUpdateResponse.KybKycPatchResponse.StatusReasons - .ADDRESS_VERIFICATION_FAILURE - ) - .userType(AccountHolderUpdateResponse.KybKycPatchResponse.UserType.BUSINESS) - .verificationApplication( - AccountHolderUpdateResponse.KybKycPatchResponse.VerificationApplication - .builder() - .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .status( - AccountHolderUpdateResponse.KybKycPatchResponse - .VerificationApplication - .Status - .ACCEPTED - ) - .addStatusReason( - AccountHolderUpdateResponse.KybKycPatchResponse - .VerificationApplication - .StatusReasons - .ADDRESS_VERIFICATION_FAILURE - ) - .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .kyPassedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .payload("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9") + .protected_("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9") + .signature("SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c") .build() ) - .websiteUrl("website_url") + .state("3cc4c292-727b-4ca8-b9a8-f96c15485f4e") .build() ) - val roundtrippedAccountHolderUpdateResponse = + val roundtrippedCardWebProvisionResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(accountHolderUpdateResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(cardWebProvisionResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedAccountHolderUpdateResponse).isEqualTo(accountHolderUpdateResponse) + assertThat(roundtrippedCardWebProvisionResponse).isEqualTo(cardWebProvisionResponse) } @Test From c6cb6550c60fac0c4e412505e86ecd45a5ca6031 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 9 Dec 2025 09:13:44 +0000 Subject: [PATCH 08/12] feat(api): support event_streams in auth_rules list endpoint --- .stats.yml | 2 +- .../kotlin/com/lithic/api/models/AuthRule.kt | 147 ------ .../api/models/AuthRuleV2CreateParams.kt | 453 ------------------ .../lithic/api/models/AuthRuleV2ListParams.kt | 297 ------------ .../com/lithic/api/models/EventStream.kt | 149 ++++++ .../com/lithic/api/models/AuthRuleTest.kt | 6 +- .../api/models/AuthRuleV2CreateParamsTest.kt | 12 +- .../models/AuthRuleV2ListPageResponseTest.kt | 6 +- .../api/models/AuthRuleV2ListParamsTest.kt | 8 +- .../async/authRules/V2ServiceAsyncTest.kt | 6 +- .../blocking/authRules/V2ServiceTest.kt | 6 +- 11 files changed, 167 insertions(+), 925 deletions(-) create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/EventStream.kt diff --git a/.stats.yml b/.stats.yml index f9b501854..3f808b063 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 176 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-abe6a4f82f696099fa8ecb1cc44f08979e17d56578ae7ea68b0e9182e21df508.yml openapi_spec_hash: d2ce51592a9a234c6f34a1168a31f91f -config_hash: ba3fbfc99a1b8635d9e79e9e49d12952 +config_hash: 739714a3fead0b26ee3a3b7bc51081f6 diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt index ecd866aa2..9d49d6a5a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt @@ -2071,153 +2071,6 @@ private constructor( "DraftVersion{parameters=$parameters, version=$version, additionalProperties=$additionalProperties}" } - /** The event stream during which the rule will be evaluated. */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** The state of the Auth Rule */ class AuthRuleState @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt index df34a0018..5fea81faa 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt @@ -1470,157 +1470,6 @@ private constructor( override fun toString() = value.toString() } - /** The event stream during which the rule will be evaluated. */ - class EventStream - @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2641,157 +2490,6 @@ private constructor( override fun toString() = value.toString() } - /** The event stream during which the rule will be evaluated. */ - class EventStream - @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -3855,157 +3553,6 @@ private constructor( override fun toString() = value.toString() } - /** The event stream during which the rule will be evaluated. */ - class EventStream - @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - LithicInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt index cf1623671..87e83eaec 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListParams.kt @@ -344,303 +344,6 @@ private constructor( } .build() - /** - * Deprecated: Use event_streams instead. Only return Auth rules that are executed during the - * provided event stream. - */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The event stream during which the rule will be evaluated. */ - class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") - - @JvmField val TOKENIZATION = of("TOKENIZATION") - - @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") - - @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") - - @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) - } - - /** An enum containing [EventStream]'s known values. */ - enum class Known { - AUTHORIZATION, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - } - - /** - * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EventStream] 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, - THREE_DS_AUTHENTICATION, - TOKENIZATION, - ACH_CREDIT_RECEIPT, - ACH_DEBIT_RECEIPT, - /** - * An enum member indicating that [EventStream] 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 - THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION - TOKENIZATION -> Value.TOKENIZATION - ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT - 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 - THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION - TOKENIZATION -> Known.TOKENIZATION - ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT - ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT - else -> throw LithicInvalidDataException("Unknown EventStream: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws LithicInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EventStream = 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 EventStream && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** Only return Auth Rules that are bound to the provided scope. */ class Scope @JsonCreator private constructor(private val value: JsonField) : Enum { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventStream.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventStream.kt new file mode 100644 index 000000000..e90c95b9e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventStream.kt @@ -0,0 +1,149 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonCreator +import com.lithic.api.core.Enum +import com.lithic.api.core.JsonField +import com.lithic.api.errors.LithicInvalidDataException + +/** The event stream during which the rule will be evaluated. */ +class EventStream @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 THREE_DS_AUTHENTICATION = of("THREE_DS_AUTHENTICATION") + + @JvmField val TOKENIZATION = of("TOKENIZATION") + + @JvmField val ACH_CREDIT_RECEIPT = of("ACH_CREDIT_RECEIPT") + + @JvmField val ACH_DEBIT_RECEIPT = of("ACH_DEBIT_RECEIPT") + + @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) + } + + /** An enum containing [EventStream]'s known values. */ + enum class Known { + AUTHORIZATION, + THREE_DS_AUTHENTICATION, + TOKENIZATION, + ACH_CREDIT_RECEIPT, + ACH_DEBIT_RECEIPT, + } + + /** + * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventStream] 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, + THREE_DS_AUTHENTICATION, + TOKENIZATION, + ACH_CREDIT_RECEIPT, + ACH_DEBIT_RECEIPT, + /** An enum member indicating that [EventStream] 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 + THREE_DS_AUTHENTICATION -> Value.THREE_DS_AUTHENTICATION + TOKENIZATION -> Value.TOKENIZATION + ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT + ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT + 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 + THREE_DS_AUTHENTICATION -> Known.THREE_DS_AUTHENTICATION + TOKENIZATION -> Known.TOKENIZATION + ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT + ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT + else -> throw LithicInvalidDataException("Unknown EventStream: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): EventStream = 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 EventStream && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt index 7f4ebe4c8..16f779742 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt @@ -50,7 +50,7 @@ internal class AuthRuleTest { .version(0L) .build() ) - .eventStream(AuthRule.EventStream.AUTHORIZATION) + .eventStream(EventStream.AUTHORIZATION) .lithicManaged(true) .name("name") .programLevel(true) @@ -98,7 +98,7 @@ internal class AuthRuleTest { .version(0L) .build() ) - assertThat(authRule.eventStream()).isEqualTo(AuthRule.EventStream.AUTHORIZATION) + assertThat(authRule.eventStream()).isEqualTo(EventStream.AUTHORIZATION) assertThat(authRule.lithicManaged()).isEqualTo(true) assertThat(authRule.name()).contains("name") assertThat(authRule.programLevel()).isEqualTo(true) @@ -149,7 +149,7 @@ internal class AuthRuleTest { .version(0L) .build() ) - .eventStream(AuthRule.EventStream.AUTHORIZATION) + .eventStream(EventStream.AUTHORIZATION) .lithicManaged(true) .name("name") .programLevel(true) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2CreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2CreateParamsTest.kt index e3e275794..e77bb674d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2CreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2CreateParamsTest.kt @@ -28,9 +28,7 @@ internal class AuthRuleV2CreateParamsTest { ) .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .eventStream( - AuthRuleV2CreateParams.Body.AccountLevelRule.EventStream.AUTHORIZATION - ) + .eventStream(EventStream.AUTHORIZATION) .name("name") .build() ) @@ -60,9 +58,7 @@ internal class AuthRuleV2CreateParamsTest { ) .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .eventStream( - AuthRuleV2CreateParams.Body.AccountLevelRule.EventStream.AUTHORIZATION - ) + .eventStream(EventStream.AUTHORIZATION) .name("name") .build() ) @@ -91,9 +87,7 @@ internal class AuthRuleV2CreateParamsTest { ) .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .eventStream( - AuthRuleV2CreateParams.Body.AccountLevelRule.EventStream.AUTHORIZATION - ) + .eventStream(EventStream.AUTHORIZATION) .name("name") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponseTest.kt index 1dcc5f02e..9ccbb5475 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListPageResponseTest.kt @@ -51,7 +51,7 @@ internal class AuthRuleV2ListPageResponseTest { .version(0L) .build() ) - .eventStream(AuthRule.EventStream.AUTHORIZATION) + .eventStream(EventStream.AUTHORIZATION) .lithicManaged(true) .name("name") .programLevel(true) @@ -102,7 +102,7 @@ internal class AuthRuleV2ListPageResponseTest { .version(0L) .build() ) - .eventStream(AuthRule.EventStream.AUTHORIZATION) + .eventStream(EventStream.AUTHORIZATION) .lithicManaged(true) .name("name") .programLevel(true) @@ -157,7 +157,7 @@ internal class AuthRuleV2ListPageResponseTest { .version(0L) .build() ) - .eventStream(AuthRule.EventStream.AUTHORIZATION) + .eventStream(EventStream.AUTHORIZATION) .lithicManaged(true) .name("name") .programLevel(true) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt index 617510a91..f0e9dcc2d 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2ListParamsTest.kt @@ -15,8 +15,8 @@ internal class AuthRuleV2ListParamsTest { .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .eventStream(AuthRuleV2ListParams.EventStream.AUTHORIZATION) - .addEventStream(AuthRuleV2ListParams.EventStream.AUTHORIZATION) + .eventStream(EventStream.AUTHORIZATION) + .addEventStream(EventStream.AUTHORIZATION) .pageSize(1L) .scope(AuthRuleV2ListParams.Scope.PROGRAM) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -31,8 +31,8 @@ internal class AuthRuleV2ListParamsTest { .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .eventStream(AuthRuleV2ListParams.EventStream.AUTHORIZATION) - .addEventStream(AuthRuleV2ListParams.EventStream.AUTHORIZATION) + .eventStream(EventStream.AUTHORIZATION) + .addEventStream(EventStream.AUTHORIZATION) .pageSize(1L) .scope(AuthRuleV2ListParams.Scope.PROGRAM) .startingAfter("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncTest.kt index 29e232658..59bfc5eef 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncTest.kt @@ -13,6 +13,7 @@ import com.lithic.api.models.AuthRuleV2UpdateParams import com.lithic.api.models.ConditionalAttribute import com.lithic.api.models.ConditionalBlockParameters import com.lithic.api.models.ConditionalOperation +import com.lithic.api.models.EventStream import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -51,10 +52,7 @@ internal class V2ServiceAsyncTest { ) .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .eventStream( - AuthRuleV2CreateParams.Body.AccountLevelRule.EventStream - .AUTHORIZATION - ) + .eventStream(EventStream.AUTHORIZATION) .name("name") .build() ) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt index 81f9e8c97..7ec49bf47 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceTest.kt @@ -13,6 +13,7 @@ import com.lithic.api.models.AuthRuleV2UpdateParams import com.lithic.api.models.ConditionalAttribute import com.lithic.api.models.ConditionalBlockParameters import com.lithic.api.models.ConditionalOperation +import com.lithic.api.models.EventStream import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -51,10 +52,7 @@ internal class V2ServiceTest { ) .addAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addBusinessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .eventStream( - AuthRuleV2CreateParams.Body.AccountLevelRule.EventStream - .AUTHORIZATION - ) + .eventStream(EventStream.AUTHORIZATION) .name("name") .build() ) From 1bac5f34b5826b4d5e11f601a4347377e0e46722 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 22:09:26 +0000 Subject: [PATCH 09/12] feat(api): add webhook schemas to SDKs - add parse and parse_unsafe chore: replace custom webhook signature verification with standardwebhooks From 08fd3715052ba80f9df989fea7530c28ee55fbaf Mon Sep 17 00:00:00 2001 From: Mirek Klimos Date: Thu, 11 Dec 2025 09:48:12 +0100 Subject: [PATCH 10/12] fix: fix auth rule conditional value parsing --- .../com/lithic/api/models/ConditionalValue.kt | 30 +++++++++---------- .../api/proguard/ProGuardCompatibilityTest.kt | 1 + 2 files changed, 15 insertions(+), 16 deletions(-) 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 37cfcec64..228c85045 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 @@ -219,30 +219,28 @@ private constructor( val bestMatches = sequenceOf( - if (node.isTextual) { - tryDeserialize(node, jacksonTypeRef())?.let { - ConditionalValue(regex = it, _json = json) - } - } else { - null - }, if (node.isNumber) { tryDeserialize(node, jacksonTypeRef())?.let { ConditionalValue(number = it, _json = json) } - } else { - null - }, + } else null, if (node.isArray) { tryDeserialize(node, jacksonTypeRef>())?.let { ConditionalValue(listOfStrings = it, _json = json) } - } else { - null - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ConditionalValue(timestamp = it, _json = json) - }, + } else null, + // Try timestamp before generic string, since timestamps serialize as + // strings + if (node.isTextual) { + tryDeserialize(node, jacksonTypeRef())?.let { + ConditionalValue(timestamp = it, _json = json) + } + } else null, + if (node.isTextual) { + tryDeserialize(node, jacksonTypeRef())?.let { + ConditionalValue(regex = it, _json = json) + } + } else null, ) .filterNotNull() .allMaxBy { it.validity() } 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 75b13fb98..24dc0a8db 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 @@ -81,6 +81,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.fraud()).isNotNull() assertThat(client.networkPrograms()).isNotNull() assertThat(client.accountActivity()).isNotNull() + assertThat(client.webhooks()).isNotNull() } @Test From 3c51183f40c0bf1caaf325d6b4a192a8f9417278 Mon Sep 17 00:00:00 2001 From: Mirek Klimos Date: Thu, 11 Dec 2025 10:16:55 +0100 Subject: [PATCH 11/12] feat(api): add parse/parseUnsafe webhook helpers and event schemas --- README.md | 47 +- .../com/lithic/api/client/LithicClient.kt | 6 +- .../lithic/api/client/LithicClientAsync.kt | 6 +- .../api/client/LithicClientAsyncImpl.kt | 16 +- .../com/lithic/api/client/LithicClientImpl.kt | 14 +- .../AccountHolderCreatedWebhookEvent.kt | 706 + ...ccountHolderDocumentUpdatedWebhookEvent.kt | 1590 +++ .../AccountHolderUpdatedWebhookEvent.kt | 4118 ++++++ .../AccountHolderVerificationWebhookEvent.kt | 649 + .../api/models/AsaRequestWebhookEvent.kt | 7316 ++++++++++ ...hRulesBacktestReportCreatedWebhookEvent.kt | 441 + .../api/models/BalanceUpdatedWebhookEvent.kt | 356 + ...kTransferTransactionCreatedWebhookEvent.kt | 1080 ++ ...kTransferTransactionUpdatedWebhookEvent.kt | 1080 ++ .../api/models/CardConvertedWebhookEvent.kt | 339 + .../api/models/CardCreatedWebhookEvent.kt | 388 + .../api/models/CardReissuedWebhookEvent.kt | 338 + .../api/models/CardRenewedWebhookEvent.kt | 509 + .../api/models/CardShippedWebhookEvent.kt | 677 + ...nsactionEnhancedDataCreatedWebhookEvent.kt | 540 + ...nsactionEnhancedDataUpdatedWebhookEvent.kt | 540 + .../CardTransactionUpdatedWebhookEvent.kt | 1626 +++ ...TokenizationApprovalRequestWebhookEvent.kt | 1887 +++ ...talWalletTokenizationResultWebhookEvent.kt | 1267 ++ ...actorAuthenticationCodeSentWebhookEvent.kt | 888 ++ ...TwoFactorAuthenticationCodeWebhookEvent.kt | 932 ++ ...alWalletTokenizationUpdatedWebhookEvent.kt | 477 + ...DisputeEvidenceUploadFailedWebhookEvent.kt | 627 + .../DisputeTransactionCreatedWebhookEvent.kt | 951 ++ .../DisputeTransactionUpdatedWebhookEvent.kt | 951 ++ .../api/models/DisputeUpdatedWebhookEvent.kt | 1300 ++ .../ExternalBankAccountCreatedWebhookEvent.kt | 1331 ++ .../ExternalBankAccountUpdatedWebhookEvent.kt | 1331 ++ .../ExternalPaymentCreatedWebhookEvent.kt | 921 ++ .../ExternalPaymentUpdatedWebhookEvent.kt | 921 ++ .../FinancialAccountCreatedWebhookEvent.kt | 853 ++ .../FinancialAccountUpdatedWebhookEvent.kt | 853 ++ .../models/FundingEventCreatedWebhookEvent.kt | 730 + .../InternalTransactionCreatedWebhookEvent.kt | 782 ++ .../InternalTransactionUpdatedWebhookEvent.kt | 782 ++ .../api/models/LoanTapeCreatedWebhookEvent.kt | 1290 ++ .../api/models/LoanTapeUpdatedWebhookEvent.kt | 1290 ++ .../ManagementOperationCreatedWebhookEvent.kt | 1042 ++ .../ManagementOperationUpdatedWebhookEvent.kt | 1042 ++ .../models/NetworkTotalCreatedWebhookEvent.kt | 849 ++ .../models/NetworkTotalUpdatedWebhookEvent.kt | 849 ++ .../lithic/api/models/ParsedWebhookEvent.kt | 6407 +++++++++ .../PaymentTransactionCreatedWebhookEvent.kt | 1339 ++ .../PaymentTransactionUpdatedWebhookEvent.kt | 1339 ++ .../SettlementReportUpdatedWebhookEvent.kt | 887 ++ .../models/StatementsCreatedWebhookEvent.kt | 1324 ++ ...eeDSAuthenticationChallengeWebhookEvent.kt | 839 ++ ...hreeDSAuthenticationCreatedWebhookEvent.kt | 1410 ++ ...hreeDSAuthenticationUpdatedWebhookEvent.kt | 1410 ++ ...TokenizationApprovalRequestWebhookEvent.kt | 1876 +++ ...enizationDecisioningRequestWebhookEvent.kt | 1189 ++ .../models/TokenizationResultWebhookEvent.kt | 1263 ++ ...actorAuthenticationCodeSentWebhookEvent.kt | 882 ++ ...TwoFactorAuthenticationCodeWebhookEvent.kt | 928 ++ .../models/TokenizationUpdatedWebhookEvent.kt | 474 + .../api/services/async/WebhookServiceAsync.kt | 45 + .../services/async/WebhookServiceAsyncImpl.kt | 98 +- .../api/services/blocking/WebhookService.kt | 41 + .../services/blocking/WebhookServiceImpl.kt | 53 +- .../AccountHolderCreatedWebhookEventTest.kt | 84 + ...ntHolderDocumentUpdatedWebhookEventTest.kt | 130 + .../AccountHolderUpdatedWebhookEventTest.kt | 417 + ...countHolderVerificationWebhookEventTest.kt | 66 + .../api/models/AsaRequestWebhookEventTest.kt | 487 + ...esBacktestReportCreatedWebhookEventTest.kt | 185 + .../models/BalanceUpdatedWebhookEventTest.kt | 83 + ...nsferTransactionCreatedWebhookEventTest.kt | 195 + ...nsferTransactionUpdatedWebhookEventTest.kt | 195 + .../models/CardConvertedWebhookEventTest.kt | 43 + .../api/models/CardCreatedWebhookEventTest.kt | 47 + .../models/CardReissuedWebhookEventTest.kt | 43 + .../api/models/CardRenewedWebhookEventTest.kt | 55 + .../api/models/CardShippedWebhookEventTest.kt | 58 + ...tionEnhancedDataCreatedWebhookEventTest.kt | 207 + ...tionEnhancedDataUpdatedWebhookEventTest.kt | 207 + .../CardTransactionUpdatedWebhookEventTest.kt | 684 + ...nizationApprovalRequestWebhookEventTest.kt | 302 + ...alletTokenizationResultWebhookEventTest.kt | 148 + ...rAuthenticationCodeSentWebhookEventTest.kt | 118 + ...actorAuthenticationCodeWebhookEventTest.kt | 118 + ...lletTokenizationUpdatedWebhookEventTest.kt | 182 + ...uteEvidenceUploadFailedWebhookEventTest.kt | 72 + ...sputeTransactionCreatedWebhookEventTest.kt | 218 + ...sputeTransactionUpdatedWebhookEventTest.kt | 218 + .../models/DisputeUpdatedWebhookEventTest.kt | 107 + ...ernalBankAccountCreatedWebhookEventTest.kt | 156 + ...ernalBankAccountUpdatedWebhookEventTest.kt | 156 + .../ExternalPaymentCreatedWebhookEventTest.kt | 143 + .../ExternalPaymentUpdatedWebhookEventTest.kt | 143 + ...FinancialAccountCreatedWebhookEventTest.kt | 127 + ...FinancialAccountUpdatedWebhookEventTest.kt | 127 + .../FundingEventCreatedWebhookEventTest.kt | 89 + ...ernalTransactionCreatedWebhookEventTest.kt | 115 + ...ernalTransactionUpdatedWebhookEventTest.kt | 115 + .../models/LoanTapeCreatedWebhookEventTest.kt | 458 + .../models/LoanTapeUpdatedWebhookEventTest.kt | 458 + ...agementOperationCreatedWebhookEventTest.kt | 214 + ...agementOperationUpdatedWebhookEventTest.kt | 214 + .../NetworkTotalCreatedWebhookEventTest.kt | 105 + .../NetworkTotalUpdatedWebhookEventTest.kt | 105 + .../api/models/ParsedWebhookEventTest.kt | 11067 ++++++++++++++++ ...ymentTransactionCreatedWebhookEventTest.kt | 231 + ...ymentTransactionUpdatedWebhookEventTest.kt | 231 + ...SettlementReportUpdatedWebhookEventTest.kt | 110 + .../StatementsCreatedWebhookEventTest.kt | 395 + ...AuthenticationChallengeWebhookEventTest.kt | 535 + ...DSAuthenticationCreatedWebhookEventTest.kt | 463 + ...DSAuthenticationUpdatedWebhookEventTest.kt | 463 + ...nizationApprovalRequestWebhookEventTest.kt | 264 + ...ationDecisioningRequestWebhookEventTest.kt | 203 + .../TokenizationResultWebhookEventTest.kt | 139 + ...rAuthenticationCodeSentWebhookEventTest.kt | 101 + ...actorAuthenticationCodeWebhookEventTest.kt | 100 + .../TokenizationUpdatedWebhookEventTest.kt | 173 + .../services/blocking/WebhookServiceTest.kt | 129 +- 120 files changed, 90238 insertions(+), 92 deletions(-) create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderDocumentUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderVerificationWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/AsaRequestWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRulesBacktestReportCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferTransactionCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferTransactionUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardConvertedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardReissuedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardRenewedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardShippedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionEnhancedDataCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionEnhancedDataUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationApprovalRequestWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationResultWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeEvidenceUploadFailedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeTransactionCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeTransactionUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransactionCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransactionUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/LoanTapeCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/LoanTapeUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ParsedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentTransactionCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentTransactionUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/SettlementReportUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/StatementsCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationChallengeWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationCreatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationApprovalRequestWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationDecisioningRequestWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationResultWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeWebhookEvent.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdatedWebhookEvent.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderDocumentUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderVerificationWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/AsaRequestWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRulesBacktestReportCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/BalanceUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferTransactionCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferTransactionUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardConvertedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardReissuedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardRenewedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardShippedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionEnhancedDataCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionEnhancedDataUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationApprovalRequestWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationResultWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeEvidenceUploadFailedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeTransactionCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeTransactionUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/LoanTapeCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/LoanTapeUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ParsedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTransactionCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTransactionUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementReportUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/StatementsCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationChallengeWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationCreatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationUpdatedWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationApprovalRequestWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationDecisioningRequestWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationResultWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeSentWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeWebhookEventTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdatedWebhookEventTest.kt diff --git a/README.md b/README.md index 9e682cdc3..cc8099d2f 100644 --- a/README.md +++ b/README.md @@ -354,15 +354,50 @@ Or to `debug` for more verbose logging: export LITHIC_LOG=debug ``` -## Webhook Verification +## Webhooks -We provide helper methods for verifying that a webhook request came from Lithic, and not a malicious third party. +Lithic uses webhooks to notify your application when events happen. The SDK provides methods for verifying webhook signatures and parsing event payloads. -You can use `lithic.webhooks().verifySignature(body, headers, secret?)` or `lithic.webhooks().unwrap(body, headers, secret?)`, -both of which will raise an error if the signature is invalid. +### Parsing and verifying webhooks -Note that the "body" parameter must be the raw JSON string sent from the server (do not parse it first). -The `.unwrap()` method can parse this JSON for you. +Use `parse()` to verify the signature and return a typed event: + +```java +import com.lithic.api.core.http.Headers; +import com.lithic.api.models.ParsedWebhookEvent; + +// Convert request headers to Headers object +Headers headers = Headers.builder().putAll(request.getHeaders()).build(); + +// Verify signature and parse payload +// Secret is optional if configured on client or set via LITHIC_WEBHOOK_SECRET env var +ParsedWebhookEvent event = client.webhooks().parse(requestBody, headers, null); + +// Handle based on event type using isXxx() checks +if (event.isCardCreated()) { + System.out.println("Card created: " + event.asCardCreated().cardToken()); +} else if (event.isCardTransactionUpdated()) { + String transactionToken = event.asCardTransactionUpdated().token(); + System.out.println("Transaction updated: " + transactionToken); +} + +``` + +### Parsing without verification +You can parse the webhook body without verifying the signature using `parseUnsafe()`. This is not recommended for production use: + +``` +// Parse only - skips signature verification (not recommended for production) +ParsedWebhookEvent event = client.webhooks().parseUnsafe(body); +``` + +### Manual signature verification +To verify the signature without parsing the body, use `verifySignature()`: + +``` +// Only verify signature, don't parse. Throws LithicException if signature is invalid +client.webhooks().verifySignature(body, headers, null); +``` ## ProGuard and R8 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 9b537b39a..eb7b7ff11 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 @@ -113,8 +113,6 @@ interface LithicClient { fun responderEndpoints(): ResponderEndpointService - fun webhooks(): WebhookService - fun externalBankAccounts(): ExternalBankAccountService fun payments(): PaymentService @@ -145,6 +143,8 @@ interface LithicClient { fun accountActivity(): AccountActivityService + fun webhooks(): WebhookService + /** Status of api */ fun apiStatus(): ApiStatus = apiStatus(ClientApiStatusParams.none()) @@ -249,6 +249,8 @@ interface LithicClient { fun accountActivity(): AccountActivityService.WithRawResponse + fun webhooks(): WebhookService.WithRawResponse + /** * Returns a raw HTTP response for `get /v1/status`, but is otherwise the same as * [LithicClient.apiStatus]. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsync.kt index ca0f3cbf3..982132d5b 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 @@ -113,8 +113,6 @@ interface LithicClientAsync { fun responderEndpoints(): ResponderEndpointServiceAsync - fun webhooks(): WebhookServiceAsync - fun externalBankAccounts(): ExternalBankAccountServiceAsync fun payments(): PaymentServiceAsync @@ -145,6 +143,8 @@ interface LithicClientAsync { fun accountActivity(): AccountActivityServiceAsync + fun webhooks(): WebhookServiceAsync + /** Status of api */ fun apiStatus(): CompletableFuture = apiStatus(ClientApiStatusParams.none()) @@ -252,6 +252,8 @@ interface LithicClientAsync { fun accountActivity(): AccountActivityServiceAsync.WithRawResponse + fun webhooks(): WebhookServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /v1/status`, but is otherwise the same as * [LithicClientAsync.apiStatus]. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientAsyncImpl.kt index be7664e6c..b757af652 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 @@ -169,8 +169,6 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl ResponderEndpointServiceAsyncImpl(clientOptionsWithUserAgent) } - private val webhooks: WebhookServiceAsync by lazy { WebhookServiceAsyncImpl(clientOptions) } - private val externalBankAccounts: ExternalBankAccountServiceAsync by lazy { ExternalBankAccountServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -231,6 +229,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl AccountActivityServiceAsyncImpl(clientOptionsWithUserAgent) } + private val webhooks: WebhookServiceAsync by lazy { + WebhookServiceAsyncImpl(clientOptionsWithUserAgent) + } + override fun sync(): LithicClient = sync override fun withRawResponse(): LithicClientAsync.WithRawResponse = withRawResponse @@ -273,8 +275,6 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun responderEndpoints(): ResponderEndpointServiceAsync = responderEndpoints - override fun webhooks(): WebhookServiceAsync = webhooks - override fun externalBankAccounts(): ExternalBankAccountServiceAsync = externalBankAccounts override fun payments(): PaymentServiceAsync = payments @@ -305,6 +305,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun accountActivity(): AccountActivityServiceAsync = accountActivity + override fun webhooks(): WebhookServiceAsync = webhooks + override fun apiStatus( params: ClientApiStatusParams, requestOptions: RequestOptions, @@ -449,6 +451,10 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl AccountActivityServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val webhooks: WebhookServiceAsync.WithRawResponse by lazy { + WebhookServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): LithicClientAsync.WithRawResponse = @@ -530,6 +536,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl override fun accountActivity(): AccountActivityServiceAsync.WithRawResponse = accountActivity + override fun webhooks(): WebhookServiceAsync.WithRawResponse = webhooks + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/client/LithicClientImpl.kt index 24ac9408c..eb652dd00 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 @@ -160,8 +160,6 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient ResponderEndpointServiceImpl(clientOptionsWithUserAgent) } - private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptions) } - private val externalBankAccounts: ExternalBankAccountService by lazy { ExternalBankAccountServiceImpl(clientOptionsWithUserAgent) } @@ -214,6 +212,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient AccountActivityServiceImpl(clientOptionsWithUserAgent) } + private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) } + override fun async(): LithicClientAsync = async override fun withRawResponse(): LithicClient.WithRawResponse = withRawResponse @@ -255,8 +255,6 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun responderEndpoints(): ResponderEndpointService = responderEndpoints - override fun webhooks(): WebhookService = webhooks - override fun externalBankAccounts(): ExternalBankAccountService = externalBankAccounts override fun payments(): PaymentService = payments @@ -287,6 +285,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun accountActivity(): AccountActivityService = accountActivity + override fun webhooks(): WebhookService = webhooks + override fun apiStatus( params: ClientApiStatusParams, requestOptions: RequestOptions, @@ -431,6 +431,10 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient AccountActivityServiceImpl.WithRawResponseImpl(clientOptions) } + private val webhooks: WebhookService.WithRawResponse by lazy { + WebhookServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): LithicClient.WithRawResponse = @@ -510,6 +514,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient override fun accountActivity(): AccountActivityService.WithRawResponse = accountActivity + override fun webhooks(): WebhookService.WithRawResponse = webhooks + private val apiStatusHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreatedWebhookEvent.kt new file mode 100644 index 000000000..b36c267e8 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderCreatedWebhookEvent.kt @@ -0,0 +1,706 @@ +// 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 + +class AccountHolderCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val eventType: JsonField, + private val token: JsonField, + private val accountToken: JsonField, + private val created: JsonField, + private val requiredDocuments: JsonField>, + private val status: JsonField, + private val statusReason: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("required_documents") + @ExcludeMissing + requiredDocuments: JsonField> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("status_reason") + @ExcludeMissing + statusReason: JsonField> = JsonMissing.of(), + ) : this( + eventType, + token, + accountToken, + created, + requiredDocuments, + status, + statusReason, + mutableMapOf(), + ) + + /** + * 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") + + /** + * The token of the account_holder that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * The token of the account that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * When the account_holder was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun requiredDocuments(): Optional> = + requiredDocuments.getOptional("required_documents") + + /** + * The status of the account_holder that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusReason(): Optional> = statusReason.getOptional("status_reason") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [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 [requiredDocuments]. + * + * Unlike [requiredDocuments], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("required_documents") + @ExcludeMissing + fun _requiredDocuments(): JsonField> = requiredDocuments + + /** + * 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 [statusReason]. + * + * Unlike [statusReason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status_reason") + @ExcludeMissing + fun _statusReason(): JsonField> = statusReason + + @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 + * [AccountHolderCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountHolderCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var eventType: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var accountToken: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var requiredDocuments: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var statusReason: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accountHolderCreatedWebhookEvent: AccountHolderCreatedWebhookEvent) = + apply { + eventType = accountHolderCreatedWebhookEvent.eventType + token = accountHolderCreatedWebhookEvent.token + accountToken = accountHolderCreatedWebhookEvent.accountToken + created = accountHolderCreatedWebhookEvent.created + requiredDocuments = + accountHolderCreatedWebhookEvent.requiredDocuments.map { it.toMutableList() } + status = accountHolderCreatedWebhookEvent.status + statusReason = + accountHolderCreatedWebhookEvent.statusReason.map { it.toMutableList() } + additionalProperties = + accountHolderCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** 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 } + + /** The token of the account_holder that was created. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The token of the account that was created. */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** When the account_holder was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun requiredDocuments(requiredDocuments: List) = + requiredDocuments(JsonField.of(requiredDocuments)) + + /** + * Sets [Builder.requiredDocuments] to an arbitrary JSON value. + * + * You should usually call [Builder.requiredDocuments] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun requiredDocuments(requiredDocuments: JsonField>) = apply { + this.requiredDocuments = requiredDocuments.map { it.toMutableList() } + } + + /** + * Adds a single [RequiredDocument] to [requiredDocuments]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRequiredDocument(requiredDocument: RequiredDocument) = apply { + requiredDocuments = + (requiredDocuments ?: JsonField.of(mutableListOf())).also { + checkKnown("requiredDocuments", it).add(requiredDocument) + } + } + + /** The status of the account_holder that was created. */ + 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 } + + fun statusReason(statusReason: List) = statusReason(JsonField.of(statusReason)) + + /** + * Sets [Builder.statusReason] to an arbitrary JSON value. + * + * You should usually call [Builder.statusReason] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusReason(statusReason: JsonField>) = apply { + this.statusReason = statusReason.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [Builder.statusReason]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStatusReason(statusReason: String) = apply { + this.statusReason = + (this.statusReason ?: JsonField.of(mutableListOf())).also { + checkKnown("statusReason", it).add(statusReason) + } + } + + 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 [AccountHolderCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccountHolderCreatedWebhookEvent = + AccountHolderCreatedWebhookEvent( + checkRequired("eventType", eventType), + token, + accountToken, + created, + (requiredDocuments ?: JsonMissing.of()).map { it.toImmutable() }, + status, + (statusReason ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccountHolderCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + eventType().validate() + token() + accountToken() + created() + requiredDocuments().ifPresent { it.forEach { it.validate() } } + status().ifPresent { it.validate() } + statusReason() + 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 = + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (requiredDocuments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (statusReason.asKnown().getOrNull()?.size ?: 0) + + /** 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 ACCOUNT_HOLDER_CREATED = of("account_holder.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_CREATED + } + + /** + * 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 { + ACCOUNT_HOLDER_CREATED, + /** + * 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) { + ACCOUNT_HOLDER_CREATED -> Value.ACCOUNT_HOLDER_CREATED + 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) { + ACCOUNT_HOLDER_CREATED -> Known.ACCOUNT_HOLDER_CREATED + 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 + + 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() + } + + /** The status of the account_holder that was created. */ + 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 ACCEPTED = of("ACCEPTED") + + @JvmField val PENDING_REVIEW = of("PENDING_REVIEW") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACCEPTED, + PENDING_REVIEW, + } + + /** + * 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 { + ACCEPTED, + PENDING_REVIEW, + /** 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) { + ACCEPTED -> Value.ACCEPTED + PENDING_REVIEW -> Value.PENDING_REVIEW + 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) { + ACCEPTED -> Known.ACCEPTED + PENDING_REVIEW -> Known.PENDING_REVIEW + else -> throw LithicInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return 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 AccountHolderCreatedWebhookEvent && + eventType == other.eventType && + token == other.token && + accountToken == other.accountToken && + created == other.created && + requiredDocuments == other.requiredDocuments && + status == other.status && + statusReason == other.statusReason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + eventType, + token, + accountToken, + created, + requiredDocuments, + status, + statusReason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccountHolderCreatedWebhookEvent{eventType=$eventType, token=$token, accountToken=$accountToken, created=$created, requiredDocuments=$requiredDocuments, status=$status, statusReason=$statusReason, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderDocumentUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderDocumentUpdatedWebhookEvent.kt new file mode 100644 index 000000000..cdde246aa --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderDocumentUpdatedWebhookEvent.kt @@ -0,0 +1,1590 @@ +// 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 + +class AccountHolderDocumentUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val eventType: JsonField, + private val token: JsonField, + private val accountHolderToken: JsonField, + private val created: JsonField, + private val documentType: JsonField, + private val entityToken: JsonField, + private val requiredDocumentUploads: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_holder_token") + @ExcludeMissing + accountHolderToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("document_type") + @ExcludeMissing + documentType: JsonField = JsonMissing.of(), + @JsonProperty("entity_token") + @ExcludeMissing + entityToken: JsonField = JsonMissing.of(), + @JsonProperty("required_document_uploads") + @ExcludeMissing + requiredDocumentUploads: JsonField> = JsonMissing.of(), + ) : this( + eventType, + token, + accountHolderToken, + created, + documentType, + entityToken, + requiredDocumentUploads, + mutableMapOf(), + ) + + /** + * 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") + + /** + * The token of the account holder document + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * The token of the account_holder that the document belongs to + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountHolderToken(): Optional = + accountHolderToken.getOptional("account_holder_token") + + /** + * When the account_holder was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") + + /** + * Type of documentation to be submitted for verification of an account holder + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun documentType(): Optional = documentType.getOptional("document_type") + + /** + * The token of the entity that the document belongs to + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun entityToken(): Optional = entityToken.getOptional("entity_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun requiredDocumentUploads(): Optional> = + requiredDocumentUploads.getOptional("required_document_uploads") + + /** + * 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 [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 [accountHolderToken]. + * + * Unlike [accountHolderToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_holder_token") + @ExcludeMissing + fun _accountHolderToken(): JsonField = accountHolderToken + + /** + * 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 [documentType]. + * + * Unlike [documentType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("document_type") + @ExcludeMissing + fun _documentType(): JsonField = documentType + + /** + * Returns the raw JSON value of [entityToken]. + * + * Unlike [entityToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("entity_token") + @ExcludeMissing + fun _entityToken(): JsonField = entityToken + + /** + * Returns the raw JSON value of [requiredDocumentUploads]. + * + * Unlike [requiredDocumentUploads], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("required_document_uploads") + @ExcludeMissing + fun _requiredDocumentUploads(): JsonField> = + requiredDocumentUploads + + @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 + * [AccountHolderDocumentUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountHolderDocumentUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var eventType: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var accountHolderToken: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var documentType: JsonField = JsonMissing.of() + private var entityToken: JsonField = JsonMissing.of() + private var requiredDocumentUploads: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + accountHolderDocumentUpdatedWebhookEvent: AccountHolderDocumentUpdatedWebhookEvent + ) = apply { + eventType = accountHolderDocumentUpdatedWebhookEvent.eventType + token = accountHolderDocumentUpdatedWebhookEvent.token + accountHolderToken = accountHolderDocumentUpdatedWebhookEvent.accountHolderToken + created = accountHolderDocumentUpdatedWebhookEvent.created + documentType = accountHolderDocumentUpdatedWebhookEvent.documentType + entityToken = accountHolderDocumentUpdatedWebhookEvent.entityToken + requiredDocumentUploads = + accountHolderDocumentUpdatedWebhookEvent.requiredDocumentUploads.map { + it.toMutableList() + } + additionalProperties = + accountHolderDocumentUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** 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 } + + /** The token of the account holder document */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The token of the account_holder that the document belongs to */ + fun accountHolderToken(accountHolderToken: String) = + accountHolderToken(JsonField.of(accountHolderToken)) + + /** + * Sets [Builder.accountHolderToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountHolderToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun accountHolderToken(accountHolderToken: JsonField) = apply { + this.accountHolderToken = accountHolderToken + } + + /** When the account_holder was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Type of documentation to be submitted for verification of an account holder */ + fun documentType(documentType: DocumentType) = documentType(JsonField.of(documentType)) + + /** + * Sets [Builder.documentType] to an arbitrary JSON value. + * + * You should usually call [Builder.documentType] with a well-typed [DocumentType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun documentType(documentType: JsonField) = apply { + this.documentType = documentType + } + + /** The token of the entity that the document belongs to */ + fun entityToken(entityToken: String) = entityToken(JsonField.of(entityToken)) + + /** + * Sets [Builder.entityToken] to an arbitrary JSON value. + * + * You should usually call [Builder.entityToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun entityToken(entityToken: JsonField) = apply { this.entityToken = entityToken } + + fun requiredDocumentUploads(requiredDocumentUploads: List) = + requiredDocumentUploads(JsonField.of(requiredDocumentUploads)) + + /** + * Sets [Builder.requiredDocumentUploads] to an arbitrary JSON value. + * + * You should usually call [Builder.requiredDocumentUploads] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun requiredDocumentUploads( + requiredDocumentUploads: JsonField> + ) = apply { + this.requiredDocumentUploads = requiredDocumentUploads.map { it.toMutableList() } + } + + /** + * Adds a single [RequiredDocumentUpload] to [requiredDocumentUploads]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRequiredDocumentUpload(requiredDocumentUpload: RequiredDocumentUpload) = apply { + requiredDocumentUploads = + (requiredDocumentUploads ?: JsonField.of(mutableListOf())).also { + checkKnown("requiredDocumentUploads", it).add(requiredDocumentUpload) + } + } + + 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 [AccountHolderDocumentUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccountHolderDocumentUpdatedWebhookEvent = + AccountHolderDocumentUpdatedWebhookEvent( + checkRequired("eventType", eventType), + token, + accountHolderToken, + created, + documentType, + entityToken, + (requiredDocumentUploads ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccountHolderDocumentUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + eventType().validate() + token() + accountHolderToken() + created() + documentType().ifPresent { it.validate() } + entityToken() + requiredDocumentUploads().ifPresent { it.forEach { 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 = + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (token.asKnown().isPresent) 1 else 0) + + (if (accountHolderToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (documentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (entityToken.asKnown().isPresent) 1 else 0) + + (requiredDocumentUploads.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** 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 ACCOUNT_HOLDER_DOCUMENT_UPDATED = of("account_holder_document.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_DOCUMENT_UPDATED + } + + /** + * 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 { + ACCOUNT_HOLDER_DOCUMENT_UPDATED, + /** + * 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) { + ACCOUNT_HOLDER_DOCUMENT_UPDATED -> Value.ACCOUNT_HOLDER_DOCUMENT_UPDATED + 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) { + ACCOUNT_HOLDER_DOCUMENT_UPDATED -> Known.ACCOUNT_HOLDER_DOCUMENT_UPDATED + 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 + + 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() + } + + /** Type of documentation to be submitted for verification of an account holder */ + class DocumentType @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 DRIVERS_LICENSE = of("DRIVERS_LICENSE") + + @JvmField val PASSPORT = of("PASSPORT") + + @JvmField val PASSPORT_CARD = of("PASSPORT_CARD") + + @JvmField val EIN_LETTER = of("EIN_LETTER") + + @JvmField val TAX_RETURN = of("TAX_RETURN") + + @JvmField val OPERATING_AGREEMENT = of("OPERATING_AGREEMENT") + + @JvmField val CERTIFICATE_OF_FORMATION = of("CERTIFICATE_OF_FORMATION") + + @JvmField val CERTIFICATE_OF_GOOD_STANDING = of("CERTIFICATE_OF_GOOD_STANDING") + + @JvmField val ARTICLES_OF_INCORPORATION = of("ARTICLES_OF_INCORPORATION") + + @JvmField val ARTICLES_OF_ORGANIZATION = of("ARTICLES_OF_ORGANIZATION") + + @JvmField val BYLAWS = of("BYLAWS") + + @JvmField val GOVERNMENT_BUSINESS_LICENSE = of("GOVERNMENT_BUSINESS_LICENSE") + + @JvmField val PARTNERSHIP_AGREEMENT = of("PARTNERSHIP_AGREEMENT") + + @JvmField val SS4_FORM = of("SS4_FORM") + + @JvmField val BANK_STATEMENT = of("BANK_STATEMENT") + + @JvmField val UTILITY_BILL_STATEMENT = of("UTILITY_BILL_STATEMENT") + + @JvmField val SSN_CARD = of("SSN_CARD") + + @JvmField val ITIN_LETTER = of("ITIN_LETTER") + + @JvmField val FINCEN_BOI_REPORT = of("FINCEN_BOI_REPORT") + + @JvmStatic fun of(value: String) = DocumentType(JsonField.of(value)) + } + + /** An enum containing [DocumentType]'s known values. */ + enum class Known { + DRIVERS_LICENSE, + PASSPORT, + PASSPORT_CARD, + EIN_LETTER, + TAX_RETURN, + OPERATING_AGREEMENT, + CERTIFICATE_OF_FORMATION, + CERTIFICATE_OF_GOOD_STANDING, + ARTICLES_OF_INCORPORATION, + ARTICLES_OF_ORGANIZATION, + BYLAWS, + GOVERNMENT_BUSINESS_LICENSE, + PARTNERSHIP_AGREEMENT, + SS4_FORM, + BANK_STATEMENT, + UTILITY_BILL_STATEMENT, + SSN_CARD, + ITIN_LETTER, + FINCEN_BOI_REPORT, + } + + /** + * An enum containing [DocumentType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DocumentType] 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 { + DRIVERS_LICENSE, + PASSPORT, + PASSPORT_CARD, + EIN_LETTER, + TAX_RETURN, + OPERATING_AGREEMENT, + CERTIFICATE_OF_FORMATION, + CERTIFICATE_OF_GOOD_STANDING, + ARTICLES_OF_INCORPORATION, + ARTICLES_OF_ORGANIZATION, + BYLAWS, + GOVERNMENT_BUSINESS_LICENSE, + PARTNERSHIP_AGREEMENT, + SS4_FORM, + BANK_STATEMENT, + UTILITY_BILL_STATEMENT, + SSN_CARD, + ITIN_LETTER, + FINCEN_BOI_REPORT, + /** + * An enum member indicating that [DocumentType] 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) { + DRIVERS_LICENSE -> Value.DRIVERS_LICENSE + PASSPORT -> Value.PASSPORT + PASSPORT_CARD -> Value.PASSPORT_CARD + EIN_LETTER -> Value.EIN_LETTER + TAX_RETURN -> Value.TAX_RETURN + OPERATING_AGREEMENT -> Value.OPERATING_AGREEMENT + CERTIFICATE_OF_FORMATION -> Value.CERTIFICATE_OF_FORMATION + CERTIFICATE_OF_GOOD_STANDING -> Value.CERTIFICATE_OF_GOOD_STANDING + ARTICLES_OF_INCORPORATION -> Value.ARTICLES_OF_INCORPORATION + ARTICLES_OF_ORGANIZATION -> Value.ARTICLES_OF_ORGANIZATION + BYLAWS -> Value.BYLAWS + GOVERNMENT_BUSINESS_LICENSE -> Value.GOVERNMENT_BUSINESS_LICENSE + PARTNERSHIP_AGREEMENT -> Value.PARTNERSHIP_AGREEMENT + SS4_FORM -> Value.SS4_FORM + BANK_STATEMENT -> Value.BANK_STATEMENT + UTILITY_BILL_STATEMENT -> Value.UTILITY_BILL_STATEMENT + SSN_CARD -> Value.SSN_CARD + ITIN_LETTER -> Value.ITIN_LETTER + FINCEN_BOI_REPORT -> Value.FINCEN_BOI_REPORT + 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) { + DRIVERS_LICENSE -> Known.DRIVERS_LICENSE + PASSPORT -> Known.PASSPORT + PASSPORT_CARD -> Known.PASSPORT_CARD + EIN_LETTER -> Known.EIN_LETTER + TAX_RETURN -> Known.TAX_RETURN + OPERATING_AGREEMENT -> Known.OPERATING_AGREEMENT + CERTIFICATE_OF_FORMATION -> Known.CERTIFICATE_OF_FORMATION + CERTIFICATE_OF_GOOD_STANDING -> Known.CERTIFICATE_OF_GOOD_STANDING + ARTICLES_OF_INCORPORATION -> Known.ARTICLES_OF_INCORPORATION + ARTICLES_OF_ORGANIZATION -> Known.ARTICLES_OF_ORGANIZATION + BYLAWS -> Known.BYLAWS + GOVERNMENT_BUSINESS_LICENSE -> Known.GOVERNMENT_BUSINESS_LICENSE + PARTNERSHIP_AGREEMENT -> Known.PARTNERSHIP_AGREEMENT + SS4_FORM -> Known.SS4_FORM + BANK_STATEMENT -> Known.BANK_STATEMENT + UTILITY_BILL_STATEMENT -> Known.UTILITY_BILL_STATEMENT + SSN_CARD -> Known.SSN_CARD + ITIN_LETTER -> Known.ITIN_LETTER + FINCEN_BOI_REPORT -> Known.FINCEN_BOI_REPORT + else -> throw LithicInvalidDataException("Unknown DocumentType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): DocumentType = 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 DocumentType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** A document upload that belongs to the overall account holder document */ + class RequiredDocumentUpload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val acceptedEntityStatusReasons: JsonField>, + private val created: JsonField, + private val imageType: JsonField, + private val rejectedEntityStatusReasons: JsonField>, + private val status: JsonField, + private val statusReasons: JsonField>, + private val updated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("accepted_entity_status_reasons") + @ExcludeMissing + acceptedEntityStatusReasons: JsonField> = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("image_type") + @ExcludeMissing + imageType: JsonField = JsonMissing.of(), + @JsonProperty("rejected_entity_status_reasons") + @ExcludeMissing + rejectedEntityStatusReasons: JsonField> = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("status_reasons") + @ExcludeMissing + statusReasons: JsonField> = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + ) : this( + token, + acceptedEntityStatusReasons, + created, + imageType, + rejectedEntityStatusReasons, + status, + statusReasons, + updated, + mutableMapOf(), + ) + + /** + * The token of the document upload + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun acceptedEntityStatusReasons(): Optional> = + acceptedEntityStatusReasons.getOptional("accepted_entity_status_reasons") + + /** + * When the document upload was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") + + /** + * The type of image that was uploaded + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun imageType(): Optional = imageType.getOptional("image_type") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rejectedEntityStatusReasons(): Optional> = + rejectedEntityStatusReasons.getOptional("rejected_entity_status_reasons") + + /** + * The status of the document upload + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusReasons(): Optional> = statusReasons.getOptional("status_reasons") + + /** + * When the document upload was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updated(): Optional = updated.getOptional("updated") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [acceptedEntityStatusReasons]. + * + * Unlike [acceptedEntityStatusReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("accepted_entity_status_reasons") + @ExcludeMissing + fun _acceptedEntityStatusReasons(): JsonField> = acceptedEntityStatusReasons + + /** + * 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 [imageType]. + * + * Unlike [imageType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("image_type") + @ExcludeMissing + fun _imageType(): JsonField = imageType + + /** + * Returns the raw JSON value of [rejectedEntityStatusReasons]. + * + * Unlike [rejectedEntityStatusReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("rejected_entity_status_reasons") + @ExcludeMissing + fun _rejectedEntityStatusReasons(): JsonField> = rejectedEntityStatusReasons + + /** + * 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 [statusReasons]. + * + * Unlike [statusReasons], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RequiredDocumentUpload]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RequiredDocumentUpload]. */ + class Builder internal constructor() { + + private var token: JsonField = JsonMissing.of() + private var acceptedEntityStatusReasons: JsonField>? = null + private var created: JsonField = JsonMissing.of() + private var imageType: JsonField = JsonMissing.of() + private var rejectedEntityStatusReasons: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var statusReasons: JsonField>? = null + private var updated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(requiredDocumentUpload: RequiredDocumentUpload) = apply { + token = requiredDocumentUpload.token + acceptedEntityStatusReasons = + requiredDocumentUpload.acceptedEntityStatusReasons.map { it.toMutableList() } + created = requiredDocumentUpload.created + imageType = requiredDocumentUpload.imageType + rejectedEntityStatusReasons = + requiredDocumentUpload.rejectedEntityStatusReasons.map { it.toMutableList() } + status = requiredDocumentUpload.status + statusReasons = requiredDocumentUpload.statusReasons.map { it.toMutableList() } + updated = requiredDocumentUpload.updated + additionalProperties = requiredDocumentUpload.additionalProperties.toMutableMap() + } + + /** The token of the document upload */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: List) = + acceptedEntityStatusReasons(JsonField.of(acceptedEntityStatusReasons)) + + /** + * Sets [Builder.acceptedEntityStatusReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedEntityStatusReasons] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun acceptedEntityStatusReasons(acceptedEntityStatusReasons: JsonField>) = + apply { + this.acceptedEntityStatusReasons = + acceptedEntityStatusReasons.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [acceptedEntityStatusReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAcceptedEntityStatusReason(acceptedEntityStatusReason: String) = apply { + acceptedEntityStatusReasons = + (acceptedEntityStatusReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("acceptedEntityStatusReasons", it) + .add(acceptedEntityStatusReason) + } + } + + /** When the document upload was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** The type of image that was uploaded */ + fun imageType(imageType: ImageType) = imageType(JsonField.of(imageType)) + + /** + * Sets [Builder.imageType] to an arbitrary JSON value. + * + * You should usually call [Builder.imageType] with a well-typed [ImageType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun imageType(imageType: JsonField) = apply { this.imageType = imageType } + + fun rejectedEntityStatusReasons(rejectedEntityStatusReasons: List) = + rejectedEntityStatusReasons(JsonField.of(rejectedEntityStatusReasons)) + + /** + * Sets [Builder.rejectedEntityStatusReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.rejectedEntityStatusReasons] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun rejectedEntityStatusReasons(rejectedEntityStatusReasons: JsonField>) = + apply { + this.rejectedEntityStatusReasons = + rejectedEntityStatusReasons.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [rejectedEntityStatusReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRejectedEntityStatusReason(rejectedEntityStatusReason: String) = apply { + rejectedEntityStatusReasons = + (rejectedEntityStatusReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("rejectedEntityStatusReasons", it) + .add(rejectedEntityStatusReason) + } + } + + /** The status of the document upload */ + fun status(status: DocumentUploadStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [DocumentUploadStatus] + * 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 statusReasons(statusReasons: List) = + statusReasons(JsonField.of(statusReasons)) + + /** + * Sets [Builder.statusReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.statusReasons] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun statusReasons(statusReasons: JsonField>) = apply { + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [statusReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStatusReason(statusReason: String) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("statusReasons", it).add(statusReason) + } + } + + /** When the document upload was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RequiredDocumentUpload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RequiredDocumentUpload = + RequiredDocumentUpload( + token, + (acceptedEntityStatusReasons ?: JsonMissing.of()).map { it.toImmutable() }, + created, + imageType, + (rejectedEntityStatusReasons ?: JsonMissing.of()).map { it.toImmutable() }, + status, + (statusReasons ?: JsonMissing.of()).map { it.toImmutable() }, + updated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RequiredDocumentUpload = apply { + if (validated) { + return@apply + } + + token() + acceptedEntityStatusReasons() + created() + imageType().ifPresent { it.validate() } + rejectedEntityStatusReasons() + status().ifPresent { it.validate() } + statusReasons() + updated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (acceptedEntityStatusReasons.asKnown().getOrNull()?.size ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (imageType.asKnown().getOrNull()?.validity() ?: 0) + + (rejectedEntityStatusReasons.asKnown().getOrNull()?.size ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (statusReasons.asKnown().getOrNull()?.size ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + /** The type of image that was uploaded */ + class ImageType @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 FRONT = of("FRONT") + + @JvmField val BACK = of("BACK") + + @JvmStatic fun of(value: String) = ImageType(JsonField.of(value)) + } + + /** An enum containing [ImageType]'s known values. */ + enum class Known { + FRONT, + BACK, + } + + /** + * An enum containing [ImageType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ImageType] 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 { + FRONT, + BACK, + /** + * An enum member indicating that [ImageType] 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) { + FRONT -> Value.FRONT + BACK -> Value.BACK + 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) { + FRONT -> Known.FRONT + BACK -> Known.BACK + else -> throw LithicInvalidDataException("Unknown ImageType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ImageType = 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 ImageType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the document upload */ + class DocumentUploadStatus + @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 ACCEPTED = of("ACCEPTED") + + @JvmField val REJECTED = of("REJECTED") + + @JvmField val PENDING_UPLOAD = of("PENDING_UPLOAD") + + @JvmField val UPLOADED = of("UPLOADED") + + @JvmField val PARTIAL_APPROVAL = of("PARTIAL_APPROVAL") + + @JvmStatic fun of(value: String) = DocumentUploadStatus(JsonField.of(value)) + } + + /** An enum containing [DocumentUploadStatus]'s known values. */ + enum class Known { + ACCEPTED, + REJECTED, + PENDING_UPLOAD, + UPLOADED, + PARTIAL_APPROVAL, + } + + /** + * An enum containing [DocumentUploadStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DocumentUploadStatus] 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 { + ACCEPTED, + REJECTED, + PENDING_UPLOAD, + UPLOADED, + PARTIAL_APPROVAL, + /** + * An enum member indicating that [DocumentUploadStatus] 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) { + ACCEPTED -> Value.ACCEPTED + REJECTED -> Value.REJECTED + PENDING_UPLOAD -> Value.PENDING_UPLOAD + UPLOADED -> Value.UPLOADED + PARTIAL_APPROVAL -> Value.PARTIAL_APPROVAL + 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) { + ACCEPTED -> Known.ACCEPTED + REJECTED -> Known.REJECTED + PENDING_UPLOAD -> Known.PENDING_UPLOAD + UPLOADED -> Known.UPLOADED + PARTIAL_APPROVAL -> Known.PARTIAL_APPROVAL + else -> throw LithicInvalidDataException("Unknown DocumentUploadStatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DocumentUploadStatus = 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 DocumentUploadStatus && 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 RequiredDocumentUpload && + token == other.token && + acceptedEntityStatusReasons == other.acceptedEntityStatusReasons && + created == other.created && + imageType == other.imageType && + rejectedEntityStatusReasons == other.rejectedEntityStatusReasons && + status == other.status && + statusReasons == other.statusReasons && + updated == other.updated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + acceptedEntityStatusReasons, + created, + imageType, + rejectedEntityStatusReasons, + status, + statusReasons, + updated, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RequiredDocumentUpload{token=$token, acceptedEntityStatusReasons=$acceptedEntityStatusReasons, created=$created, imageType=$imageType, rejectedEntityStatusReasons=$rejectedEntityStatusReasons, status=$status, statusReasons=$statusReasons, updated=$updated, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountHolderDocumentUpdatedWebhookEvent && + eventType == other.eventType && + token == other.token && + accountHolderToken == other.accountHolderToken && + created == other.created && + documentType == other.documentType && + entityToken == other.entityToken && + requiredDocumentUploads == other.requiredDocumentUploads && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + eventType, + token, + accountHolderToken, + created, + documentType, + entityToken, + requiredDocumentUploads, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccountHolderDocumentUpdatedWebhookEvent{eventType=$eventType, token=$token, accountHolderToken=$accountHolderToken, created=$created, documentType=$documentType, entityToken=$entityToken, requiredDocumentUploads=$requiredDocumentUploads, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdatedWebhookEvent.kt new file mode 100644 index 000000000..9a49ea1a9 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderUpdatedWebhookEvent.kt @@ -0,0 +1,4118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.allMaxBy +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** KYB payload for an updated account holder. */ +@JsonDeserialize(using = AccountHolderUpdatedWebhookEvent.Deserializer::class) +@JsonSerialize(using = AccountHolderUpdatedWebhookEvent.Serializer::class) +class AccountHolderUpdatedWebhookEvent +private constructor( + private val kybPayload: KybPayload? = null, + private val kycPayload: KycPayload? = null, + private val legacyPayload: LegacyPayload? = null, + private val _json: JsonValue? = null, +) { + + /** KYB payload for an updated account holder. */ + fun kybPayload(): Optional = Optional.ofNullable(kybPayload) + + /** KYC payload for an updated account holder. */ + fun kycPayload(): Optional = Optional.ofNullable(kycPayload) + + /** Legacy payload for an updated account holder. */ + fun legacyPayload(): Optional = Optional.ofNullable(legacyPayload) + + fun isKybPayload(): Boolean = kybPayload != null + + fun isKycPayload(): Boolean = kycPayload != null + + fun isLegacyPayload(): Boolean = legacyPayload != null + + /** KYB payload for an updated account holder. */ + fun asKybPayload(): KybPayload = kybPayload.getOrThrow("kybPayload") + + /** KYC payload for an updated account holder. */ + fun asKycPayload(): KycPayload = kycPayload.getOrThrow("kycPayload") + + /** Legacy payload for an updated account holder. */ + fun asLegacyPayload(): LegacyPayload = legacyPayload.getOrThrow("legacyPayload") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + kybPayload != null -> visitor.visitKybPayload(kybPayload) + kycPayload != null -> visitor.visitKycPayload(kycPayload) + legacyPayload != null -> visitor.visitLegacyPayload(legacyPayload) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AccountHolderUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitKybPayload(kybPayload: KybPayload) { + kybPayload.validate() + } + + override fun visitKycPayload(kycPayload: KycPayload) { + kycPayload.validate() + } + + override fun visitLegacyPayload(legacyPayload: LegacyPayload) { + legacyPayload.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitKybPayload(kybPayload: KybPayload) = kybPayload.validity() + + override fun visitKycPayload(kycPayload: KycPayload) = kycPayload.validity() + + override fun visitLegacyPayload(legacyPayload: LegacyPayload) = + legacyPayload.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountHolderUpdatedWebhookEvent && + kybPayload == other.kybPayload && + kycPayload == other.kycPayload && + legacyPayload == other.legacyPayload + } + + override fun hashCode(): Int = Objects.hash(kybPayload, kycPayload, legacyPayload) + + override fun toString(): String = + when { + kybPayload != null -> "AccountHolderUpdatedWebhookEvent{kybPayload=$kybPayload}" + kycPayload != null -> "AccountHolderUpdatedWebhookEvent{kycPayload=$kycPayload}" + legacyPayload != null -> + "AccountHolderUpdatedWebhookEvent{legacyPayload=$legacyPayload}" + _json != null -> "AccountHolderUpdatedWebhookEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AccountHolderUpdatedWebhookEvent") + } + + companion object { + + /** KYB payload for an updated account holder. */ + @JvmStatic + fun ofKybPayload(kybPayload: KybPayload) = + AccountHolderUpdatedWebhookEvent(kybPayload = kybPayload) + + /** KYC payload for an updated account holder. */ + @JvmStatic + fun ofKycPayload(kycPayload: KycPayload) = + AccountHolderUpdatedWebhookEvent(kycPayload = kycPayload) + + /** Legacy payload for an updated account holder. */ + @JvmStatic + fun ofLegacyPayload(legacyPayload: LegacyPayload) = + AccountHolderUpdatedWebhookEvent(legacyPayload = legacyPayload) + } + + /** + * An interface that defines how to map each variant of [AccountHolderUpdatedWebhookEvent] to a + * value of type [T]. + */ + interface Visitor { + + /** KYB payload for an updated account holder. */ + fun visitKybPayload(kybPayload: KybPayload): T + + /** KYC payload for an updated account holder. */ + fun visitKycPayload(kycPayload: KycPayload): T + + /** Legacy payload for an updated account holder. */ + fun visitLegacyPayload(legacyPayload: LegacyPayload): T + + /** + * Maps an unknown variant of [AccountHolderUpdatedWebhookEvent] to a value of type [T]. + * + * An instance of [AccountHolderUpdatedWebhookEvent] can contain an unknown variant if it + * was deserialized from data that doesn't match any known variant. For example, if the SDK + * is on an older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown AccountHolderUpdatedWebhookEvent: $json") + } + } + + internal class Deserializer : + BaseDeserializer( + AccountHolderUpdatedWebhookEvent::class + ) { + + override fun ObjectCodec.deserialize(node: JsonNode): AccountHolderUpdatedWebhookEvent { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + AccountHolderUpdatedWebhookEvent(kybPayload = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountHolderUpdatedWebhookEvent(kycPayload = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AccountHolderUpdatedWebhookEvent(legacyPayload = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> AccountHolderUpdatedWebhookEvent(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(AccountHolderUpdatedWebhookEvent::class) { + + override fun serialize( + value: AccountHolderUpdatedWebhookEvent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.kybPayload != null -> generator.writeObject(value.kybPayload) + value.kycPayload != null -> generator.writeObject(value.kycPayload) + value.legacyPayload != null -> generator.writeObject(value.legacyPayload) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AccountHolderUpdatedWebhookEvent") + } + } + } + + /** KYB payload for an updated account holder. */ + class KybPayload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val updateRequest: JsonField, + private val eventType: JsonField, + private val externalId: JsonField, + private val natureOfBusiness: JsonField, + private val websiteUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("update_request") + @ExcludeMissing + updateRequest: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + @JsonProperty("nature_of_business") + @ExcludeMissing + natureOfBusiness: JsonField = JsonMissing.of(), + @JsonProperty("website_url") + @ExcludeMissing + websiteUrl: JsonField = JsonMissing.of(), + ) : this( + token, + updateRequest, + eventType, + externalId, + natureOfBusiness, + websiteUrl, + mutableMapOf(), + ) + + /** + * The token of the account_holder that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Original request to update the account holder. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updateRequest(): UpdateRequest = updateRequest.getRequired("update_request") + + /** + * The type of event that occurred. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventType(): Optional = eventType.getOptional("event_type") + + /** + * A user provided id that can be used to link an account holder with an external system + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * Short description of the company's line of business (i.e., what does the company do?). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun natureOfBusiness(): Optional = + natureOfBusiness.getOptional("nature_of_business") + + /** + * Company website URL. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun websiteUrl(): Optional = websiteUrl.getOptional("website_url") + + /** + * 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 [updateRequest]. + * + * Unlike [updateRequest], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("update_request") + @ExcludeMissing + fun _updateRequest(): JsonField = updateRequest + + /** + * 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 [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + + /** + * Returns the raw JSON value of [natureOfBusiness]. + * + * Unlike [natureOfBusiness], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nature_of_business") + @ExcludeMissing + fun _natureOfBusiness(): JsonField = natureOfBusiness + + /** + * Returns the raw JSON value of [websiteUrl]. + * + * Unlike [websiteUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("website_url") + @ExcludeMissing + fun _websiteUrl(): JsonField = websiteUrl + + @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 [KybPayload]. + * + * The following fields are required: + * ```java + * .token() + * .updateRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [KybPayload]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var updateRequest: JsonField? = null + private var eventType: JsonField = JsonMissing.of() + private var externalId: JsonField = JsonMissing.of() + private var natureOfBusiness: JsonField = JsonMissing.of() + private var websiteUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(kybPayload: KybPayload) = apply { + token = kybPayload.token + updateRequest = kybPayload.updateRequest + eventType = kybPayload.eventType + externalId = kybPayload.externalId + natureOfBusiness = kybPayload.natureOfBusiness + websiteUrl = kybPayload.websiteUrl + additionalProperties = kybPayload.additionalProperties.toMutableMap() + } + + /** The token of the account_holder that was created. */ + 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 } + + /** Original request to update the account holder. */ + fun updateRequest(updateRequest: UpdateRequest) = + updateRequest(JsonField.of(updateRequest)) + + /** + * Sets [Builder.updateRequest] to an arbitrary JSON value. + * + * You should usually call [Builder.updateRequest] with a well-typed [UpdateRequest] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun updateRequest(updateRequest: JsonField) = apply { + this.updateRequest = updateRequest + } + + /** 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 } + + /** + * A user provided id that can be used to link an account holder with an external system + */ + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + /** + * Short description of the company's line of business (i.e., what does the company + * do?). + */ + fun natureOfBusiness(natureOfBusiness: String) = + natureOfBusiness(JsonField.of(natureOfBusiness)) + + /** + * Sets [Builder.natureOfBusiness] to an arbitrary JSON value. + * + * You should usually call [Builder.natureOfBusiness] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun natureOfBusiness(natureOfBusiness: JsonField) = apply { + this.natureOfBusiness = natureOfBusiness + } + + /** Company website URL. */ + fun websiteUrl(websiteUrl: String) = websiteUrl(JsonField.of(websiteUrl)) + + /** + * Sets [Builder.websiteUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.websiteUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun websiteUrl(websiteUrl: JsonField) = apply { this.websiteUrl = websiteUrl } + + 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 [KybPayload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .updateRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): KybPayload = + KybPayload( + checkRequired("token", token), + checkRequired("updateRequest", updateRequest), + eventType, + externalId, + natureOfBusiness, + websiteUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): KybPayload = apply { + if (validated) { + return@apply + } + + token() + updateRequest().validate() + eventType().ifPresent { it.validate() } + externalId() + natureOfBusiness() + websiteUrl() + 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) + + (updateRequest.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (if (natureOfBusiness.asKnown().isPresent) 1 else 0) + + (if (websiteUrl.asKnown().isPresent) 1 else 0) + + /** Original request to update the account holder. */ + class UpdateRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val beneficialOwnerEntities: JsonField>, + private val beneficialOwnerIndividuals: JsonField>, + private val businessEntity: JsonField, + private val controlPerson: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("beneficial_owner_entities") + @ExcludeMissing + beneficialOwnerEntities: JsonField> = JsonMissing.of(), + @JsonProperty("beneficial_owner_individuals") + @ExcludeMissing + beneficialOwnerIndividuals: JsonField> = JsonMissing.of(), + @JsonProperty("business_entity") + @ExcludeMissing + businessEntity: JsonField = JsonMissing.of(), + @JsonProperty("control_person") + @ExcludeMissing + controlPerson: JsonField = JsonMissing.of(), + ) : this( + beneficialOwnerEntities, + beneficialOwnerIndividuals, + businessEntity, + controlPerson, + mutableMapOf(), + ) + + /** + * Deprecated. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun beneficialOwnerEntities(): Optional> = + beneficialOwnerEntities.getOptional("beneficial_owner_entities") + + /** + * You must submit a list of all direct and indirect individuals with 25% or more + * ownership in the company. A maximum of 4 beneficial owners can be submitted. If no + * individual owns 25% of the company you do not need to send beneficial owner + * information. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section I) for more background on individuals that should be included. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun beneficialOwnerIndividuals(): Optional> = + beneficialOwnerIndividuals.getOptional("beneficial_owner_individuals") + + /** + * Information for business for which the account is being opened and KYB is being run. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun businessEntity(): Optional = + businessEntity.getOptional("business_entity") + + /** + * An individual with significant responsibility for managing the legal entity (e.g., a + * Chief Executive Officer, Chief Financial Officer, Chief Operating Officer, Managing + * Member, General Partner, President, Vice President, or Treasurer). This can be an + * executive, or someone who will have program-wide access to the cards that Lithic will + * provide. In some cases, this individual could also be a beneficial owner listed + * above. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section II) for more background. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun controlPerson(): Optional = controlPerson.getOptional("control_person") + + /** + * Returns the raw JSON value of [beneficialOwnerEntities]. + * + * Unlike [beneficialOwnerEntities], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("beneficial_owner_entities") + @ExcludeMissing + fun _beneficialOwnerEntities(): JsonField> = + beneficialOwnerEntities + + /** + * Returns the raw JSON value of [beneficialOwnerIndividuals]. + * + * Unlike [beneficialOwnerIndividuals], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("beneficial_owner_individuals") + @ExcludeMissing + fun _beneficialOwnerIndividuals(): JsonField> = + beneficialOwnerIndividuals + + /** + * Returns the raw JSON value of [businessEntity]. + * + * Unlike [businessEntity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("business_entity") + @ExcludeMissing + fun _businessEntity(): JsonField = businessEntity + + /** + * Returns the raw JSON value of [controlPerson]. + * + * Unlike [controlPerson], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("control_person") + @ExcludeMissing + fun _controlPerson(): JsonField = controlPerson + + @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 [UpdateRequest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateRequest]. */ + class Builder internal constructor() { + + private var beneficialOwnerEntities: JsonField>? = + null + private var beneficialOwnerIndividuals: JsonField>? = null + private var businessEntity: JsonField = JsonMissing.of() + private var controlPerson: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateRequest: UpdateRequest) = apply { + beneficialOwnerEntities = + updateRequest.beneficialOwnerEntities.map { it.toMutableList() } + beneficialOwnerIndividuals = + updateRequest.beneficialOwnerIndividuals.map { it.toMutableList() } + businessEntity = updateRequest.businessEntity + controlPerson = updateRequest.controlPerson + additionalProperties = updateRequest.additionalProperties.toMutableMap() + } + + /** Deprecated. */ + @Deprecated("deprecated") + fun beneficialOwnerEntities(beneficialOwnerEntities: List) = + beneficialOwnerEntities(JsonField.of(beneficialOwnerEntities)) + + /** + * Sets [Builder.beneficialOwnerEntities] to an arbitrary JSON value. + * + * You should usually call [Builder.beneficialOwnerEntities] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun beneficialOwnerEntities( + beneficialOwnerEntities: JsonField> + ) = apply { + this.beneficialOwnerEntities = + beneficialOwnerEntities.map { it.toMutableList() } + } + + /** + * Adds a single [KybBusinessEntity] to [beneficialOwnerEntities]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addBeneficialOwnerEntity(beneficialOwnerEntity: KybBusinessEntity) = apply { + beneficialOwnerEntities = + (beneficialOwnerEntities ?: JsonField.of(mutableListOf())).also { + checkKnown("beneficialOwnerEntities", it).add(beneficialOwnerEntity) + } + } + + /** + * You must submit a list of all direct and indirect individuals with 25% or more + * ownership in the company. A maximum of 4 beneficial owners can be submitted. If + * no individual owns 25% of the company you do not need to send beneficial owner + * information. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section I) for more background on individuals that should be included. + */ + fun beneficialOwnerIndividuals(beneficialOwnerIndividuals: List) = + beneficialOwnerIndividuals(JsonField.of(beneficialOwnerIndividuals)) + + /** + * Sets [Builder.beneficialOwnerIndividuals] to an arbitrary JSON value. + * + * You should usually call [Builder.beneficialOwnerIndividuals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun beneficialOwnerIndividuals( + beneficialOwnerIndividuals: JsonField> + ) = apply { + this.beneficialOwnerIndividuals = + beneficialOwnerIndividuals.map { it.toMutableList() } + } + + /** + * Adds a single [Individual] to [beneficialOwnerIndividuals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeneficialOwnerIndividual(beneficialOwnerIndividual: Individual) = apply { + beneficialOwnerIndividuals = + (beneficialOwnerIndividuals ?: JsonField.of(mutableListOf())).also { + checkKnown("beneficialOwnerIndividuals", it) + .add(beneficialOwnerIndividual) + } + } + + /** + * Information for business for which the account is being opened and KYB is being + * run. + */ + fun businessEntity(businessEntity: KybBusinessEntity) = + businessEntity(JsonField.of(businessEntity)) + + /** + * Sets [Builder.businessEntity] to an arbitrary JSON value. + * + * You should usually call [Builder.businessEntity] with a well-typed + * [KybBusinessEntity] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun businessEntity(businessEntity: JsonField) = apply { + this.businessEntity = businessEntity + } + + /** + * An individual with significant responsibility for managing the legal entity + * (e.g., a Chief Executive Officer, Chief Financial Officer, Chief Operating + * Officer, Managing Member, General Partner, President, Vice President, or + * Treasurer). This can be an executive, or someone who will have program-wide + * access to the cards that Lithic will provide. In some cases, this individual + * could also be a beneficial owner listed above. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section II) for more background. + */ + fun controlPerson(controlPerson: Individual) = + controlPerson(JsonField.of(controlPerson)) + + /** + * Sets [Builder.controlPerson] to an arbitrary JSON value. + * + * You should usually call [Builder.controlPerson] with a well-typed [Individual] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun controlPerson(controlPerson: JsonField) = apply { + this.controlPerson = controlPerson + } + + 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 [UpdateRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdateRequest = + UpdateRequest( + (beneficialOwnerEntities ?: JsonMissing.of()).map { it.toImmutable() }, + (beneficialOwnerIndividuals ?: JsonMissing.of()).map { it.toImmutable() }, + businessEntity, + controlPerson, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UpdateRequest = apply { + if (validated) { + return@apply + } + + beneficialOwnerEntities().ifPresent { it.forEach { it.validate() } } + beneficialOwnerIndividuals().ifPresent { it.forEach { it.validate() } } + businessEntity().ifPresent { it.validate() } + controlPerson().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 = + (beneficialOwnerEntities.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (beneficialOwnerIndividuals.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (businessEntity.asKnown().getOrNull()?.validity() ?: 0) + + (controlPerson.asKnown().getOrNull()?.validity() ?: 0) + + class Individual + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField
, + private val dob: JsonField, + private val email: JsonField, + private val firstName: JsonField, + private val governmentId: JsonField, + private val lastName: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") + @ExcludeMissing + address: JsonField
= JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + firstName: JsonField = JsonMissing.of(), + @JsonProperty("government_id") + @ExcludeMissing + governmentId: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + lastName: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + mutableMapOf(), + ) + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently supported. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun address(): Optional
= address.getOptional("address") + + /** + * Individual's date of birth, as an RFC 3339 date. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dob(): Optional = dob.getOptional("dob") + + /** + * Individual's email address. If utilizing Lithic for chargeback processing, this + * customer email address may be used to communicate dispute status and resolution. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Individual's first name, as it appears on government-issued identity documents. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun firstName(): Optional = firstName.getOptional("first_name") + + /** + * Government-issued identification number (required for identity verification and + * compliance with banking regulations). Social Security Numbers (SSN) and + * Individual Taxpayer Identification Numbers (ITIN) are currently supported, + * entered as full nine-digits, with or without hyphens + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun governmentId(): Optional = governmentId.getOptional("government_id") + + /** + * Individual's last name, as it appears on government-issued identity documents. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lastName(): Optional = lastName.getOptional("last_name") + + /** + * Individual's phone number, entered in E.164 format. + * + * @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") + + /** + * 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 [dob]. + * + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName + + /** + * Returns the raw JSON value of [governmentId]. + * + * Unlike [governmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId + + /** + * Returns the raw JSON value of [lastName]. + * + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName + + /** + * 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 + + @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 [Individual]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Individual]. */ + class Builder internal constructor() { + + private var address: JsonField
= JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var governmentId: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(individual: Individual) = apply { + address = individual.address + dob = individual.dob + email = individual.email + firstName = individual.firstName + governmentId = individual.governmentId + lastName = individual.lastName + phoneNumber = individual.phoneNumber + additionalProperties = individual.additionalProperties.toMutableMap() + } + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently + * supported. + */ + fun address(address: Address) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [Address] 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 } + + /** Individual's date of birth, as an RFC 3339 date. */ + fun dob(dob: String) = dob(JsonField.of(dob)) + + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** + * Individual's email address. If utilizing Lithic for chargeback processing, + * this customer email address may be used to communicate dispute status and + * resolution. + */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** + * Individual's first name, as it appears on government-issued identity + * documents. + */ + fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun firstName(firstName: JsonField) = apply { + this.firstName = firstName + } + + /** + * Government-issued identification number (required for identity verification + * and compliance with banking regulations). Social Security Numbers (SSN) and + * Individual Taxpayer Identification Numbers (ITIN) are currently supported, + * entered as full nine-digits, with or without hyphens + */ + fun governmentId(governmentId: String) = + governmentId(JsonField.of(governmentId)) + + /** + * Sets [Builder.governmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.governmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun governmentId(governmentId: JsonField) = apply { + this.governmentId = governmentId + } + + /** + * Individual's last name, as it appears on government-issued identity + * documents. + */ + fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + + /** + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + /** Individual's phone number, entered in E.164 format. */ + 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 + } + + 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 [Individual]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Individual = + Individual( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Individual = apply { + if (validated) { + return@apply + } + + address().ifPresent { it.validate() } + dob() + email() + firstName() + governmentId() + lastName() + phoneNumber() + 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 = + (address.asKnown().getOrNull()?.validity() ?: 0) + + (if (dob.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (if (governmentId.asKnown().isPresent) 1 else 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently supported. + */ + class Address + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address1: JsonField, + private val city: JsonField, + private val country: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val address2: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address1") + @ExcludeMissing + address1: JsonField = JsonMissing.of(), + @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("address2") + @ExcludeMissing + address2: JsonField = JsonMissing.of(), + ) : this(address1, city, country, postalCode, state, address2, mutableMapOf()) + + /** + * Valid deliverable address (no PO boxes). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun address1(): String = address1.getRequired("address1") + + /** + * Name of city. + * + * @throws LithicInvalidDataException if 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") + + /** + * Valid country code. Only USA is currently supported, entered in uppercase ISO + * 3166-1 alpha-3 three-character format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Valid postal code. Only USA ZIP codes are currently supported, entered as a + * five-digit ZIP or nine-digit ZIP+4. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun postalCode(): String = postalCode.getRequired("postal_code") + + /** + * Valid state code. Only USA state codes are currently supported, entered in + * uppercase ISO 3166-2 two-character format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun state(): String = state.getRequired("state") + + /** + * Unit or apartment number (if applicable). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun address2(): Optional = address2.getOptional("address2") + + /** + * Returns the raw JSON value of [address1]. + * + * Unlike [address1], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address1") + @ExcludeMissing + fun _address1(): JsonField = address1 + + /** + * 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 [address2]. + * + * Unlike [address2], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address2") + @ExcludeMissing + fun _address2(): JsonField = address2 + + @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 [Address]. + * + * The following fields are required: + * ```java + * .address1() + * .city() + * .country() + * .postalCode() + * .state() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Address]. */ + class Builder internal constructor() { + + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null + private var address2: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(address: Address) = apply { + address1 = address.address1 + city = address.city + country = address.country + postalCode = address.postalCode + state = address.state + address2 = address.address2 + additionalProperties = address.additionalProperties.toMutableMap() + } + + /** Valid deliverable address (no PO boxes). */ + fun address1(address1: String) = address1(JsonField.of(address1)) + + /** + * Sets [Builder.address1] to an arbitrary JSON value. + * + * You should usually call [Builder.address1] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun address1(address1: JsonField) = apply { + this.address1 = address1 + } + + /** Name of city. */ + 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 } + + /** + * Valid country code. Only USA is currently supported, entered in uppercase + * ISO 3166-1 alpha-3 three-character format. + */ + 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 } + + /** + * Valid postal code. Only USA ZIP codes are currently supported, entered as + * a five-digit ZIP or nine-digit ZIP+4. + */ + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun postalCode(postalCode: JsonField) = apply { + this.postalCode = postalCode + } + + /** + * Valid state code. Only USA state codes are currently supported, entered + * in uppercase ISO 3166-2 two-character format. + */ + 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 } + + /** Unit or apartment number (if applicable). */ + fun address2(address2: String) = address2(JsonField.of(address2)) + + /** + * Sets [Builder.address2] to an arbitrary JSON value. + * + * You should usually call [Builder.address2] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun address2(address2: JsonField) = apply { + this.address2 = address2 + } + + 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 [Address]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .address1() + * .city() + * .country() + * .postalCode() + * .state() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Address = + Address( + checkRequired("address1", address1), + checkRequired("city", city), + checkRequired("country", country), + checkRequired("postalCode", postalCode), + checkRequired("state", state), + address2, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Address = apply { + if (validated) { + return@apply + } + + address1() + city() + country() + postalCode() + state() + address2() + 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 (address1.asKnown().isPresent) 1 else 0) + + (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 (address2.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Address && + address1 == other.address1 && + city == other.city && + country == other.country && + postalCode == other.postalCode && + state == other.state && + address2 == other.address2 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address1, + city, + country, + postalCode, + state, + address2, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Address{address1=$address1, city=$city, country=$country, postalCode=$postalCode, state=$state, address2=$address2, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Individual && + address == other.address && + dob == other.dob && + email == other.email && + firstName == other.firstName && + governmentId == other.governmentId && + lastName == other.lastName && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Individual{address=$address, dob=$dob, email=$email, firstName=$firstName, governmentId=$governmentId, lastName=$lastName, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateRequest && + beneficialOwnerEntities == other.beneficialOwnerEntities && + beneficialOwnerIndividuals == other.beneficialOwnerIndividuals && + businessEntity == other.businessEntity && + controlPerson == other.controlPerson && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + beneficialOwnerEntities, + beneficialOwnerIndividuals, + businessEntity, + controlPerson, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateRequest{beneficialOwnerEntities=$beneficialOwnerEntities, beneficialOwnerIndividuals=$beneficialOwnerIndividuals, businessEntity=$businessEntity, controlPerson=$controlPerson, 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 ACCOUNT_HOLDER_UPDATED = of("account_holder.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_UPDATED + } + + /** + * 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 { + ACCOUNT_HOLDER_UPDATED, + /** + * 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) { + ACCOUNT_HOLDER_UPDATED -> Value.ACCOUNT_HOLDER_UPDATED + 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) { + ACCOUNT_HOLDER_UPDATED -> Known.ACCOUNT_HOLDER_UPDATED + 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 + + 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 KybPayload && + token == other.token && + updateRequest == other.updateRequest && + eventType == other.eventType && + externalId == other.externalId && + natureOfBusiness == other.natureOfBusiness && + websiteUrl == other.websiteUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + updateRequest, + eventType, + externalId, + natureOfBusiness, + websiteUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "KybPayload{token=$token, updateRequest=$updateRequest, eventType=$eventType, externalId=$externalId, natureOfBusiness=$natureOfBusiness, websiteUrl=$websiteUrl, additionalProperties=$additionalProperties}" + } + + /** KYC payload for an updated account holder. */ + class KycPayload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val updateRequest: JsonField, + private val eventType: JsonField, + private val externalId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("update_request") + @ExcludeMissing + updateRequest: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + ) : this(token, updateRequest, eventType, externalId, mutableMapOf()) + + /** + * The token of the account_holder that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Original request to update the account holder. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updateRequest(): UpdateRequest = updateRequest.getRequired("update_request") + + /** + * The type of event that occurred. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventType(): Optional = eventType.getOptional("event_type") + + /** + * A user provided id that can be used to link an account holder with an external system + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * 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 [updateRequest]. + * + * Unlike [updateRequest], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("update_request") + @ExcludeMissing + fun _updateRequest(): JsonField = updateRequest + + /** + * 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 [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + + @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 [KycPayload]. + * + * The following fields are required: + * ```java + * .token() + * .updateRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [KycPayload]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var updateRequest: JsonField? = null + private var eventType: JsonField = JsonMissing.of() + private var externalId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(kycPayload: KycPayload) = apply { + token = kycPayload.token + updateRequest = kycPayload.updateRequest + eventType = kycPayload.eventType + externalId = kycPayload.externalId + additionalProperties = kycPayload.additionalProperties.toMutableMap() + } + + /** The token of the account_holder that was created. */ + 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 } + + /** Original request to update the account holder. */ + fun updateRequest(updateRequest: UpdateRequest) = + updateRequest(JsonField.of(updateRequest)) + + /** + * Sets [Builder.updateRequest] to an arbitrary JSON value. + * + * You should usually call [Builder.updateRequest] with a well-typed [UpdateRequest] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun updateRequest(updateRequest: JsonField) = apply { + this.updateRequest = updateRequest + } + + /** 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 } + + /** + * A user provided id that can be used to link an account holder with an external system + */ + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + 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 [KycPayload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .updateRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): KycPayload = + KycPayload( + checkRequired("token", token), + checkRequired("updateRequest", updateRequest), + eventType, + externalId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): KycPayload = apply { + if (validated) { + return@apply + } + + token() + updateRequest().validate() + eventType().ifPresent { it.validate() } + externalId() + 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) + + (updateRequest.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + /** Original request to update the account holder. */ + class UpdateRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val individual: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("individual") + @ExcludeMissing + individual: JsonField = JsonMissing.of() + ) : this(individual, mutableMapOf()) + + /** + * Information on the individual for whom the account is being opened and KYC is being + * run. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun individual(): Optional = individual.getOptional("individual") + + /** + * Returns the raw JSON value of [individual]. + * + * Unlike [individual], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("individual") + @ExcludeMissing + fun _individual(): JsonField = individual + + @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 [UpdateRequest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateRequest]. */ + class Builder internal constructor() { + + private var individual: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateRequest: UpdateRequest) = apply { + individual = updateRequest.individual + additionalProperties = updateRequest.additionalProperties.toMutableMap() + } + + /** + * Information on the individual for whom the account is being opened and KYC is + * being run. + */ + fun individual(individual: Individual) = individual(JsonField.of(individual)) + + /** + * Sets [Builder.individual] to an arbitrary JSON value. + * + * You should usually call [Builder.individual] with a well-typed [Individual] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun individual(individual: JsonField) = apply { + this.individual = individual + } + + 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 [UpdateRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdateRequest = + UpdateRequest(individual, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): UpdateRequest = apply { + if (validated) { + return@apply + } + + individual().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 = (individual.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Information on the individual for whom the account is being opened and KYC is being + * run. + */ + class Individual + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField
, + private val dob: JsonField, + private val email: JsonField, + private val firstName: JsonField, + private val governmentId: JsonField, + private val lastName: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") + @ExcludeMissing + address: JsonField
= JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + firstName: JsonField = JsonMissing.of(), + @JsonProperty("government_id") + @ExcludeMissing + governmentId: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + lastName: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + mutableMapOf(), + ) + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently supported. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun address(): Optional
= address.getOptional("address") + + /** + * Individual's date of birth, as an RFC 3339 date. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dob(): Optional = dob.getOptional("dob") + + /** + * Individual's email address. If utilizing Lithic for chargeback processing, this + * customer email address may be used to communicate dispute status and resolution. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Individual's first name, as it appears on government-issued identity documents. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun firstName(): Optional = firstName.getOptional("first_name") + + /** + * Government-issued identification number (required for identity verification and + * compliance with banking regulations). Social Security Numbers (SSN) and + * Individual Taxpayer Identification Numbers (ITIN) are currently supported, + * entered as full nine-digits, with or without hyphens + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun governmentId(): Optional = governmentId.getOptional("government_id") + + /** + * Individual's last name, as it appears on government-issued identity documents. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lastName(): Optional = lastName.getOptional("last_name") + + /** + * Individual's phone number, entered in E.164 format. + * + * @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") + + /** + * 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 [dob]. + * + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName + + /** + * Returns the raw JSON value of [governmentId]. + * + * Unlike [governmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId + + /** + * Returns the raw JSON value of [lastName]. + * + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName + + /** + * 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 + + @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 [Individual]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Individual]. */ + class Builder internal constructor() { + + private var address: JsonField
= JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var governmentId: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(individual: Individual) = apply { + address = individual.address + dob = individual.dob + email = individual.email + firstName = individual.firstName + governmentId = individual.governmentId + lastName = individual.lastName + phoneNumber = individual.phoneNumber + additionalProperties = individual.additionalProperties.toMutableMap() + } + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently + * supported. + */ + fun address(address: Address) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [Address] 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 } + + /** Individual's date of birth, as an RFC 3339 date. */ + fun dob(dob: String) = dob(JsonField.of(dob)) + + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** + * Individual's email address. If utilizing Lithic for chargeback processing, + * this customer email address may be used to communicate dispute status and + * resolution. + */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** + * Individual's first name, as it appears on government-issued identity + * documents. + */ + fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun firstName(firstName: JsonField) = apply { + this.firstName = firstName + } + + /** + * Government-issued identification number (required for identity verification + * and compliance with banking regulations). Social Security Numbers (SSN) and + * Individual Taxpayer Identification Numbers (ITIN) are currently supported, + * entered as full nine-digits, with or without hyphens + */ + fun governmentId(governmentId: String) = + governmentId(JsonField.of(governmentId)) + + /** + * Sets [Builder.governmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.governmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun governmentId(governmentId: JsonField) = apply { + this.governmentId = governmentId + } + + /** + * Individual's last name, as it appears on government-issued identity + * documents. + */ + fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + + /** + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + /** Individual's phone number, entered in E.164 format. */ + 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 + } + + 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 [Individual]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Individual = + Individual( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Individual = apply { + if (validated) { + return@apply + } + + address().ifPresent { it.validate() } + dob() + email() + firstName() + governmentId() + lastName() + phoneNumber() + 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 = + (address.asKnown().getOrNull()?.validity() ?: 0) + + (if (dob.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (if (governmentId.asKnown().isPresent) 1 else 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently supported. + */ + class Address + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address1: JsonField, + private val city: JsonField, + private val country: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val address2: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address1") + @ExcludeMissing + address1: JsonField = JsonMissing.of(), + @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("address2") + @ExcludeMissing + address2: JsonField = JsonMissing.of(), + ) : this(address1, city, country, postalCode, state, address2, mutableMapOf()) + + /** + * Valid deliverable address (no PO boxes). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun address1(): String = address1.getRequired("address1") + + /** + * Name of city. + * + * @throws LithicInvalidDataException if 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") + + /** + * Valid country code. Only USA is currently supported, entered in uppercase ISO + * 3166-1 alpha-3 three-character format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Valid postal code. Only USA ZIP codes are currently supported, entered as a + * five-digit ZIP or nine-digit ZIP+4. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun postalCode(): String = postalCode.getRequired("postal_code") + + /** + * Valid state code. Only USA state codes are currently supported, entered in + * uppercase ISO 3166-2 two-character format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun state(): String = state.getRequired("state") + + /** + * Unit or apartment number (if applicable). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun address2(): Optional = address2.getOptional("address2") + + /** + * Returns the raw JSON value of [address1]. + * + * Unlike [address1], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address1") + @ExcludeMissing + fun _address1(): JsonField = address1 + + /** + * 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 [address2]. + * + * Unlike [address2], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address2") + @ExcludeMissing + fun _address2(): JsonField = address2 + + @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 [Address]. + * + * The following fields are required: + * ```java + * .address1() + * .city() + * .country() + * .postalCode() + * .state() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Address]. */ + class Builder internal constructor() { + + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null + private var address2: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(address: Address) = apply { + address1 = address.address1 + city = address.city + country = address.country + postalCode = address.postalCode + state = address.state + address2 = address.address2 + additionalProperties = address.additionalProperties.toMutableMap() + } + + /** Valid deliverable address (no PO boxes). */ + fun address1(address1: String) = address1(JsonField.of(address1)) + + /** + * Sets [Builder.address1] to an arbitrary JSON value. + * + * You should usually call [Builder.address1] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun address1(address1: JsonField) = apply { + this.address1 = address1 + } + + /** Name of city. */ + 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 } + + /** + * Valid country code. Only USA is currently supported, entered in uppercase + * ISO 3166-1 alpha-3 three-character format. + */ + 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 } + + /** + * Valid postal code. Only USA ZIP codes are currently supported, entered as + * a five-digit ZIP or nine-digit ZIP+4. + */ + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun postalCode(postalCode: JsonField) = apply { + this.postalCode = postalCode + } + + /** + * Valid state code. Only USA state codes are currently supported, entered + * in uppercase ISO 3166-2 two-character format. + */ + 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 } + + /** Unit or apartment number (if applicable). */ + fun address2(address2: String) = address2(JsonField.of(address2)) + + /** + * Sets [Builder.address2] to an arbitrary JSON value. + * + * You should usually call [Builder.address2] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun address2(address2: JsonField) = apply { + this.address2 = address2 + } + + 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 [Address]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .address1() + * .city() + * .country() + * .postalCode() + * .state() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Address = + Address( + checkRequired("address1", address1), + checkRequired("city", city), + checkRequired("country", country), + checkRequired("postalCode", postalCode), + checkRequired("state", state), + address2, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Address = apply { + if (validated) { + return@apply + } + + address1() + city() + country() + postalCode() + state() + address2() + 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 (address1.asKnown().isPresent) 1 else 0) + + (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 (address2.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Address && + address1 == other.address1 && + city == other.city && + country == other.country && + postalCode == other.postalCode && + state == other.state && + address2 == other.address2 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address1, + city, + country, + postalCode, + state, + address2, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Address{address1=$address1, city=$city, country=$country, postalCode=$postalCode, state=$state, address2=$address2, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Individual && + address == other.address && + dob == other.dob && + email == other.email && + firstName == other.firstName && + governmentId == other.governmentId && + lastName == other.lastName && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Individual{address=$address, dob=$dob, email=$email, firstName=$firstName, governmentId=$governmentId, lastName=$lastName, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateRequest && + individual == other.individual && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(individual, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateRequest{individual=$individual, 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 ACCOUNT_HOLDER_UPDATED = of("account_holder.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_UPDATED + } + + /** + * 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 { + ACCOUNT_HOLDER_UPDATED, + /** + * 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) { + ACCOUNT_HOLDER_UPDATED -> Value.ACCOUNT_HOLDER_UPDATED + 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) { + ACCOUNT_HOLDER_UPDATED -> Known.ACCOUNT_HOLDER_UPDATED + 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 + + 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 KycPayload && + token == other.token && + updateRequest == other.updateRequest && + eventType == other.eventType && + externalId == other.externalId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(token, updateRequest, eventType, externalId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "KycPayload{token=$token, updateRequest=$updateRequest, eventType=$eventType, externalId=$externalId, additionalProperties=$additionalProperties}" + } + + /** Legacy payload for an updated account holder. */ + class LegacyPayload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val businessAccountToken: JsonField, + private val created: JsonField, + private val email: JsonField, + private val eventType: JsonField, + private val externalId: JsonField, + private val firstName: JsonField, + private val lastName: JsonField, + private val legalBusinessName: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("business_account_token") + @ExcludeMissing + businessAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + firstName: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + lastName: JsonField = JsonMissing.of(), + @JsonProperty("legal_business_name") + @ExcludeMissing + legalBusinessName: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this( + token, + businessAccountToken, + created, + email, + eventType, + externalId, + firstName, + lastName, + legalBusinessName, + phoneNumber, + mutableMapOf(), + ) + + /** + * The token of the account_holder that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * If applicable, represents the business account token associated with the account_holder. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun businessAccountToken(): Optional = + businessAccountToken.getOptional("business_account_token") + + /** + * When the account_holder updated event was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") + + /** + * If updated, the newly updated email associated with the account_holder otherwise the + * existing email is provided. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * The type of event that occurred. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventType(): Optional = eventType.getOptional("event_type") + + /** + * If applicable, represents the external_id associated with the account_holder. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * If applicable, represents the account_holder's first name. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun firstName(): Optional = firstName.getOptional("first_name") + + /** + * If applicable, represents the account_holder's last name. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastName(): Optional = lastName.getOptional("last_name") + + /** + * If applicable, represents the account_holder's business name. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun legalBusinessName(): Optional = + legalBusinessName.getOptional("legal_business_name") + + /** + * If updated, the newly updated phone_number associated with the account_holder otherwise + * the existing phone_number is provided. + * + * @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") + + /** + * 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 [businessAccountToken]. + * + * Unlike [businessAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("business_account_token") + @ExcludeMissing + fun _businessAccountToken(): JsonField = businessAccountToken + + /** + * 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 [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * 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 [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName + + /** + * Returns the raw JSON value of [lastName]. + * + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName + + /** + * Returns the raw JSON value of [legalBusinessName]. + * + * Unlike [legalBusinessName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("legal_business_name") + @ExcludeMissing + fun _legalBusinessName(): JsonField = legalBusinessName + + /** + * 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 + + @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 [LegacyPayload]. + * + * The following fields are required: + * ```java + * .token() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LegacyPayload]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var businessAccountToken: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var eventType: JsonField = JsonMissing.of() + private var externalId: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var legalBusinessName: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(legacyPayload: LegacyPayload) = apply { + token = legacyPayload.token + businessAccountToken = legacyPayload.businessAccountToken + created = legacyPayload.created + email = legacyPayload.email + eventType = legacyPayload.eventType + externalId = legacyPayload.externalId + firstName = legacyPayload.firstName + lastName = legacyPayload.lastName + legalBusinessName = legacyPayload.legalBusinessName + phoneNumber = legacyPayload.phoneNumber + additionalProperties = legacyPayload.additionalProperties.toMutableMap() + } + + /** The token of the account_holder that was created. */ + 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 } + + /** + * If applicable, represents the business account token associated with the + * account_holder. + */ + fun businessAccountToken(businessAccountToken: String?) = + businessAccountToken(JsonField.ofNullable(businessAccountToken)) + + /** + * Alias for calling [Builder.businessAccountToken] with + * `businessAccountToken.orElse(null)`. + */ + fun businessAccountToken(businessAccountToken: Optional) = + businessAccountToken(businessAccountToken.getOrNull()) + + /** + * Sets [Builder.businessAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.businessAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun businessAccountToken(businessAccountToken: JsonField) = apply { + this.businessAccountToken = businessAccountToken + } + + /** When the account_holder updated event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** + * If updated, the newly updated email associated with the account_holder otherwise the + * existing email is provided. + */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** 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 } + + /** If applicable, represents the external_id associated with the account_holder. */ + fun externalId(externalId: String?) = externalId(JsonField.ofNullable(externalId)) + + /** Alias for calling [Builder.externalId] with `externalId.orElse(null)`. */ + fun externalId(externalId: Optional) = externalId(externalId.getOrNull()) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + /** If applicable, represents the account_holder's first name. */ + fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstName(firstName: JsonField) = apply { this.firstName = firstName } + + /** If applicable, represents the account_holder's last name. */ + fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + + /** + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + /** If applicable, represents the account_holder's business name. */ + fun legalBusinessName(legalBusinessName: String) = + legalBusinessName(JsonField.of(legalBusinessName)) + + /** + * Sets [Builder.legalBusinessName] to an arbitrary JSON value. + * + * You should usually call [Builder.legalBusinessName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun legalBusinessName(legalBusinessName: JsonField) = apply { + this.legalBusinessName = legalBusinessName + } + + /** + * If updated, the newly updated phone_number associated with the account_holder + * otherwise the existing phone_number is provided. + */ + 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 + } + + 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 [LegacyPayload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LegacyPayload = + LegacyPayload( + checkRequired("token", token), + businessAccountToken, + created, + email, + eventType, + externalId, + firstName, + lastName, + legalBusinessName, + phoneNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LegacyPayload = apply { + if (validated) { + return@apply + } + + token() + businessAccountToken() + created() + email() + eventType().ifPresent { it.validate() } + externalId() + firstName() + lastName() + legalBusinessName() + phoneNumber() + 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 (businessAccountToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (if (legalBusinessName.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + /** 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 ACCOUNT_HOLDER_UPDATED = of("account_holder.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_UPDATED + } + + /** + * 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 { + ACCOUNT_HOLDER_UPDATED, + /** + * 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) { + ACCOUNT_HOLDER_UPDATED -> Value.ACCOUNT_HOLDER_UPDATED + 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) { + ACCOUNT_HOLDER_UPDATED -> Known.ACCOUNT_HOLDER_UPDATED + 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 + + 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 LegacyPayload && + token == other.token && + businessAccountToken == other.businessAccountToken && + created == other.created && + email == other.email && + eventType == other.eventType && + externalId == other.externalId && + firstName == other.firstName && + lastName == other.lastName && + legalBusinessName == other.legalBusinessName && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + businessAccountToken, + created, + email, + eventType, + externalId, + firstName, + lastName, + legalBusinessName, + phoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LegacyPayload{token=$token, businessAccountToken=$businessAccountToken, created=$created, email=$email, eventType=$eventType, externalId=$externalId, firstName=$firstName, lastName=$lastName, legalBusinessName=$legalBusinessName, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderVerificationWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderVerificationWebhookEvent.kt new file mode 100644 index 000000000..63533cca8 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AccountHolderVerificationWebhookEvent.kt @@ -0,0 +1,649 @@ +// 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 + +class AccountHolderVerificationWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val eventType: JsonField, + private val token: JsonField, + private val accountToken: JsonField, + private val created: JsonField, + private val status: JsonField, + private val statusReasons: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("status_reasons") + @ExcludeMissing + statusReasons: JsonField> = JsonMissing.of(), + ) : this(eventType, token, accountToken, created, status, statusReasons, mutableMapOf()) + + /** + * 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") + + /** + * The token of the account_holder being verified. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * The token of the account being verified. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * When the account_holder verification status was updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") + + /** + * The status of the account_holder that was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusReasons(): Optional> = statusReasons.getOptional("status_reasons") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [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 [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 [statusReasons]. + * + * Unlike [statusReasons], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status_reasons") + @ExcludeMissing + fun _statusReasons(): JsonField> = statusReasons + + @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 + * [AccountHolderVerificationWebhookEvent]. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccountHolderVerificationWebhookEvent]. */ + class Builder internal constructor() { + + private var eventType: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var accountToken: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var statusReasons: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + accountHolderVerificationWebhookEvent: AccountHolderVerificationWebhookEvent + ) = apply { + eventType = accountHolderVerificationWebhookEvent.eventType + token = accountHolderVerificationWebhookEvent.token + accountToken = accountHolderVerificationWebhookEvent.accountToken + created = accountHolderVerificationWebhookEvent.created + status = accountHolderVerificationWebhookEvent.status + statusReasons = + accountHolderVerificationWebhookEvent.statusReasons.map { it.toMutableList() } + additionalProperties = + accountHolderVerificationWebhookEvent.additionalProperties.toMutableMap() + } + + /** 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 } + + /** The token of the account_holder being verified. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The token of the account being verified. */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** When the account_holder verification status was updated */ + 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 } + + /** The status of the account_holder that was created */ + 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 } + + fun statusReasons(statusReasons: List) = statusReasons(JsonField.of(statusReasons)) + + /** + * Sets [Builder.statusReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.statusReasons] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusReasons(statusReasons: JsonField>) = apply { + this.statusReasons = statusReasons.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [statusReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStatusReason(statusReason: String) = apply { + statusReasons = + (statusReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("statusReasons", it).add(statusReason) + } + } + + 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 [AccountHolderVerificationWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AccountHolderVerificationWebhookEvent = + AccountHolderVerificationWebhookEvent( + checkRequired("eventType", eventType), + token, + accountToken, + created, + status, + (statusReasons ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccountHolderVerificationWebhookEvent = apply { + if (validated) { + return@apply + } + + eventType().validate() + token() + accountToken() + created() + status().ifPresent { it.validate() } + statusReasons() + 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 = + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (statusReasons.asKnown().getOrNull()?.size ?: 0) + + /** 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 ACCOUNT_HOLDER_VERIFICATION = of("account_holder.verification") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_VERIFICATION + } + + /** + * 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 { + ACCOUNT_HOLDER_VERIFICATION, + /** + * 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) { + ACCOUNT_HOLDER_VERIFICATION -> Value.ACCOUNT_HOLDER_VERIFICATION + 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) { + ACCOUNT_HOLDER_VERIFICATION -> Known.ACCOUNT_HOLDER_VERIFICATION + 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 + + 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() + } + + /** The status of the account_holder that was created */ + 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 ACCEPTED = of("ACCEPTED") + + @JvmField val PENDING_REVIEW = of("PENDING_REVIEW") + + @JvmField val REJECTED = of("REJECTED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACCEPTED, + PENDING_REVIEW, + REJECTED, + } + + /** + * 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 { + ACCEPTED, + PENDING_REVIEW, + REJECTED, + /** 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) { + ACCEPTED -> Value.ACCEPTED + PENDING_REVIEW -> Value.PENDING_REVIEW + REJECTED -> Value.REJECTED + 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) { + ACCEPTED -> Known.ACCEPTED + PENDING_REVIEW -> Known.PENDING_REVIEW + REJECTED -> Known.REJECTED + else -> throw LithicInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return 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 AccountHolderVerificationWebhookEvent && + eventType == other.eventType && + token == other.token && + accountToken == other.accountToken && + created == other.created && + status == other.status && + statusReasons == other.statusReasons && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + eventType, + token, + accountToken, + created, + status, + statusReasons, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccountHolderVerificationWebhookEvent{eventType=$eventType, token=$token, accountToken=$accountToken, created=$created, status=$status, statusReasons=$statusReasons, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AsaRequestWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AsaRequestWebhookEvent.kt new file mode 100644 index 000000000..1aea2ef82 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AsaRequestWebhookEvent.kt @@ -0,0 +1,7316 @@ +// 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 + +/** The Auth Stream Access request payload that was sent to the ASA responder. */ +class AsaRequestWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val acquirerFee: JsonField, + private val amount: 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 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("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("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, + authorizationAmount, + avs, + card, + cardholderCurrency, + cashAmount, + created, + merchant, + merchantAmount, + merchantCurrency, + 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") + + /** + * 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). + */ + fun amount(): Long = amount.getRequired("amount") + + /** + * 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). + */ + 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") + + /** + * 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). + */ + 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") + + /** + * @throws LithicInvalidDataException if 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(): Merchant = merchant.getRequired("merchant") + + /** + * 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). + */ + 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). + */ + fun merchantCurrency(): String = merchantCurrency.getRequired("merchant_currency") + + /** + * 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). + */ + 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") + + /** + * 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). + */ + 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. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [authorizationAmount]. + * + * Unlike [authorizationAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @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. + */ + @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. + */ + @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. + */ + @JsonProperty("merchant_currency") + @ExcludeMissing + fun _merchantCurrency(): JsonField = merchantCurrency + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [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. + */ + @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 [AsaRequestWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .acquirerFee() + * .amount() + * .authorizationAmount() + * .avs() + * .card() + * .cardholderCurrency() + * .cashAmount() + * .created() + * .merchant() + * .merchantAmount() + * .merchantCurrency() + * .settledAmount() + * .status() + * .transactionInitiator() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaRequestWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var acquirerFee: JsonField? = null + private var amount: 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 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(asaRequestWebhookEvent: AsaRequestWebhookEvent) = apply { + token = asaRequestWebhookEvent.token + acquirerFee = asaRequestWebhookEvent.acquirerFee + amount = asaRequestWebhookEvent.amount + authorizationAmount = asaRequestWebhookEvent.authorizationAmount + avs = asaRequestWebhookEvent.avs + card = asaRequestWebhookEvent.card + cardholderCurrency = asaRequestWebhookEvent.cardholderCurrency + cashAmount = asaRequestWebhookEvent.cashAmount + created = asaRequestWebhookEvent.created + merchant = asaRequestWebhookEvent.merchant + merchantAmount = asaRequestWebhookEvent.merchantAmount + merchantCurrency = asaRequestWebhookEvent.merchantCurrency + settledAmount = asaRequestWebhookEvent.settledAmount + status = asaRequestWebhookEvent.status + transactionInitiator = asaRequestWebhookEvent.transactionInitiator + accountType = asaRequestWebhookEvent.accountType + cardholderAuthentication = asaRequestWebhookEvent.cardholderAuthentication + cashback = asaRequestWebhookEvent.cashback + conversionRate = asaRequestWebhookEvent.conversionRate + eventToken = asaRequestWebhookEvent.eventToken + fleetInfo = asaRequestWebhookEvent.fleetInfo + latestChallenge = asaRequestWebhookEvent.latestChallenge + network = asaRequestWebhookEvent.network + networkRiskScore = asaRequestWebhookEvent.networkRiskScore + networkSpecificData = asaRequestWebhookEvent.networkSpecificData + pos = asaRequestWebhookEvent.pos + tokenInfo = asaRequestWebhookEvent.tokenInfo + ttl = asaRequestWebhookEvent.ttl + additionalProperties = asaRequestWebhookEvent.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 } + + /** + * Authorization amount of the transaction (in cents), including any acquirer fees. The + * contents of this field are identical to `authorization_amount`. + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The 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. + */ + 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. + */ + 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 } + + /** 3-character alphabetic ISO 4217 code for cardholder's billing currency. */ + 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. + */ + 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 } + + fun merchant(merchant: Merchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed [Merchant] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchant(merchant: JsonField) = apply { this.merchant = merchant } + + /** + * 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. + */ + 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. + */ + fun merchantAmount(merchantAmount: JsonField) = apply { + this.merchantAmount = merchantAmount + } + + /** 3-character alphabetic ISO 4217 code for the local currency of the transaction. */ + 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. + */ + fun merchantCurrency(merchantCurrency: JsonField) = apply { + this.merchantCurrency = merchantCurrency + } + + /** + * Amount (in cents) of the transaction that has been settled, including any acquirer fees + */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** + * The 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 } + + /** + * 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. + */ + 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. + */ + 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 [AsaRequestWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .acquirerFee() + * .amount() + * .authorizationAmount() + * .avs() + * .card() + * .cardholderCurrency() + * .cashAmount() + * .created() + * .merchant() + * .merchantAmount() + * .merchantCurrency() + * .settledAmount() + * .status() + * .transactionInitiator() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AsaRequestWebhookEvent = + AsaRequestWebhookEvent( + checkRequired("token", token), + checkRequired("acquirerFee", acquirerFee), + checkRequired("amount", amount), + 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("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 + + fun validate(): AsaRequestWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + acquirerFee() + amount() + authorizationAmount() + avs().validate() + card().validate() + cardholderCurrency() + cashAmount() + created() + merchant().validate() + merchantAmount() + merchantCurrency() + 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) + + (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) + + (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) + + 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 + + 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 + + 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 hostname: 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("hostname") + @ExcludeMissing + hostname: 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, + hostname, + lastFour, + memo, + spendLimit, + spendLimitDuration, + state, + type, + mutableMapOf(), + ) + + /** + * Globally unique identifier for the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * Hostname of card’s locked merchant (will be empty if not applicable) + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hostname(): Optional = hostname.getOptional("hostname") + + /** + * Last four digits of the card number + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastFour(): Optional = lastFour.getOptional("last_four") + + /** + * Customizable name to identify the card. We recommend against using this field to store + * JSON data as it can cause unexpected behavior. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun memo(): Optional = memo.getOptional("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 (e.g. if the + * server responded with an unexpected value). + */ + fun spendLimit(): Optional = spendLimit.getOptional("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 (e.g. if the + * server responded with an unexpected value). + */ + fun spendLimitDuration(): Optional = + spendLimitDuration.getOptional("spend_limit_duration") + + /** + * @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") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [token]. + * + * 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 [hostname]. + * + * Unlike [hostname], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hostname") @ExcludeMissing fun _hostname(): JsonField = hostname + + /** + * 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]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AsaRequestCard]. */ + class Builder internal constructor() { + + private var token: JsonField = JsonMissing.of() + private var hostname: JsonField = JsonMissing.of() + private var lastFour: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() + private var spendLimit: JsonField = JsonMissing.of() + private var spendLimitDuration: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(asaRequestCard: AsaRequestCard) = apply { + token = asaRequestCard.token + hostname = asaRequestCard.hostname + 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 } + + /** Hostname of card’s locked merchant (will be empty if not applicable) */ + fun hostname(hostname: String) = hostname(JsonField.of(hostname)) + + /** + * Sets [Builder.hostname] to an arbitrary JSON value. + * + * You should usually call [Builder.hostname] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hostname(hostname: JsonField) = apply { this.hostname = hostname } + + /** 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. We recommend against using this field to + * store JSON data as it can cause unexpected behavior. + */ + 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. + */ + fun build(): AsaRequestCard = + AsaRequestCard( + token, + hostname, + lastFour, + memo, + spendLimit, + spendLimitDuration, + state, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AsaRequestCard = apply { + if (validated) { + return@apply + } + + token() + hostname() + lastFour() + memo() + spendLimit() + spendLimitDuration().ifPresent { it.validate() } + state().ifPresent { it.validate() } + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (if (hostname.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 + + 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 + + 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 + + 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 && + hostname == other.hostname && + 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, + hostname, + lastFour, + memo, + spendLimit, + spendLimitDuration, + state, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AsaRequestCard{token=$token, hostname=$hostname, lastFour=$lastFour, memo=$memo, spendLimit=$spendLimit, spendLimitDuration=$spendLimitDuration, state=$state, type=$type, 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 AsaRequestWebhookEvent && + token == other.token && + acquirerFee == other.acquirerFee && + amount == other.amount && + 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 && + 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, + authorizationAmount, + avs, + card, + cardholderCurrency, + cashAmount, + created, + merchant, + merchantAmount, + merchantCurrency, + 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() = + "AsaRequestWebhookEvent{token=$token, acquirerFee=$acquirerFee, amount=$amount, authorizationAmount=$authorizationAmount, avs=$avs, card=$card, cardholderCurrency=$cardholderCurrency, cashAmount=$cashAmount, created=$created, merchant=$merchant, merchantAmount=$merchantAmount, merchantCurrency=$merchantCurrency, 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/AuthRulesBacktestReportCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRulesBacktestReportCreatedWebhookEvent.kt new file mode 100644 index 000000000..558bc6b8d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRulesBacktestReportCreatedWebhookEvent.kt @@ -0,0 +1,441 @@ +// 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.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AuthRulesBacktestReportCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val backtestToken: JsonField, + private val results: JsonField, + private val simulationParameters: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("backtest_token") + @ExcludeMissing + backtestToken: JsonField = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField = JsonMissing.of(), + @JsonProperty("simulation_parameters") + @ExcludeMissing + simulationParameters: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this(backtestToken, results, simulationParameters, eventType, mutableMapOf()) + + fun toBacktestResults(): BacktestResults = + BacktestResults.builder() + .backtestToken(backtestToken) + .results(results) + .simulationParameters(simulationParameters) + .build() + + /** + * Auth Rule Backtest Token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun backtestToken(): String = backtestToken.getRequired("backtest_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): BacktestResults.Results = results.getRequired("results") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun simulationParameters(): BacktestResults.SimulationParameters = + simulationParameters.getRequired("simulation_parameters") + + /** + * 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 [backtestToken]. + * + * Unlike [backtestToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("backtest_token") + @ExcludeMissing + fun _backtestToken(): JsonField = backtestToken + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") + @ExcludeMissing + fun _results(): JsonField = results + + /** + * Returns the raw JSON value of [simulationParameters]. + * + * Unlike [simulationParameters], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("simulation_parameters") + @ExcludeMissing + fun _simulationParameters(): JsonField = + simulationParameters + + /** + * 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 + * [AuthRulesBacktestReportCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .backtestToken() + * .results() + * .simulationParameters() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuthRulesBacktestReportCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var backtestToken: JsonField? = null + private var results: JsonField? = null + private var simulationParameters: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + authRulesBacktestReportCreatedWebhookEvent: AuthRulesBacktestReportCreatedWebhookEvent + ) = apply { + backtestToken = authRulesBacktestReportCreatedWebhookEvent.backtestToken + results = authRulesBacktestReportCreatedWebhookEvent.results + simulationParameters = authRulesBacktestReportCreatedWebhookEvent.simulationParameters + eventType = authRulesBacktestReportCreatedWebhookEvent.eventType + additionalProperties = + authRulesBacktestReportCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Auth Rule Backtest Token */ + fun backtestToken(backtestToken: String) = backtestToken(JsonField.of(backtestToken)) + + /** + * Sets [Builder.backtestToken] to an arbitrary JSON value. + * + * You should usually call [Builder.backtestToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun backtestToken(backtestToken: JsonField) = apply { + this.backtestToken = backtestToken + } + + fun results(results: BacktestResults.Results) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed [BacktestResults.Results] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun results(results: JsonField) = apply { this.results = results } + + fun simulationParameters(simulationParameters: BacktestResults.SimulationParameters) = + simulationParameters(JsonField.of(simulationParameters)) + + /** + * Sets [Builder.simulationParameters] to an arbitrary JSON value. + * + * You should usually call [Builder.simulationParameters] with a well-typed + * [BacktestResults.SimulationParameters] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun simulationParameters( + simulationParameters: JsonField + ) = apply { this.simulationParameters = simulationParameters } + + /** 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 [AuthRulesBacktestReportCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .backtestToken() + * .results() + * .simulationParameters() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AuthRulesBacktestReportCreatedWebhookEvent = + AuthRulesBacktestReportCreatedWebhookEvent( + checkRequired("backtestToken", backtestToken), + checkRequired("results", results), + checkRequired("simulationParameters", simulationParameters), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AuthRulesBacktestReportCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + backtestToken() + results().validate() + simulationParameters().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 = + (if (backtestToken.asKnown().isPresent) 1 else 0) + + (results.asKnown().getOrNull()?.validity() ?: 0) + + (simulationParameters.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 AUTH_RULES_BACKTEST_REPORT_CREATED = of("auth_rules.backtest_report.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + AUTH_RULES_BACKTEST_REPORT_CREATED + } + + /** + * 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 { + AUTH_RULES_BACKTEST_REPORT_CREATED, + /** + * 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) { + AUTH_RULES_BACKTEST_REPORT_CREATED -> Value.AUTH_RULES_BACKTEST_REPORT_CREATED + 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) { + AUTH_RULES_BACKTEST_REPORT_CREATED -> Known.AUTH_RULES_BACKTEST_REPORT_CREATED + 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 + + 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 AuthRulesBacktestReportCreatedWebhookEvent && + backtestToken == other.backtestToken && + results == other.results && + simulationParameters == other.simulationParameters && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(backtestToken, results, simulationParameters, eventType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthRulesBacktestReportCreatedWebhookEvent{backtestToken=$backtestToken, results=$results, simulationParameters=$simulationParameters, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceUpdatedWebhookEvent.kt new file mode 100644 index 000000000..70e8dbd4c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BalanceUpdatedWebhookEvent.kt @@ -0,0 +1,356 @@ +// 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.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class BalanceUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") + @ExcludeMissing + data: JsonField> = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this(data, eventType, 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 data(): List = data.getRequired("data") + + /** + * 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 [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [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 [BalanceUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .data() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BalanceUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(balanceUpdatedWebhookEvent: BalanceUpdatedWebhookEvent) = apply { + data = balanceUpdatedWebhookEvent.data.map { it.toMutableList() } + eventType = balanceUpdatedWebhookEvent.eventType + additionalProperties = balanceUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [FinancialAccountBalance] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: FinancialAccountBalance) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** 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 [BalanceUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BalanceUpdatedWebhookEvent = + BalanceUpdatedWebhookEvent( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BalanceUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + data().forEach { it.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 = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 BALANCE_UPDATED = of("balance.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + BALANCE_UPDATED + } + + /** + * 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 { + BALANCE_UPDATED, + /** + * 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) { + BALANCE_UPDATED -> Value.BALANCE_UPDATED + 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) { + BALANCE_UPDATED -> Known.BALANCE_UPDATED + 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 + + 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 BalanceUpdatedWebhookEvent && + data == other.data && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, eventType, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BalanceUpdatedWebhookEvent{data=$data, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferTransactionCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferTransactionCreatedWebhookEvent.kt new file mode 100644 index 000000000..402c6edc5 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferTransactionCreatedWebhookEvent.kt @@ -0,0 +1,1080 @@ +// 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 + +/** Book transfer transaction */ +class BookTransferTransactionCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val fromFinancialAccountToken: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val toFinancialAccountToken: JsonField, + private val updated: JsonField, + private val externalId: JsonField, + private val externalResource: JsonField, + private val transactionSeries: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("from_financial_account_token") + @ExcludeMissing + fromFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("to_financial_account_token") + @ExcludeMissing + toFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + @JsonProperty("external_resource") + @ExcludeMissing + externalResource: JsonField = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + events, + family, + fromFinancialAccountToken, + pendingAmount, + result, + settledAmount, + status, + toFinancialAccountToken, + updated, + externalId, + externalResource, + transactionSeries, + eventType, + mutableMapOf(), + ) + + fun toBookTransferResponse(): BookTransferResponse = + BookTransferResponse.builder() + .token(token) + .category(category) + .created(created) + .currency(currency) + .events(events) + .family(family) + .fromFinancialAccountToken(fromFinancialAccountToken) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .status(status) + .toFinancialAccountToken(toFinancialAccountToken) + .updated(updated) + .externalId(externalId) + .externalResource(externalResource) + .transactionSeries(transactionSeries) + .build() + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): BookTransferResponse.BookTransferCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * 3-character alphabetic ISO 4217 code for the settling 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). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * A list of all financial events that have modified this transfer + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * TRANSFER - Book Transfer 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 family(): BookTransferResponse.Family = family.getRequired("family") + + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fromFinancialAccountToken(): String = + fromFinancialAccountToken.getRequired("from_financial_account_token") + + /** + * Pending amount of the transaction in the currency's smallest unit (e.g., cents), including + * any acquirer fees. + * + * The value of this field will go to zero over time once the financial transaction is settled. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): BookTransferResponse.TransactionResult = result.getRequired("result") + + /** + * Amount of the transaction that has been settled in the currency's smallest unit (e.g., cents) + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): BookTransferResponse.TransactionStatus = status.getRequired("status") + + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun toFinancialAccountToken(): String = + toFinancialAccountToken.getRequired("to_financial_account_token") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * External ID defined by the customer + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * External resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResource(): Optional = + externalResource.getOptional("external_resource") + + /** + * A series of transactions that are grouped together + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [fromFinancialAccountToken]. + * + * Unlike [fromFinancialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("from_financial_account_token") + @ExcludeMissing + fun _fromFinancialAccountToken(): JsonField = fromFinancialAccountToken + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [toFinancialAccountToken]. + * + * Unlike [toFinancialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("to_financial_account_token") + @ExcludeMissing + fun _toFinancialAccountToken(): JsonField = toFinancialAccountToken + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") @ExcludeMissing fun _externalId(): JsonField = externalId + + /** + * Returns the raw JSON value of [externalResource]. + * + * Unlike [externalResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource") + @ExcludeMissing + fun _externalResource(): JsonField = externalResource + + /** + * Returns the raw JSON value of [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = transactionSeries + + /** + * 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 + * [BookTransferTransactionCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BookTransferTransactionCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var fromFinancialAccountToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var toFinancialAccountToken: JsonField? = null + private var updated: JsonField? = null + private var externalId: JsonField = JsonMissing.of() + private var externalResource: JsonField = JsonMissing.of() + private var transactionSeries: JsonField = + JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + bookTransferTransactionCreatedWebhookEvent: BookTransferTransactionCreatedWebhookEvent + ) = apply { + token = bookTransferTransactionCreatedWebhookEvent.token + category = bookTransferTransactionCreatedWebhookEvent.category + created = bookTransferTransactionCreatedWebhookEvent.created + currency = bookTransferTransactionCreatedWebhookEvent.currency + events = bookTransferTransactionCreatedWebhookEvent.events.map { it.toMutableList() } + family = bookTransferTransactionCreatedWebhookEvent.family + fromFinancialAccountToken = + bookTransferTransactionCreatedWebhookEvent.fromFinancialAccountToken + pendingAmount = bookTransferTransactionCreatedWebhookEvent.pendingAmount + result = bookTransferTransactionCreatedWebhookEvent.result + settledAmount = bookTransferTransactionCreatedWebhookEvent.settledAmount + status = bookTransferTransactionCreatedWebhookEvent.status + toFinancialAccountToken = + bookTransferTransactionCreatedWebhookEvent.toFinancialAccountToken + updated = bookTransferTransactionCreatedWebhookEvent.updated + externalId = bookTransferTransactionCreatedWebhookEvent.externalId + externalResource = bookTransferTransactionCreatedWebhookEvent.externalResource + transactionSeries = bookTransferTransactionCreatedWebhookEvent.transactionSeries + eventType = bookTransferTransactionCreatedWebhookEvent.eventType + additionalProperties = + bookTransferTransactionCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun category(category: BookTransferResponse.BookTransferCategory) = + category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [BookTransferResponse.BookTransferCategory] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun category(category: JsonField) = apply { + this.category = category + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** 3-character alphabetic ISO 4217 code for the settling currency of the transaction */ + 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 } + + /** A list of all financial events that have modified this transfer */ + fun events(events: List) = + events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [BookTransferResponse.BookTransferEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: BookTransferResponse.BookTransferEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** TRANSFER - Book Transfer Transaction */ + fun family(family: BookTransferResponse.Family) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [BookTransferResponse.Family] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case + */ + fun fromFinancialAccountToken(fromFinancialAccountToken: String) = + fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) + + /** + * Sets [Builder.fromFinancialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.fromFinancialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fromFinancialAccountToken(fromFinancialAccountToken: JsonField) = apply { + this.fromFinancialAccountToken = fromFinancialAccountToken + } + + /** + * Pending amount of the transaction in the currency's smallest unit (e.g., cents), + * including any acquirer fees. + * + * The value of this field will go to zero over time once the financial transaction is + * settled. + */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: BookTransferResponse.TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [BookTransferResponse.TransactionResult] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + /** + * Amount of the transaction that has been settled in the currency's smallest unit (e.g., + * cents) + */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** The status of the transaction */ + fun status(status: BookTransferResponse.TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [BookTransferResponse.TransactionStatus] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case + */ + fun toFinancialAccountToken(toFinancialAccountToken: String) = + toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) + + /** + * Sets [Builder.toFinancialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.toFinancialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun toFinancialAccountToken(toFinancialAccountToken: JsonField) = apply { + this.toFinancialAccountToken = toFinancialAccountToken + } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** External ID defined by the customer */ + fun externalId(externalId: String?) = externalId(JsonField.ofNullable(externalId)) + + /** Alias for calling [Builder.externalId] with `externalId.orElse(null)`. */ + fun externalId(externalId: Optional) = externalId(externalId.getOrNull()) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) + + /** Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) + + /** + * Sets [Builder.externalResource] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResource] with a well-typed [ExternalResource] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalResource(externalResource: JsonField) = apply { + this.externalResource = externalResource + } + + /** A series of transactions that are grouped together */ + fun transactionSeries(transactionSeries: BookTransferResponse.TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed + * [BookTransferResponse.TransactionSeries] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun transactionSeries( + transactionSeries: JsonField + ) = apply { this.transactionSeries = transactionSeries } + + /** 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 [BookTransferTransactionCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BookTransferTransactionCreatedWebhookEvent = + BookTransferTransactionCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("fromFinancialAccountToken", fromFinancialAccountToken), + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("toFinancialAccountToken", toFinancialAccountToken), + checkRequired("updated", updated), + externalId, + externalResource, + transactionSeries, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BookTransferTransactionCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + events().forEach { it.validate() } + family().validate() + fromFinancialAccountToken() + pendingAmount() + result().validate() + settledAmount() + status().validate() + toFinancialAccountToken() + updated() + externalId() + externalResource().ifPresent { it.validate() } + transactionSeries().ifPresent { it.validate() } + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (fromFinancialAccountToken.asKnown().isPresent) 1 else 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (toFinancialAccountToken.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (externalResource.asKnown().getOrNull()?.validity() ?: 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 BOOK_TRANSFER_TRANSACTION_CREATED = of("book_transfer_transaction.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + BOOK_TRANSFER_TRANSACTION_CREATED + } + + /** + * 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 { + BOOK_TRANSFER_TRANSACTION_CREATED, + /** + * 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) { + BOOK_TRANSFER_TRANSACTION_CREATED -> Value.BOOK_TRANSFER_TRANSACTION_CREATED + 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) { + BOOK_TRANSFER_TRANSACTION_CREATED -> Known.BOOK_TRANSFER_TRANSACTION_CREATED + 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 + + 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 BookTransferTransactionCreatedWebhookEvent && + token == other.token && + category == other.category && + created == other.created && + currency == other.currency && + events == other.events && + family == other.family && + fromFinancialAccountToken == other.fromFinancialAccountToken && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + status == other.status && + toFinancialAccountToken == other.toFinancialAccountToken && + updated == other.updated && + externalId == other.externalId && + externalResource == other.externalResource && + transactionSeries == other.transactionSeries && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + currency, + events, + family, + fromFinancialAccountToken, + pendingAmount, + result, + settledAmount, + status, + toFinancialAccountToken, + updated, + externalId, + externalResource, + transactionSeries, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BookTransferTransactionCreatedWebhookEvent{token=$token, category=$category, created=$created, currency=$currency, events=$events, family=$family, fromFinancialAccountToken=$fromFinancialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, toFinancialAccountToken=$toFinancialAccountToken, updated=$updated, externalId=$externalId, externalResource=$externalResource, transactionSeries=$transactionSeries, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferTransactionUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferTransactionUpdatedWebhookEvent.kt new file mode 100644 index 000000000..9f582acff --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BookTransferTransactionUpdatedWebhookEvent.kt @@ -0,0 +1,1080 @@ +// 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 + +/** Book transfer transaction */ +class BookTransferTransactionUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val fromFinancialAccountToken: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val toFinancialAccountToken: JsonField, + private val updated: JsonField, + private val externalId: JsonField, + private val externalResource: JsonField, + private val transactionSeries: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("from_financial_account_token") + @ExcludeMissing + fromFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("to_financial_account_token") + @ExcludeMissing + toFinancialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + @JsonProperty("external_resource") + @ExcludeMissing + externalResource: JsonField = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + events, + family, + fromFinancialAccountToken, + pendingAmount, + result, + settledAmount, + status, + toFinancialAccountToken, + updated, + externalId, + externalResource, + transactionSeries, + eventType, + mutableMapOf(), + ) + + fun toBookTransferResponse(): BookTransferResponse = + BookTransferResponse.builder() + .token(token) + .category(category) + .created(created) + .currency(currency) + .events(events) + .family(family) + .fromFinancialAccountToken(fromFinancialAccountToken) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .status(status) + .toFinancialAccountToken(toFinancialAccountToken) + .updated(updated) + .externalId(externalId) + .externalResource(externalResource) + .transactionSeries(transactionSeries) + .build() + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): BookTransferResponse.BookTransferCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * 3-character alphabetic ISO 4217 code for the settling 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). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * A list of all financial events that have modified this transfer + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * TRANSFER - Book Transfer 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 family(): BookTransferResponse.Family = family.getRequired("family") + + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fromFinancialAccountToken(): String = + fromFinancialAccountToken.getRequired("from_financial_account_token") + + /** + * Pending amount of the transaction in the currency's smallest unit (e.g., cents), including + * any acquirer fees. + * + * The value of this field will go to zero over time once the financial transaction is settled. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): BookTransferResponse.TransactionResult = result.getRequired("result") + + /** + * Amount of the transaction that has been settled in the currency's smallest unit (e.g., cents) + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): BookTransferResponse.TransactionStatus = status.getRequired("status") + + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun toFinancialAccountToken(): String = + toFinancialAccountToken.getRequired("to_financial_account_token") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * External ID defined by the customer + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * External resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResource(): Optional = + externalResource.getOptional("external_resource") + + /** + * A series of transactions that are grouped together + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [fromFinancialAccountToken]. + * + * Unlike [fromFinancialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("from_financial_account_token") + @ExcludeMissing + fun _fromFinancialAccountToken(): JsonField = fromFinancialAccountToken + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [toFinancialAccountToken]. + * + * Unlike [toFinancialAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("to_financial_account_token") + @ExcludeMissing + fun _toFinancialAccountToken(): JsonField = toFinancialAccountToken + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") @ExcludeMissing fun _externalId(): JsonField = externalId + + /** + * Returns the raw JSON value of [externalResource]. + * + * Unlike [externalResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource") + @ExcludeMissing + fun _externalResource(): JsonField = externalResource + + /** + * Returns the raw JSON value of [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = transactionSeries + + /** + * 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 + * [BookTransferTransactionUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BookTransferTransactionUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var fromFinancialAccountToken: JsonField? = null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var toFinancialAccountToken: JsonField? = null + private var updated: JsonField? = null + private var externalId: JsonField = JsonMissing.of() + private var externalResource: JsonField = JsonMissing.of() + private var transactionSeries: JsonField = + JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + bookTransferTransactionUpdatedWebhookEvent: BookTransferTransactionUpdatedWebhookEvent + ) = apply { + token = bookTransferTransactionUpdatedWebhookEvent.token + category = bookTransferTransactionUpdatedWebhookEvent.category + created = bookTransferTransactionUpdatedWebhookEvent.created + currency = bookTransferTransactionUpdatedWebhookEvent.currency + events = bookTransferTransactionUpdatedWebhookEvent.events.map { it.toMutableList() } + family = bookTransferTransactionUpdatedWebhookEvent.family + fromFinancialAccountToken = + bookTransferTransactionUpdatedWebhookEvent.fromFinancialAccountToken + pendingAmount = bookTransferTransactionUpdatedWebhookEvent.pendingAmount + result = bookTransferTransactionUpdatedWebhookEvent.result + settledAmount = bookTransferTransactionUpdatedWebhookEvent.settledAmount + status = bookTransferTransactionUpdatedWebhookEvent.status + toFinancialAccountToken = + bookTransferTransactionUpdatedWebhookEvent.toFinancialAccountToken + updated = bookTransferTransactionUpdatedWebhookEvent.updated + externalId = bookTransferTransactionUpdatedWebhookEvent.externalId + externalResource = bookTransferTransactionUpdatedWebhookEvent.externalResource + transactionSeries = bookTransferTransactionUpdatedWebhookEvent.transactionSeries + eventType = bookTransferTransactionUpdatedWebhookEvent.eventType + additionalProperties = + bookTransferTransactionUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun category(category: BookTransferResponse.BookTransferCategory) = + category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [BookTransferResponse.BookTransferCategory] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun category(category: JsonField) = apply { + this.category = category + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** 3-character alphabetic ISO 4217 code for the settling currency of the transaction */ + 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 } + + /** A list of all financial events that have modified this transfer */ + fun events(events: List) = + events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [BookTransferResponse.BookTransferEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: BookTransferResponse.BookTransferEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** TRANSFER - Book Transfer Transaction */ + fun family(family: BookTransferResponse.Family) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [BookTransferResponse.Family] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** + * Globally unique identifier for the financial account or card that will send the funds. + * Accepted type dependent on the program's use case + */ + fun fromFinancialAccountToken(fromFinancialAccountToken: String) = + fromFinancialAccountToken(JsonField.of(fromFinancialAccountToken)) + + /** + * Sets [Builder.fromFinancialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.fromFinancialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fromFinancialAccountToken(fromFinancialAccountToken: JsonField) = apply { + this.fromFinancialAccountToken = fromFinancialAccountToken + } + + /** + * Pending amount of the transaction in the currency's smallest unit (e.g., cents), + * including any acquirer fees. + * + * The value of this field will go to zero over time once the financial transaction is + * settled. + */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: BookTransferResponse.TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [BookTransferResponse.TransactionResult] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + /** + * Amount of the transaction that has been settled in the currency's smallest unit (e.g., + * cents) + */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** The status of the transaction */ + fun status(status: BookTransferResponse.TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [BookTransferResponse.TransactionStatus] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + /** + * Globally unique identifier for the financial account or card that will receive the funds. + * Accepted type dependent on the program's use case + */ + fun toFinancialAccountToken(toFinancialAccountToken: String) = + toFinancialAccountToken(JsonField.of(toFinancialAccountToken)) + + /** + * Sets [Builder.toFinancialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.toFinancialAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun toFinancialAccountToken(toFinancialAccountToken: JsonField) = apply { + this.toFinancialAccountToken = toFinancialAccountToken + } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** External ID defined by the customer */ + fun externalId(externalId: String?) = externalId(JsonField.ofNullable(externalId)) + + /** Alias for calling [Builder.externalId] with `externalId.orElse(null)`. */ + fun externalId(externalId: Optional) = externalId(externalId.getOrNull()) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) + + /** Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) + + /** + * Sets [Builder.externalResource] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResource] with a well-typed [ExternalResource] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalResource(externalResource: JsonField) = apply { + this.externalResource = externalResource + } + + /** A series of transactions that are grouped together */ + fun transactionSeries(transactionSeries: BookTransferResponse.TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed + * [BookTransferResponse.TransactionSeries] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun transactionSeries( + transactionSeries: JsonField + ) = apply { this.transactionSeries = transactionSeries } + + /** 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 [BookTransferTransactionUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .events() + * .family() + * .fromFinancialAccountToken() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .toFinancialAccountToken() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BookTransferTransactionUpdatedWebhookEvent = + BookTransferTransactionUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("fromFinancialAccountToken", fromFinancialAccountToken), + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("toFinancialAccountToken", toFinancialAccountToken), + checkRequired("updated", updated), + externalId, + externalResource, + transactionSeries, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BookTransferTransactionUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + events().forEach { it.validate() } + family().validate() + fromFinancialAccountToken() + pendingAmount() + result().validate() + settledAmount() + status().validate() + toFinancialAccountToken() + updated() + externalId() + externalResource().ifPresent { it.validate() } + transactionSeries().ifPresent { it.validate() } + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (fromFinancialAccountToken.asKnown().isPresent) 1 else 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (toFinancialAccountToken.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (externalResource.asKnown().getOrNull()?.validity() ?: 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 BOOK_TRANSFER_TRANSACTION_UPDATED = of("book_transfer_transaction.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + BOOK_TRANSFER_TRANSACTION_UPDATED + } + + /** + * 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 { + BOOK_TRANSFER_TRANSACTION_UPDATED, + /** + * 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) { + BOOK_TRANSFER_TRANSACTION_UPDATED -> Value.BOOK_TRANSFER_TRANSACTION_UPDATED + 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) { + BOOK_TRANSFER_TRANSACTION_UPDATED -> Known.BOOK_TRANSFER_TRANSACTION_UPDATED + 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 + + 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 BookTransferTransactionUpdatedWebhookEvent && + token == other.token && + category == other.category && + created == other.created && + currency == other.currency && + events == other.events && + family == other.family && + fromFinancialAccountToken == other.fromFinancialAccountToken && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + status == other.status && + toFinancialAccountToken == other.toFinancialAccountToken && + updated == other.updated && + externalId == other.externalId && + externalResource == other.externalResource && + transactionSeries == other.transactionSeries && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + currency, + events, + family, + fromFinancialAccountToken, + pendingAmount, + result, + settledAmount, + status, + toFinancialAccountToken, + updated, + externalId, + externalResource, + transactionSeries, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BookTransferTransactionUpdatedWebhookEvent{token=$token, category=$category, created=$created, currency=$currency, events=$events, family=$family, fromFinancialAccountToken=$fromFinancialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, toFinancialAccountToken=$toFinancialAccountToken, updated=$updated, externalId=$externalId, externalResource=$externalResource, transactionSeries=$transactionSeries, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardConvertedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardConvertedWebhookEvent.kt new file mode 100644 index 000000000..f22f05feb --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardConvertedWebhookEvent.kt @@ -0,0 +1,339 @@ +// 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.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CardConvertedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val cardToken: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this(cardToken, eventType, mutableMapOf()) + + /** + * The token of the card that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * 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 [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [CardConvertedWebhookEvent]. + * + * The following fields are required: + * ```java + * .cardToken() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardConvertedWebhookEvent]. */ + class Builder internal constructor() { + + private var cardToken: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardConvertedWebhookEvent: CardConvertedWebhookEvent) = apply { + cardToken = cardConvertedWebhookEvent.cardToken + eventType = cardConvertedWebhookEvent.eventType + additionalProperties = cardConvertedWebhookEvent.additionalProperties.toMutableMap() + } + + /** The token of the card that was created. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** 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 [CardConvertedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardToken() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardConvertedWebhookEvent = + CardConvertedWebhookEvent( + checkRequired("cardToken", cardToken), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardConvertedWebhookEvent = apply { + if (validated) { + return@apply + } + + cardToken() + 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 = + (if (cardToken.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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_CONVERTED = of("card.converted") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_CONVERTED + } + + /** + * 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_CONVERTED, + /** + * 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_CONVERTED -> Value.CARD_CONVERTED + 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_CONVERTED -> Known.CARD_CONVERTED + 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 + + 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 CardConvertedWebhookEvent && + cardToken == other.cardToken && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(cardToken, eventType, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardConvertedWebhookEvent{cardToken=$cardToken, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreatedWebhookEvent.kt new file mode 100644 index 000000000..f811cd601 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardCreatedWebhookEvent.kt @@ -0,0 +1,388 @@ +// 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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CardCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val cardToken: JsonField, + private val eventType: JsonField, + private val replacementFor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("replacement_for") + @ExcludeMissing + replacementFor: JsonField = JsonMissing.of(), + ) : this(cardToken, eventType, replacementFor, mutableMapOf()) + + /** + * The token of the card that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * 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") + + /** + * The token of the card that was replaced, if the new card is a replacement card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun replacementFor(): Optional = replacementFor.getOptional("replacement_for") + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [replacementFor]. + * + * Unlike [replacementFor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("replacement_for") + @ExcludeMissing + fun _replacementFor(): JsonField = replacementFor + + @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 [CardCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .cardToken() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var cardToken: JsonField? = null + private var eventType: JsonField? = null + private var replacementFor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardCreatedWebhookEvent: CardCreatedWebhookEvent) = apply { + cardToken = cardCreatedWebhookEvent.cardToken + eventType = cardCreatedWebhookEvent.eventType + replacementFor = cardCreatedWebhookEvent.replacementFor + additionalProperties = cardCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** The token of the card that was created. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** 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 } + + /** The token of the card that was replaced, if the new card is a replacement card. */ + fun replacementFor(replacementFor: String?) = + replacementFor(JsonField.ofNullable(replacementFor)) + + /** Alias for calling [Builder.replacementFor] with `replacementFor.orElse(null)`. */ + fun replacementFor(replacementFor: Optional) = + replacementFor(replacementFor.getOrNull()) + + /** + * Sets [Builder.replacementFor] to an arbitrary JSON value. + * + * You should usually call [Builder.replacementFor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun replacementFor(replacementFor: JsonField) = apply { + this.replacementFor = replacementFor + } + + 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 [CardCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardToken() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardCreatedWebhookEvent = + CardCreatedWebhookEvent( + checkRequired("cardToken", cardToken), + checkRequired("eventType", eventType), + replacementFor, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + cardToken() + eventType().validate() + replacementFor() + 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 (cardToken.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (replacementFor.asKnown().isPresent) 1 else 0) + + /** 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_CREATED = of("card.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_CREATED + } + + /** + * 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_CREATED, + /** + * 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_CREATED -> Value.CARD_CREATED + 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_CREATED -> Known.CARD_CREATED + 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 + + 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 CardCreatedWebhookEvent && + cardToken == other.cardToken && + eventType == other.eventType && + replacementFor == other.replacementFor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(cardToken, eventType, replacementFor, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardCreatedWebhookEvent{cardToken=$cardToken, eventType=$eventType, replacementFor=$replacementFor, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardReissuedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardReissuedWebhookEvent.kt new file mode 100644 index 000000000..db0ad80b1 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardReissuedWebhookEvent.kt @@ -0,0 +1,338 @@ +// 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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CardReissuedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val eventType: JsonField, + private val cardToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + ) : this(eventType, cardToken, mutableMapOf()) + + /** + * 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") + + /** + * The token of the card that was reissued. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardToken(): Optional = cardToken.getOptional("card_token") + + /** + * 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 [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + @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 [CardReissuedWebhookEvent]. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardReissuedWebhookEvent]. */ + class Builder internal constructor() { + + private var eventType: JsonField? = null + private var cardToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardReissuedWebhookEvent: CardReissuedWebhookEvent) = apply { + eventType = cardReissuedWebhookEvent.eventType + cardToken = cardReissuedWebhookEvent.cardToken + additionalProperties = cardReissuedWebhookEvent.additionalProperties.toMutableMap() + } + + /** 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 } + + /** The token of the card that was reissued. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + fun 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 [CardReissuedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardReissuedWebhookEvent = + CardReissuedWebhookEvent( + checkRequired("eventType", eventType), + cardToken, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardReissuedWebhookEvent = apply { + if (validated) { + return@apply + } + + eventType().validate() + cardToken() + 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 = + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + /** 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_REISSUED = of("card.reissued") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_REISSUED + } + + /** + * 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_REISSUED, + /** + * 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_REISSUED -> Value.CARD_REISSUED + 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_REISSUED -> Known.CARD_REISSUED + 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 + + 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 CardReissuedWebhookEvent && + eventType == other.eventType && + cardToken == other.cardToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(eventType, cardToken, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardReissuedWebhookEvent{eventType=$eventType, cardToken=$cardToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardRenewedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardRenewedWebhookEvent.kt new file mode 100644 index 000000000..03834f563 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardRenewedWebhookEvent.kt @@ -0,0 +1,509 @@ +// 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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CardRenewedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val eventType: JsonField, + private val cardToken: JsonField, + private val expMonth: JsonField, + private val expYear: JsonField, + private val previousExpMonth: JsonField, + private val previousExpYear: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("exp_month") @ExcludeMissing expMonth: JsonField = JsonMissing.of(), + @JsonProperty("exp_year") @ExcludeMissing expYear: JsonField = JsonMissing.of(), + @JsonProperty("previous_exp_month") + @ExcludeMissing + previousExpMonth: JsonField = JsonMissing.of(), + @JsonProperty("previous_exp_year") + @ExcludeMissing + previousExpYear: JsonField = JsonMissing.of(), + ) : this( + eventType, + cardToken, + expMonth, + expYear, + previousExpMonth, + previousExpYear, + mutableMapOf(), + ) + + /** + * 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") + + /** + * The token of the card that was renewed. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardToken(): Optional = cardToken.getOptional("card_token") + + /** + * The new expiration month of the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expMonth(): Optional = expMonth.getOptional("exp_month") + + /** + * The new expiration year of the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expYear(): Optional = expYear.getOptional("exp_year") + + /** + * The previous expiration month of the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previousExpMonth(): Optional = previousExpMonth.getOptional("previous_exp_month") + + /** + * The previous expiration year of the card. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previousExpYear(): Optional = previousExpYear.getOptional("previous_exp_year") + + /** + * 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 [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [expMonth]. + * + * Unlike [expMonth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exp_month") @ExcludeMissing fun _expMonth(): JsonField = expMonth + + /** + * Returns the raw JSON value of [expYear]. + * + * Unlike [expYear], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("exp_year") @ExcludeMissing fun _expYear(): JsonField = expYear + + /** + * Returns the raw JSON value of [previousExpMonth]. + * + * Unlike [previousExpMonth], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("previous_exp_month") + @ExcludeMissing + fun _previousExpMonth(): JsonField = previousExpMonth + + /** + * Returns the raw JSON value of [previousExpYear]. + * + * Unlike [previousExpYear], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("previous_exp_year") + @ExcludeMissing + fun _previousExpYear(): JsonField = previousExpYear + + @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 [CardRenewedWebhookEvent]. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardRenewedWebhookEvent]. */ + class Builder internal constructor() { + + private var eventType: JsonField? = null + private var cardToken: JsonField = JsonMissing.of() + private var expMonth: JsonField = JsonMissing.of() + private var expYear: JsonField = JsonMissing.of() + private var previousExpMonth: JsonField = JsonMissing.of() + private var previousExpYear: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardRenewedWebhookEvent: CardRenewedWebhookEvent) = apply { + eventType = cardRenewedWebhookEvent.eventType + cardToken = cardRenewedWebhookEvent.cardToken + expMonth = cardRenewedWebhookEvent.expMonth + expYear = cardRenewedWebhookEvent.expYear + previousExpMonth = cardRenewedWebhookEvent.previousExpMonth + previousExpYear = cardRenewedWebhookEvent.previousExpYear + additionalProperties = cardRenewedWebhookEvent.additionalProperties.toMutableMap() + } + + /** 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 } + + /** The token of the card that was renewed. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** The new expiration month of the card. */ + fun expMonth(expMonth: String) = expMonth(JsonField.of(expMonth)) + + /** + * Sets [Builder.expMonth] to an arbitrary JSON value. + * + * You should usually call [Builder.expMonth] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expMonth(expMonth: JsonField) = apply { this.expMonth = expMonth } + + /** The new expiration year of the card. */ + fun expYear(expYear: String) = expYear(JsonField.of(expYear)) + + /** + * Sets [Builder.expYear] to an arbitrary JSON value. + * + * You should usually call [Builder.expYear] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expYear(expYear: JsonField) = apply { this.expYear = expYear } + + /** The previous expiration month of the card. */ + fun previousExpMonth(previousExpMonth: String) = + previousExpMonth(JsonField.of(previousExpMonth)) + + /** + * Sets [Builder.previousExpMonth] to an arbitrary JSON value. + * + * You should usually call [Builder.previousExpMonth] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun previousExpMonth(previousExpMonth: JsonField) = apply { + this.previousExpMonth = previousExpMonth + } + + /** The previous expiration year of the card. */ + fun previousExpYear(previousExpYear: String) = + previousExpYear(JsonField.of(previousExpYear)) + + /** + * Sets [Builder.previousExpYear] to an arbitrary JSON value. + * + * You should usually call [Builder.previousExpYear] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun previousExpYear(previousExpYear: JsonField) = apply { + this.previousExpYear = previousExpYear + } + + 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 [CardRenewedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardRenewedWebhookEvent = + CardRenewedWebhookEvent( + checkRequired("eventType", eventType), + cardToken, + expMonth, + expYear, + previousExpMonth, + previousExpYear, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardRenewedWebhookEvent = apply { + if (validated) { + return@apply + } + + eventType().validate() + cardToken() + expMonth() + expYear() + previousExpMonth() + previousExpYear() + 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 = + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (expMonth.asKnown().isPresent) 1 else 0) + + (if (expYear.asKnown().isPresent) 1 else 0) + + (if (previousExpMonth.asKnown().isPresent) 1 else 0) + + (if (previousExpYear.asKnown().isPresent) 1 else 0) + + /** 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_RENEWED = of("card.renewed") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_RENEWED + } + + /** + * 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_RENEWED, + /** + * 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_RENEWED -> Value.CARD_RENEWED + 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_RENEWED -> Known.CARD_RENEWED + 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 + + 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 CardRenewedWebhookEvent && + eventType == other.eventType && + cardToken == other.cardToken && + expMonth == other.expMonth && + expYear == other.expYear && + previousExpMonth == other.previousExpMonth && + previousExpYear == other.previousExpYear && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + eventType, + cardToken, + expMonth, + expYear, + previousExpMonth, + previousExpYear, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardRenewedWebhookEvent{eventType=$eventType, cardToken=$cardToken, expMonth=$expMonth, expYear=$expYear, previousExpMonth=$previousExpMonth, previousExpYear=$previousExpYear, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardShippedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardShippedWebhookEvent.kt new file mode 100644 index 000000000..3cc66baac --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardShippedWebhookEvent.kt @@ -0,0 +1,677 @@ +// 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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CardShippedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val bulkOrderToken: JsonField, + private val cardToken: JsonField, + private val eventType: JsonField, + private val shippingMethod: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("bulk_order_token") + @ExcludeMissing + bulkOrderToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("shipping_method") + @ExcludeMissing + shippingMethod: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this(bulkOrderToken, cardToken, eventType, shippingMethod, trackingNumber, mutableMapOf()) + + /** + * The token of the bulk order associated with this card shipment, if applicable. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bulkOrderToken(): Optional = bulkOrderToken.getOptional("bulk_order_token") + + /** + * The token of the card that was shipped. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * 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") + + /** + * The specific shipping method used to ship 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 shippingMethod(): ShippingMethod = shippingMethod.getRequired("shipping_method") + + /** + * The tracking number of the shipment. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun trackingNumber(): Optional = trackingNumber.getOptional("tracking_number") + + /** + * Returns the raw JSON value of [bulkOrderToken]. + * + * Unlike [bulkOrderToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bulk_order_token") + @ExcludeMissing + fun _bulkOrderToken(): JsonField = bulkOrderToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [shippingMethod]. + * + * Unlike [shippingMethod], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shipping_method") + @ExcludeMissing + fun _shippingMethod(): JsonField = shippingMethod + + /** + * Returns the raw JSON value of [trackingNumber]. + * + * Unlike [trackingNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tracking_number") + @ExcludeMissing + fun _trackingNumber(): JsonField = trackingNumber + + @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 [CardShippedWebhookEvent]. + * + * The following fields are required: + * ```java + * .bulkOrderToken() + * .cardToken() + * .eventType() + * .shippingMethod() + * .trackingNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardShippedWebhookEvent]. */ + class Builder internal constructor() { + + private var bulkOrderToken: JsonField? = null + private var cardToken: JsonField? = null + private var eventType: JsonField? = null + private var shippingMethod: JsonField? = null + private var trackingNumber: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardShippedWebhookEvent: CardShippedWebhookEvent) = apply { + bulkOrderToken = cardShippedWebhookEvent.bulkOrderToken + cardToken = cardShippedWebhookEvent.cardToken + eventType = cardShippedWebhookEvent.eventType + shippingMethod = cardShippedWebhookEvent.shippingMethod + trackingNumber = cardShippedWebhookEvent.trackingNumber + additionalProperties = cardShippedWebhookEvent.additionalProperties.toMutableMap() + } + + /** The token of the bulk order associated with this card shipment, if applicable. */ + fun bulkOrderToken(bulkOrderToken: String?) = + bulkOrderToken(JsonField.ofNullable(bulkOrderToken)) + + /** Alias for calling [Builder.bulkOrderToken] with `bulkOrderToken.orElse(null)`. */ + fun bulkOrderToken(bulkOrderToken: Optional) = + bulkOrderToken(bulkOrderToken.getOrNull()) + + /** + * Sets [Builder.bulkOrderToken] to an arbitrary JSON value. + * + * You should usually call [Builder.bulkOrderToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bulkOrderToken(bulkOrderToken: JsonField) = apply { + this.bulkOrderToken = bulkOrderToken + } + + /** The token of the card that was shipped. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** 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 } + + /** The specific shipping method used to ship the card. */ + fun shippingMethod(shippingMethod: ShippingMethod) = + shippingMethod(JsonField.of(shippingMethod)) + + /** + * Sets [Builder.shippingMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingMethod] with a well-typed [ShippingMethod] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shippingMethod(shippingMethod: JsonField) = apply { + this.shippingMethod = shippingMethod + } + + /** The tracking number of the shipment. */ + fun trackingNumber(trackingNumber: String?) = + trackingNumber(JsonField.ofNullable(trackingNumber)) + + /** Alias for calling [Builder.trackingNumber] with `trackingNumber.orElse(null)`. */ + fun trackingNumber(trackingNumber: Optional) = + trackingNumber(trackingNumber.getOrNull()) + + /** + * Sets [Builder.trackingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.trackingNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun trackingNumber(trackingNumber: JsonField) = apply { + this.trackingNumber = trackingNumber + } + + 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 [CardShippedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .bulkOrderToken() + * .cardToken() + * .eventType() + * .shippingMethod() + * .trackingNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardShippedWebhookEvent = + CardShippedWebhookEvent( + checkRequired("bulkOrderToken", bulkOrderToken), + checkRequired("cardToken", cardToken), + checkRequired("eventType", eventType), + checkRequired("shippingMethod", shippingMethod), + checkRequired("trackingNumber", trackingNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardShippedWebhookEvent = apply { + if (validated) { + return@apply + } + + bulkOrderToken() + cardToken() + eventType().validate() + shippingMethod().validate() + trackingNumber() + 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 (bulkOrderToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (shippingMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** 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_SHIPPED = of("card.shipped") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_SHIPPED + } + + /** + * 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_SHIPPED, + /** + * 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_SHIPPED -> Value.CARD_SHIPPED + 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_SHIPPED -> Known.CARD_SHIPPED + 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 + + 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() + } + + /** The specific shipping method used to ship the card. */ + class ShippingMethod @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 EX_US_EXPEDITED_WITH_TRACKING = of("Ex-US expedited with tracking") + + @JvmField val EX_US_STANDARD_WITH_TRACKING = of("Ex-US standard with tracking") + + @JvmField val EX_US_STANDARD_WITHOUT_TRACKING = of("Ex-US standard without tracking") + + @JvmField val FED_EX_2_DAYS = of("FedEx 2 days") + + @JvmField val FED_EX_EXPRESS = of("FedEx express") + + @JvmField val FED_EX_OVERNIGHT = of("FedEx overnight") + + @JvmField val USPS_PRIORITY = of("USPS priority") + + @JvmField val USPS_WITH_TRACKING = of("USPS with tracking") + + @JvmField val USPS_WITHOUT_TRACKING_ENVELOPE = of("USPS without tracking envelope") + + @JvmField + val USPS_WITHOUT_TRACKING_ENVELOPE_NON_MACHINE = + of("USPS without tracking envelope non-machine") + + @JvmField val USPS_WITHOUT_TRACKING_FLAT = of("USPS without tracking flat") + + @JvmStatic fun of(value: String) = ShippingMethod(JsonField.of(value)) + } + + /** An enum containing [ShippingMethod]'s known values. */ + enum class Known { + EX_US_EXPEDITED_WITH_TRACKING, + EX_US_STANDARD_WITH_TRACKING, + EX_US_STANDARD_WITHOUT_TRACKING, + FED_EX_2_DAYS, + FED_EX_EXPRESS, + FED_EX_OVERNIGHT, + USPS_PRIORITY, + USPS_WITH_TRACKING, + USPS_WITHOUT_TRACKING_ENVELOPE, + USPS_WITHOUT_TRACKING_ENVELOPE_NON_MACHINE, + USPS_WITHOUT_TRACKING_FLAT, + } + + /** + * An enum containing [ShippingMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ShippingMethod] 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 { + EX_US_EXPEDITED_WITH_TRACKING, + EX_US_STANDARD_WITH_TRACKING, + EX_US_STANDARD_WITHOUT_TRACKING, + FED_EX_2_DAYS, + FED_EX_EXPRESS, + FED_EX_OVERNIGHT, + USPS_PRIORITY, + USPS_WITH_TRACKING, + USPS_WITHOUT_TRACKING_ENVELOPE, + USPS_WITHOUT_TRACKING_ENVELOPE_NON_MACHINE, + USPS_WITHOUT_TRACKING_FLAT, + /** + * An enum member indicating that [ShippingMethod] 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) { + EX_US_EXPEDITED_WITH_TRACKING -> Value.EX_US_EXPEDITED_WITH_TRACKING + EX_US_STANDARD_WITH_TRACKING -> Value.EX_US_STANDARD_WITH_TRACKING + EX_US_STANDARD_WITHOUT_TRACKING -> Value.EX_US_STANDARD_WITHOUT_TRACKING + FED_EX_2_DAYS -> Value.FED_EX_2_DAYS + FED_EX_EXPRESS -> Value.FED_EX_EXPRESS + FED_EX_OVERNIGHT -> Value.FED_EX_OVERNIGHT + USPS_PRIORITY -> Value.USPS_PRIORITY + USPS_WITH_TRACKING -> Value.USPS_WITH_TRACKING + USPS_WITHOUT_TRACKING_ENVELOPE -> Value.USPS_WITHOUT_TRACKING_ENVELOPE + USPS_WITHOUT_TRACKING_ENVELOPE_NON_MACHINE -> + Value.USPS_WITHOUT_TRACKING_ENVELOPE_NON_MACHINE + USPS_WITHOUT_TRACKING_FLAT -> Value.USPS_WITHOUT_TRACKING_FLAT + 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) { + EX_US_EXPEDITED_WITH_TRACKING -> Known.EX_US_EXPEDITED_WITH_TRACKING + EX_US_STANDARD_WITH_TRACKING -> Known.EX_US_STANDARD_WITH_TRACKING + EX_US_STANDARD_WITHOUT_TRACKING -> Known.EX_US_STANDARD_WITHOUT_TRACKING + FED_EX_2_DAYS -> Known.FED_EX_2_DAYS + FED_EX_EXPRESS -> Known.FED_EX_EXPRESS + FED_EX_OVERNIGHT -> Known.FED_EX_OVERNIGHT + USPS_PRIORITY -> Known.USPS_PRIORITY + USPS_WITH_TRACKING -> Known.USPS_WITH_TRACKING + USPS_WITHOUT_TRACKING_ENVELOPE -> Known.USPS_WITHOUT_TRACKING_ENVELOPE + USPS_WITHOUT_TRACKING_ENVELOPE_NON_MACHINE -> + Known.USPS_WITHOUT_TRACKING_ENVELOPE_NON_MACHINE + USPS_WITHOUT_TRACKING_FLAT -> Known.USPS_WITHOUT_TRACKING_FLAT + else -> throw LithicInvalidDataException("Unknown ShippingMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): ShippingMethod = 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 ShippingMethod && 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 CardShippedWebhookEvent && + bulkOrderToken == other.bulkOrderToken && + cardToken == other.cardToken && + eventType == other.eventType && + shippingMethod == other.shippingMethod && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + bulkOrderToken, + cardToken, + eventType, + shippingMethod, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardShippedWebhookEvent{bulkOrderToken=$bulkOrderToken, cardToken=$cardToken, eventType=$eventType, shippingMethod=$shippingMethod, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionEnhancedDataCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionEnhancedDataCreatedWebhookEvent.kt new file mode 100644 index 000000000..6037dd0ea --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionEnhancedDataCreatedWebhookEvent.kt @@ -0,0 +1,540 @@ +// 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.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CardTransactionEnhancedDataCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val common: JsonField, + private val eventToken: JsonField, + private val fleet: JsonField>, + private val transactionToken: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("common") + @ExcludeMissing + common: JsonField = JsonMissing.of(), + @JsonProperty("event_token") + @ExcludeMissing + eventToken: JsonField = JsonMissing.of(), + @JsonProperty("fleet") + @ExcludeMissing + fleet: JsonField> = JsonMissing.of(), + @JsonProperty("transaction_token") + @ExcludeMissing + transactionToken: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this(token, common, eventToken, fleet, transactionToken, eventType, mutableMapOf()) + + fun toEnhancedData(): EnhancedData = + EnhancedData.builder() + .token(token) + .common(common) + .eventToken(eventToken) + .fleet(fleet) + .transactionToken(transactionToken) + .build() + + /** + * A unique identifier for the enhanced commercial data. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun common(): EnhancedData.CommonData = common.getRequired("common") + + /** + * The token of the event that the enhanced data is associated with. + * + * @throws LithicInvalidDataException if 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") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fleet(): List = fleet.getRequired("fleet") + + /** + * The token of the transaction that the enhanced data is associated with. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transactionToken(): String = transactionToken.getRequired("transaction_token") + + /** + * 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 [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 [common]. + * + * Unlike [common], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("common") + @ExcludeMissing + fun _common(): JsonField = common + + /** + * 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 [fleet]. + * + * Unlike [fleet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fleet") @ExcludeMissing fun _fleet(): JsonField> = fleet + + /** + * Returns the raw JSON value of [transactionToken]. + * + * Unlike [transactionToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken + + /** + * 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 + * [CardTransactionEnhancedDataCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .common() + * .eventToken() + * .fleet() + * .transactionToken() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTransactionEnhancedDataCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var common: JsonField? = null + private var eventToken: JsonField? = null + private var fleet: JsonField>? = null + private var transactionToken: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + cardTransactionEnhancedDataCreatedWebhookEvent: + CardTransactionEnhancedDataCreatedWebhookEvent + ) = apply { + token = cardTransactionEnhancedDataCreatedWebhookEvent.token + common = cardTransactionEnhancedDataCreatedWebhookEvent.common + eventToken = cardTransactionEnhancedDataCreatedWebhookEvent.eventToken + fleet = cardTransactionEnhancedDataCreatedWebhookEvent.fleet.map { it.toMutableList() } + transactionToken = cardTransactionEnhancedDataCreatedWebhookEvent.transactionToken + eventType = cardTransactionEnhancedDataCreatedWebhookEvent.eventType + additionalProperties = + cardTransactionEnhancedDataCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** A unique identifier for the enhanced commercial data. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun common(common: EnhancedData.CommonData) = common(JsonField.of(common)) + + /** + * Sets [Builder.common] to an arbitrary JSON value. + * + * You should usually call [Builder.common] with a well-typed [EnhancedData.CommonData] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun common(common: JsonField) = apply { this.common = common } + + /** The token of the event that the enhanced data is associated with. */ + 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 } + + fun fleet(fleet: List) = fleet(JsonField.of(fleet)) + + /** + * Sets [Builder.fleet] to an arbitrary JSON value. + * + * You should usually call [Builder.fleet] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fleet(fleet: JsonField>) = apply { + this.fleet = fleet.map { it.toMutableList() } + } + + /** + * Adds a single [EnhancedData.Fleet] to [Builder.fleet]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFleet(fleet: EnhancedData.Fleet) = apply { + this.fleet = + (this.fleet ?: JsonField.of(mutableListOf())).also { + checkKnown("fleet", it).add(fleet) + } + } + + /** The token of the transaction that the enhanced data is associated with. */ + fun transactionToken(transactionToken: String) = + transactionToken(JsonField.of(transactionToken)) + + /** + * Sets [Builder.transactionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transactionToken(transactionToken: JsonField) = apply { + this.transactionToken = transactionToken + } + + /** 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 [CardTransactionEnhancedDataCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .common() + * .eventToken() + * .fleet() + * .transactionToken() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTransactionEnhancedDataCreatedWebhookEvent = + CardTransactionEnhancedDataCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("common", common), + checkRequired("eventToken", eventToken), + checkRequired("fleet", fleet).map { it.toImmutable() }, + checkRequired("transactionToken", transactionToken), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardTransactionEnhancedDataCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + common().validate() + eventToken() + fleet().forEach { it.validate() } + transactionToken() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (common.asKnown().getOrNull()?.validity() ?: 0) + + (if (eventToken.asKnown().isPresent) 1 else 0) + + (fleet.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (transactionToken.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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_TRANSACTION_ENHANCED_DATA_CREATED = + of("card_transaction.enhanced_data.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_TRANSACTION_ENHANCED_DATA_CREATED + } + + /** + * 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_TRANSACTION_ENHANCED_DATA_CREATED, + /** + * 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_TRANSACTION_ENHANCED_DATA_CREATED -> + Value.CARD_TRANSACTION_ENHANCED_DATA_CREATED + 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_TRANSACTION_ENHANCED_DATA_CREATED -> + Known.CARD_TRANSACTION_ENHANCED_DATA_CREATED + 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 + + 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 CardTransactionEnhancedDataCreatedWebhookEvent && + token == other.token && + common == other.common && + eventToken == other.eventToken && + fleet == other.fleet && + transactionToken == other.transactionToken && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + common, + eventToken, + fleet, + transactionToken, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardTransactionEnhancedDataCreatedWebhookEvent{token=$token, common=$common, eventToken=$eventToken, fleet=$fleet, transactionToken=$transactionToken, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionEnhancedDataUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionEnhancedDataUpdatedWebhookEvent.kt new file mode 100644 index 000000000..a2cc1de04 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionEnhancedDataUpdatedWebhookEvent.kt @@ -0,0 +1,540 @@ +// 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.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CardTransactionEnhancedDataUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val common: JsonField, + private val eventToken: JsonField, + private val fleet: JsonField>, + private val transactionToken: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("common") + @ExcludeMissing + common: JsonField = JsonMissing.of(), + @JsonProperty("event_token") + @ExcludeMissing + eventToken: JsonField = JsonMissing.of(), + @JsonProperty("fleet") + @ExcludeMissing + fleet: JsonField> = JsonMissing.of(), + @JsonProperty("transaction_token") + @ExcludeMissing + transactionToken: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this(token, common, eventToken, fleet, transactionToken, eventType, mutableMapOf()) + + fun toEnhancedData(): EnhancedData = + EnhancedData.builder() + .token(token) + .common(common) + .eventToken(eventToken) + .fleet(fleet) + .transactionToken(transactionToken) + .build() + + /** + * A unique identifier for the enhanced commercial data. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun common(): EnhancedData.CommonData = common.getRequired("common") + + /** + * The token of the event that the enhanced data is associated with. + * + * @throws LithicInvalidDataException if 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") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fleet(): List = fleet.getRequired("fleet") + + /** + * The token of the transaction that the enhanced data is associated with. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transactionToken(): String = transactionToken.getRequired("transaction_token") + + /** + * 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 [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 [common]. + * + * Unlike [common], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("common") + @ExcludeMissing + fun _common(): JsonField = common + + /** + * 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 [fleet]. + * + * Unlike [fleet], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fleet") @ExcludeMissing fun _fleet(): JsonField> = fleet + + /** + * Returns the raw JSON value of [transactionToken]. + * + * Unlike [transactionToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken + + /** + * 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 + * [CardTransactionEnhancedDataUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .common() + * .eventToken() + * .fleet() + * .transactionToken() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTransactionEnhancedDataUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var common: JsonField? = null + private var eventToken: JsonField? = null + private var fleet: JsonField>? = null + private var transactionToken: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + cardTransactionEnhancedDataUpdatedWebhookEvent: + CardTransactionEnhancedDataUpdatedWebhookEvent + ) = apply { + token = cardTransactionEnhancedDataUpdatedWebhookEvent.token + common = cardTransactionEnhancedDataUpdatedWebhookEvent.common + eventToken = cardTransactionEnhancedDataUpdatedWebhookEvent.eventToken + fleet = cardTransactionEnhancedDataUpdatedWebhookEvent.fleet.map { it.toMutableList() } + transactionToken = cardTransactionEnhancedDataUpdatedWebhookEvent.transactionToken + eventType = cardTransactionEnhancedDataUpdatedWebhookEvent.eventType + additionalProperties = + cardTransactionEnhancedDataUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** A unique identifier for the enhanced commercial data. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun common(common: EnhancedData.CommonData) = common(JsonField.of(common)) + + /** + * Sets [Builder.common] to an arbitrary JSON value. + * + * You should usually call [Builder.common] with a well-typed [EnhancedData.CommonData] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun common(common: JsonField) = apply { this.common = common } + + /** The token of the event that the enhanced data is associated with. */ + 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 } + + fun fleet(fleet: List) = fleet(JsonField.of(fleet)) + + /** + * Sets [Builder.fleet] to an arbitrary JSON value. + * + * You should usually call [Builder.fleet] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fleet(fleet: JsonField>) = apply { + this.fleet = fleet.map { it.toMutableList() } + } + + /** + * Adds a single [EnhancedData.Fleet] to [Builder.fleet]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFleet(fleet: EnhancedData.Fleet) = apply { + this.fleet = + (this.fleet ?: JsonField.of(mutableListOf())).also { + checkKnown("fleet", it).add(fleet) + } + } + + /** The token of the transaction that the enhanced data is associated with. */ + fun transactionToken(transactionToken: String) = + transactionToken(JsonField.of(transactionToken)) + + /** + * Sets [Builder.transactionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transactionToken(transactionToken: JsonField) = apply { + this.transactionToken = transactionToken + } + + /** 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 [CardTransactionEnhancedDataUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .common() + * .eventToken() + * .fleet() + * .transactionToken() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTransactionEnhancedDataUpdatedWebhookEvent = + CardTransactionEnhancedDataUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("common", common), + checkRequired("eventToken", eventToken), + checkRequired("fleet", fleet).map { it.toImmutable() }, + checkRequired("transactionToken", transactionToken), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardTransactionEnhancedDataUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + common().validate() + eventToken() + fleet().forEach { it.validate() } + transactionToken() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (common.asKnown().getOrNull()?.validity() ?: 0) + + (if (eventToken.asKnown().isPresent) 1 else 0) + + (fleet.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (transactionToken.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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_TRANSACTION_ENHANCED_DATA_UPDATED = + of("card_transaction.enhanced_data.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_TRANSACTION_ENHANCED_DATA_UPDATED + } + + /** + * 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_TRANSACTION_ENHANCED_DATA_UPDATED, + /** + * 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_TRANSACTION_ENHANCED_DATA_UPDATED -> + Value.CARD_TRANSACTION_ENHANCED_DATA_UPDATED + 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_TRANSACTION_ENHANCED_DATA_UPDATED -> + Known.CARD_TRANSACTION_ENHANCED_DATA_UPDATED + 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 + + 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 CardTransactionEnhancedDataUpdatedWebhookEvent && + token == other.token && + common == other.common && + eventToken == other.eventToken && + fleet == other.fleet && + transactionToken == other.transactionToken && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + common, + eventToken, + fleet, + transactionToken, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardTransactionEnhancedDataUpdatedWebhookEvent{token=$token, common=$common, eventToken=$eventToken, fleet=$fleet, transactionToken=$transactionToken, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionUpdatedWebhookEvent.kt new file mode 100644 index 000000000..56b57bd5d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/CardTransactionUpdatedWebhookEvent.kt @@ -0,0 +1,1626 @@ +// 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 + +class CardTransactionUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountToken: JsonField, + private val acquirerFee: JsonField, + private val acquirerReferenceNumber: JsonField, + private val amount: JsonField, + private val amounts: JsonField, + private val authorizationAmount: JsonField, + private val authorizationCode: JsonField, + private val avs: JsonField, + private val cardToken: JsonField, + private val cardholderAuthentication: JsonField, + private val created: JsonField, + private val financialAccountToken: JsonField, + private val merchant: JsonField, + private val merchantAmount: JsonField, + private val merchantAuthorizationAmount: JsonField, + private val merchantCurrency: JsonField, + private val network: JsonField, + private val networkRiskScore: JsonField, + private val pos: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val tokenInfo: JsonField, + private val updated: JsonField, + private val events: JsonField>, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_fee") + @ExcludeMissing + acquirerFee: JsonField = JsonMissing.of(), + @JsonProperty("acquirer_reference_number") + @ExcludeMissing + acquirerReferenceNumber: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("amounts") + @ExcludeMissing + amounts: JsonField = JsonMissing.of(), + @JsonProperty("authorization_amount") + @ExcludeMissing + authorizationAmount: JsonField = JsonMissing.of(), + @JsonProperty("authorization_code") + @ExcludeMissing + authorizationCode: JsonField = JsonMissing.of(), + @JsonProperty("avs") @ExcludeMissing avs: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_authentication") + @ExcludeMissing + cardholderAuthentication: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("merchant") @ExcludeMissing merchant: JsonField = JsonMissing.of(), + @JsonProperty("merchant_amount") + @ExcludeMissing + merchantAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_authorization_amount") + @ExcludeMissing + merchantAuthorizationAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_currency") + @ExcludeMissing + merchantCurrency: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), + @JsonProperty("network_risk_score") + @ExcludeMissing + networkRiskScore: JsonField = JsonMissing.of(), + @JsonProperty("pos") @ExcludeMissing pos: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("token_info") + @ExcludeMissing + tokenInfo: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountToken, + acquirerFee, + acquirerReferenceNumber, + amount, + amounts, + authorizationAmount, + authorizationCode, + avs, + cardToken, + cardholderAuthentication, + created, + financialAccountToken, + merchant, + merchantAmount, + merchantAuthorizationAmount, + merchantCurrency, + network, + networkRiskScore, + pos, + result, + settledAmount, + status, + tokenInfo, + updated, + events, + eventType, + mutableMapOf(), + ) + + fun toTransaction(): Transaction = + Transaction.builder() + .token(token) + .accountToken(accountToken) + .acquirerFee(acquirerFee) + .acquirerReferenceNumber(acquirerReferenceNumber) + .amount(amount) + .amounts(amounts) + .authorizationAmount(authorizationAmount) + .authorizationCode(authorizationCode) + .avs(avs) + .cardToken(cardToken) + .cardholderAuthentication(cardholderAuthentication) + .created(created) + .financialAccountToken(financialAccountToken) + .merchant(merchant) + .merchantAmount(merchantAmount) + .merchantAuthorizationAmount(merchantAuthorizationAmount) + .merchantCurrency(merchantCurrency) + .network(network) + .networkRiskScore(networkRiskScore) + .pos(pos) + .result(result) + .settledAmount(settledAmount) + .status(status) + .tokenInfo(tokenInfo) + .updated(updated) + .events(events) + .build() + + /** + * Globally unique identifier. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * The token for the account associated with this transaction. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountToken(): String = accountToken.getRequired("account_token") + + /** + * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of the + * currency. Will be zero if no fee is assessed. Rebates may be transmitted as a negative value + * to indicate credited fees. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun acquirerFee(): Optional = acquirerFee.getOptional("acquirer_fee") + + /** + * Unique identifier assigned to a transaction by the acquirer that can be used in dispute and + * chargeback filing. This field has been deprecated in favor of the `acquirer_reference_number` + * that resides in the event-level `network_info`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(): Optional = + acquirerReferenceNumber.getOptional("acquirer_reference_number") + + /** + * When the transaction is pending, this represents the authorization amount of the transaction + * in the anticipated settlement currency. Once the transaction has settled, this field + * represents the settled amount in the settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") fun amount(): Long = amount.getRequired("amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amounts(): Transaction.TransactionAmounts = amounts.getRequired("amounts") + + /** + * The authorization amount of the transaction in the anticipated settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun authorizationAmount(): Optional = + authorizationAmount.getOptional("authorization_amount") + + /** + * A fixed-width 6-digit numeric identifier that can be used to identify a transaction with + * networks. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authorizationCode(): Optional = authorizationCode.getOptional("authorization_code") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun avs(): Optional = avs.getOptional("avs") + + /** + * Token for the card used in this transaction. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cardholderAuthentication(): Optional = + cardholderAuthentication.getOptional("cardholder_authentication") + + /** + * Date and time when the transaction first occurred. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun financialAccountToken(): Optional = + financialAccountToken.getOptional("financial_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun merchant(): Merchant = merchant.getRequired("merchant") + + /** + * Analogous to the 'amount', but in the merchant currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantAmount(): Optional = merchantAmount.getOptional("merchant_amount") + + /** + * Analogous to the 'authorization_amount', but in the merchant currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(): Optional = + merchantAuthorizationAmount.getOptional("merchant_authorization_amount") + + /** + * 3-character alphabetic ISO 4217 code for the local currency of the transaction. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun merchantCurrency(): String = merchantCurrency.getRequired("merchant_currency") + + /** + * Card network of the authorization. Value is `UNKNOWN` when Lithic cannot determine the + * network code from the upstream provider. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun network(): Optional = network.getOptional("network") + + /** + * Network-provided score assessing risk level associated with a given authorization. Scores are + * on a range of 0-999, with 0 representing the lowest risk and 999 representing the highest + * risk. For Visa transactions, where the raw score has a range of 0-99, Lithic will normalize + * the score by multiplying the raw score by 10x. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkRiskScore(): Optional = networkRiskScore.getOptional("network_risk_score") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pos(): Transaction.Pos = pos.getRequired("pos") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): Transaction.DeclineResult = result.getRequired("result") + + /** + * The settled amount of the transaction in the settlement currency. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * Status of the transaction. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Transaction.Status = status.getRequired("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenInfo(): Optional = tokenInfo.getOptional("token_info") + + /** + * Date and time when the transaction last updated. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun events(): Optional> = events.getOptional("events") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [acquirerFee]. + * + * Unlike [acquirerFee], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("acquirer_fee") @ExcludeMissing fun _acquirerFee(): JsonField = acquirerFee + + /** + * Returns the raw JSON value of [acquirerReferenceNumber]. + * + * Unlike [acquirerReferenceNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("acquirer_reference_number") + @ExcludeMissing + fun _acquirerReferenceNumber(): JsonField = acquirerReferenceNumber + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [amounts]. + * + * Unlike [amounts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amounts") + @ExcludeMissing + fun _amounts(): JsonField = amounts + + /** + * Returns the raw JSON value of [authorizationAmount]. + * + * Unlike [authorizationAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("authorization_amount") + @ExcludeMissing + fun _authorizationAmount(): JsonField = authorizationAmount + + /** + * Returns the raw JSON value of [authorizationCode]. + * + * Unlike [authorizationCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authorization_code") + @ExcludeMissing + fun _authorizationCode(): JsonField = authorizationCode + + /** + * Returns the raw JSON value of [avs]. + * + * Unlike [avs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("avs") @ExcludeMissing fun _avs(): JsonField = avs + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [cardholderAuthentication]. + * + * Unlike [cardholderAuthentication], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_authentication") + @ExcludeMissing + fun _cardholderAuthentication(): JsonField = cardholderAuthentication + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [merchant]. + * + * Unlike [merchant], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("merchant") @ExcludeMissing fun _merchant(): JsonField = merchant + + /** + * Returns the raw JSON value of [merchantAmount]. + * + * Unlike [merchantAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_amount") + @ExcludeMissing + fun _merchantAmount(): JsonField = merchantAmount + + /** + * Returns the raw JSON value of [merchantAuthorizationAmount]. + * + * Unlike [merchantAuthorizationAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_authorization_amount") + @ExcludeMissing + fun _merchantAuthorizationAmount(): JsonField = merchantAuthorizationAmount + + /** + * Returns the raw JSON value of [merchantCurrency]. + * + * Unlike [merchantCurrency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("merchant_currency") + @ExcludeMissing + fun _merchantCurrency(): JsonField = merchantCurrency + + /** + * Returns the raw JSON value of [network]. + * + * Unlike [network], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("network") + @ExcludeMissing + fun _network(): JsonField = network + + /** + * Returns the raw JSON value of [networkRiskScore]. + * + * Unlike [networkRiskScore], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_risk_score") + @ExcludeMissing + fun _networkRiskScore(): JsonField = networkRiskScore + + /** + * Returns the raw JSON value of [pos]. + * + * Unlike [pos], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pos") @ExcludeMissing fun _pos(): JsonField = pos + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [tokenInfo]. + * + * Unlike [tokenInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token_info") @ExcludeMissing fun _tokenInfo(): JsonField = tokenInfo + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [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 + * [CardTransactionUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .acquirerFee() + * .acquirerReferenceNumber() + * .amount() + * .amounts() + * .authorizationAmount() + * .authorizationCode() + * .avs() + * .cardToken() + * .cardholderAuthentication() + * .created() + * .financialAccountToken() + * .merchant() + * .merchantAmount() + * .merchantAuthorizationAmount() + * .merchantCurrency() + * .network() + * .networkRiskScore() + * .pos() + * .result() + * .settledAmount() + * .status() + * .tokenInfo() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTransactionUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var acquirerFee: JsonField? = null + private var acquirerReferenceNumber: JsonField? = null + private var amount: JsonField? = null + private var amounts: JsonField? = null + private var authorizationAmount: JsonField? = null + private var authorizationCode: JsonField? = null + private var avs: JsonField? = null + private var cardToken: JsonField? = null + private var cardholderAuthentication: JsonField? = null + private var created: JsonField? = null + private var financialAccountToken: JsonField? = null + private var merchant: JsonField? = null + private var merchantAmount: JsonField? = null + private var merchantAuthorizationAmount: JsonField? = null + private var merchantCurrency: JsonField? = null + private var network: JsonField? = null + private var networkRiskScore: JsonField? = null + private var pos: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var tokenInfo: JsonField? = null + private var updated: JsonField? = null + private var events: JsonField>? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardTransactionUpdatedWebhookEvent: CardTransactionUpdatedWebhookEvent) = + apply { + token = cardTransactionUpdatedWebhookEvent.token + accountToken = cardTransactionUpdatedWebhookEvent.accountToken + acquirerFee = cardTransactionUpdatedWebhookEvent.acquirerFee + acquirerReferenceNumber = cardTransactionUpdatedWebhookEvent.acquirerReferenceNumber + amount = cardTransactionUpdatedWebhookEvent.amount + amounts = cardTransactionUpdatedWebhookEvent.amounts + authorizationAmount = cardTransactionUpdatedWebhookEvent.authorizationAmount + authorizationCode = cardTransactionUpdatedWebhookEvent.authorizationCode + avs = cardTransactionUpdatedWebhookEvent.avs + cardToken = cardTransactionUpdatedWebhookEvent.cardToken + cardholderAuthentication = + cardTransactionUpdatedWebhookEvent.cardholderAuthentication + created = cardTransactionUpdatedWebhookEvent.created + financialAccountToken = cardTransactionUpdatedWebhookEvent.financialAccountToken + merchant = cardTransactionUpdatedWebhookEvent.merchant + merchantAmount = cardTransactionUpdatedWebhookEvent.merchantAmount + merchantAuthorizationAmount = + cardTransactionUpdatedWebhookEvent.merchantAuthorizationAmount + merchantCurrency = cardTransactionUpdatedWebhookEvent.merchantCurrency + network = cardTransactionUpdatedWebhookEvent.network + networkRiskScore = cardTransactionUpdatedWebhookEvent.networkRiskScore + pos = cardTransactionUpdatedWebhookEvent.pos + result = cardTransactionUpdatedWebhookEvent.result + settledAmount = cardTransactionUpdatedWebhookEvent.settledAmount + status = cardTransactionUpdatedWebhookEvent.status + tokenInfo = cardTransactionUpdatedWebhookEvent.tokenInfo + updated = cardTransactionUpdatedWebhookEvent.updated + events = cardTransactionUpdatedWebhookEvent.events.map { it.toMutableList() } + eventType = cardTransactionUpdatedWebhookEvent.eventType + additionalProperties = + cardTransactionUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** The token for the account associated with this transaction. */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** + * Fee assessed by the merchant and paid for by the cardholder in the smallest unit of the + * currency. Will be zero if no fee is assessed. Rebates may be transmitted as a negative + * value to indicate credited fees. + */ + fun acquirerFee(acquirerFee: Long?) = acquirerFee(JsonField.ofNullable(acquirerFee)) + + /** + * Alias for [Builder.acquirerFee]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun acquirerFee(acquirerFee: Long) = acquirerFee(acquirerFee as Long?) + + /** Alias for calling [Builder.acquirerFee] with `acquirerFee.orElse(null)`. */ + fun acquirerFee(acquirerFee: Optional) = acquirerFee(acquirerFee.getOrNull()) + + /** + * Sets [Builder.acquirerFee] to an arbitrary JSON value. + * + * You should usually call [Builder.acquirerFee] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun acquirerFee(acquirerFee: JsonField) = apply { this.acquirerFee = acquirerFee } + + /** + * Unique identifier assigned to a transaction by the acquirer that can be used in dispute + * and chargeback filing. This field has been deprecated in favor of the + * `acquirer_reference_number` that resides in the event-level `network_info`. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: String?) = + acquirerReferenceNumber(JsonField.ofNullable(acquirerReferenceNumber)) + + /** + * Alias for calling [Builder.acquirerReferenceNumber] with + * `acquirerReferenceNumber.orElse(null)`. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: Optional) = + acquirerReferenceNumber(acquirerReferenceNumber.getOrNull()) + + /** + * Sets [Builder.acquirerReferenceNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.acquirerReferenceNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + @Deprecated("deprecated") + fun acquirerReferenceNumber(acquirerReferenceNumber: JsonField) = apply { + this.acquirerReferenceNumber = acquirerReferenceNumber + } + + /** + * When the transaction is pending, this represents the authorization amount of the + * transaction in the anticipated settlement currency. Once the transaction has settled, + * this field represents the settled amount in the settlement currency. + */ + @Deprecated("deprecated") fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun amounts(amounts: Transaction.TransactionAmounts) = amounts(JsonField.of(amounts)) + + /** + * Sets [Builder.amounts] to an arbitrary JSON value. + * + * You should usually call [Builder.amounts] with a well-typed + * [Transaction.TransactionAmounts] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun amounts(amounts: JsonField) = apply { + this.amounts = amounts + } + + /** The authorization amount of the transaction in the anticipated settlement currency. */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Long?) = + authorizationAmount(JsonField.ofNullable(authorizationAmount)) + + /** + * Alias for [Builder.authorizationAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Long) = + authorizationAmount(authorizationAmount as Long?) + + /** + * Alias for calling [Builder.authorizationAmount] with `authorizationAmount.orElse(null)`. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: Optional) = + authorizationAmount(authorizationAmount.getOrNull()) + + /** + * Sets [Builder.authorizationAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun authorizationAmount(authorizationAmount: JsonField) = apply { + this.authorizationAmount = authorizationAmount + } + + /** + * A fixed-width 6-digit numeric identifier that can be used to identify a transaction with + * networks. + */ + fun authorizationCode(authorizationCode: String?) = + authorizationCode(JsonField.ofNullable(authorizationCode)) + + /** Alias for calling [Builder.authorizationCode] with `authorizationCode.orElse(null)`. */ + fun authorizationCode(authorizationCode: Optional) = + authorizationCode(authorizationCode.getOrNull()) + + /** + * Sets [Builder.authorizationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.authorizationCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authorizationCode(authorizationCode: JsonField) = apply { + this.authorizationCode = authorizationCode + } + + fun avs(avs: Transaction.Avs?) = avs(JsonField.ofNullable(avs)) + + /** Alias for calling [Builder.avs] with `avs.orElse(null)`. */ + fun avs(avs: Optional) = avs(avs.getOrNull()) + + /** + * Sets [Builder.avs] to an arbitrary JSON value. + * + * You should usually call [Builder.avs] with a well-typed [Transaction.Avs] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun avs(avs: JsonField) = apply { this.avs = avs } + + /** Token for the card used in this transaction. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + fun cardholderAuthentication(cardholderAuthentication: CardholderAuthentication?) = + cardholderAuthentication(JsonField.ofNullable(cardholderAuthentication)) + + /** + * Alias for calling [Builder.cardholderAuthentication] with + * `cardholderAuthentication.orElse(null)`. + */ + fun cardholderAuthentication(cardholderAuthentication: Optional) = + cardholderAuthentication(cardholderAuthentication.getOrNull()) + + /** + * Sets [Builder.cardholderAuthentication] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderAuthentication] with a well-typed + * [CardholderAuthentication] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun cardholderAuthentication( + cardholderAuthentication: JsonField + ) = apply { this.cardholderAuthentication = cardholderAuthentication } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun financialAccountToken(financialAccountToken: String?) = + financialAccountToken(JsonField.ofNullable(financialAccountToken)) + + /** + * Alias for calling [Builder.financialAccountToken] with + * `financialAccountToken.orElse(null)`. + */ + fun financialAccountToken(financialAccountToken: Optional) = + financialAccountToken(financialAccountToken.getOrNull()) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + fun merchant(merchant: Merchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed [Merchant] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchant(merchant: JsonField) = apply { this.merchant = merchant } + + /** Analogous to the 'amount', but in the merchant currency. */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Long?) = + merchantAmount(JsonField.ofNullable(merchantAmount)) + + /** + * Alias for [Builder.merchantAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Long) = merchantAmount(merchantAmount as Long?) + + /** Alias for calling [Builder.merchantAmount] with `merchantAmount.orElse(null)`. */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: Optional) = + merchantAmount(merchantAmount.getOrNull()) + + /** + * Sets [Builder.merchantAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + @Deprecated("deprecated") + fun merchantAmount(merchantAmount: JsonField) = apply { + this.merchantAmount = merchantAmount + } + + /** Analogous to the 'authorization_amount', but in the merchant currency. */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long?) = + merchantAuthorizationAmount(JsonField.ofNullable(merchantAuthorizationAmount)) + + /** + * Alias for [Builder.merchantAuthorizationAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Long) = + merchantAuthorizationAmount(merchantAuthorizationAmount as Long?) + + /** + * Alias for calling [Builder.merchantAuthorizationAmount] with + * `merchantAuthorizationAmount.orElse(null)`. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: Optional) = + merchantAuthorizationAmount(merchantAuthorizationAmount.getOrNull()) + + /** + * Sets [Builder.merchantAuthorizationAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAuthorizationAmount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + @Deprecated("deprecated") + fun merchantAuthorizationAmount(merchantAuthorizationAmount: JsonField) = apply { + this.merchantAuthorizationAmount = merchantAuthorizationAmount + } + + /** 3-character alphabetic ISO 4217 code for the local currency of the transaction. */ + @Deprecated("deprecated") + fun merchantCurrency(merchantCurrency: String) = + merchantCurrency(JsonField.of(merchantCurrency)) + + /** + * Sets [Builder.merchantCurrency] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCurrency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun merchantCurrency(merchantCurrency: JsonField) = apply { + this.merchantCurrency = merchantCurrency + } + + /** + * Card network of the authorization. Value is `UNKNOWN` when Lithic cannot determine the + * network code from the upstream provider. + */ + fun network(network: Transaction.Network?) = network(JsonField.ofNullable(network)) + + /** Alias for calling [Builder.network] with `network.orElse(null)`. */ + fun network(network: Optional) = network(network.getOrNull()) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [Transaction.Network] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun network(network: JsonField) = apply { this.network = network } + + /** + * Network-provided score assessing risk level associated with a given authorization. Scores + * are on a range of 0-999, with 0 representing the lowest risk and 999 representing the + * highest risk. For Visa transactions, where the raw score has a range of 0-99, Lithic will + * normalize the score by multiplying the raw score by 10x. + */ + fun networkRiskScore(networkRiskScore: Long?) = + networkRiskScore(JsonField.ofNullable(networkRiskScore)) + + /** + * Alias for [Builder.networkRiskScore]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun networkRiskScore(networkRiskScore: Long) = networkRiskScore(networkRiskScore as Long?) + + /** Alias for calling [Builder.networkRiskScore] with `networkRiskScore.orElse(null)`. */ + fun networkRiskScore(networkRiskScore: Optional) = + networkRiskScore(networkRiskScore.getOrNull()) + + /** + * Sets [Builder.networkRiskScore] to an arbitrary JSON value. + * + * You should usually call [Builder.networkRiskScore] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkRiskScore(networkRiskScore: JsonField) = apply { + this.networkRiskScore = networkRiskScore + } + + fun pos(pos: Transaction.Pos) = pos(JsonField.of(pos)) + + /** + * Sets [Builder.pos] to an arbitrary JSON value. + * + * You should usually call [Builder.pos] with a well-typed [Transaction.Pos] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pos(pos: JsonField) = apply { this.pos = pos } + + fun result(result: Transaction.DeclineResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Transaction.DeclineResult] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** The settled amount of the transaction in the settlement currency. */ + @Deprecated("deprecated") + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + @Deprecated("deprecated") + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** Status of the transaction. */ + fun status(status: Transaction.Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Transaction.Status] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun tokenInfo(tokenInfo: 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 } + + /** Date and time when the transaction last updated. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [Transaction.TransactionEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: Transaction.TransactionEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** 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 [CardTransactionUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .acquirerFee() + * .acquirerReferenceNumber() + * .amount() + * .amounts() + * .authorizationAmount() + * .authorizationCode() + * .avs() + * .cardToken() + * .cardholderAuthentication() + * .created() + * .financialAccountToken() + * .merchant() + * .merchantAmount() + * .merchantAuthorizationAmount() + * .merchantCurrency() + * .network() + * .networkRiskScore() + * .pos() + * .result() + * .settledAmount() + * .status() + * .tokenInfo() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTransactionUpdatedWebhookEvent = + CardTransactionUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountToken", accountToken), + checkRequired("acquirerFee", acquirerFee), + checkRequired("acquirerReferenceNumber", acquirerReferenceNumber), + checkRequired("amount", amount), + checkRequired("amounts", amounts), + checkRequired("authorizationAmount", authorizationAmount), + checkRequired("authorizationCode", authorizationCode), + checkRequired("avs", avs), + checkRequired("cardToken", cardToken), + checkRequired("cardholderAuthentication", cardholderAuthentication), + checkRequired("created", created), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("merchant", merchant), + checkRequired("merchantAmount", merchantAmount), + checkRequired("merchantAuthorizationAmount", merchantAuthorizationAmount), + checkRequired("merchantCurrency", merchantCurrency), + checkRequired("network", network), + checkRequired("networkRiskScore", networkRiskScore), + checkRequired("pos", pos), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("tokenInfo", tokenInfo), + checkRequired("updated", updated), + (events ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardTransactionUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountToken() + acquirerFee() + acquirerReferenceNumber() + amount() + amounts().validate() + authorizationAmount() + authorizationCode() + avs().ifPresent { it.validate() } + cardToken() + cardholderAuthentication().ifPresent { it.validate() } + created() + financialAccountToken() + merchant().validate() + merchantAmount() + merchantAuthorizationAmount() + merchantCurrency() + network().ifPresent { it.validate() } + networkRiskScore() + pos().validate() + result().validate() + settledAmount() + status().validate() + tokenInfo().ifPresent { it.validate() } + updated() + events().ifPresent { it.forEach { it.validate() } } + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (acquirerFee.asKnown().isPresent) 1 else 0) + + (if (acquirerReferenceNumber.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (amounts.asKnown().getOrNull()?.validity() ?: 0) + + (if (authorizationAmount.asKnown().isPresent) 1 else 0) + + (if (authorizationCode.asKnown().isPresent) 1 else 0) + + (avs.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (cardholderAuthentication.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (merchantAmount.asKnown().isPresent) 1 else 0) + + (if (merchantAuthorizationAmount.asKnown().isPresent) 1 else 0) + + (if (merchantCurrency.asKnown().isPresent) 1 else 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (if (networkRiskScore.asKnown().isPresent) 1 else 0) + + (pos.asKnown().getOrNull()?.validity() ?: 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (tokenInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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_TRANSACTION_UPDATED = of("card_transaction.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + CARD_TRANSACTION_UPDATED + } + + /** + * 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_TRANSACTION_UPDATED, + /** + * 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_TRANSACTION_UPDATED -> Value.CARD_TRANSACTION_UPDATED + 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_TRANSACTION_UPDATED -> Known.CARD_TRANSACTION_UPDATED + 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 + + 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 CardTransactionUpdatedWebhookEvent && + token == other.token && + accountToken == other.accountToken && + acquirerFee == other.acquirerFee && + acquirerReferenceNumber == other.acquirerReferenceNumber && + amount == other.amount && + amounts == other.amounts && + authorizationAmount == other.authorizationAmount && + authorizationCode == other.authorizationCode && + avs == other.avs && + cardToken == other.cardToken && + cardholderAuthentication == other.cardholderAuthentication && + created == other.created && + financialAccountToken == other.financialAccountToken && + merchant == other.merchant && + merchantAmount == other.merchantAmount && + merchantAuthorizationAmount == other.merchantAuthorizationAmount && + merchantCurrency == other.merchantCurrency && + network == other.network && + networkRiskScore == other.networkRiskScore && + pos == other.pos && + result == other.result && + settledAmount == other.settledAmount && + status == other.status && + tokenInfo == other.tokenInfo && + updated == other.updated && + events == other.events && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountToken, + acquirerFee, + acquirerReferenceNumber, + amount, + amounts, + authorizationAmount, + authorizationCode, + avs, + cardToken, + cardholderAuthentication, + created, + financialAccountToken, + merchant, + merchantAmount, + merchantAuthorizationAmount, + merchantCurrency, + network, + networkRiskScore, + pos, + result, + settledAmount, + status, + tokenInfo, + updated, + events, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardTransactionUpdatedWebhookEvent{token=$token, accountToken=$accountToken, acquirerFee=$acquirerFee, acquirerReferenceNumber=$acquirerReferenceNumber, amount=$amount, amounts=$amounts, authorizationAmount=$authorizationAmount, authorizationCode=$authorizationCode, avs=$avs, cardToken=$cardToken, cardholderAuthentication=$cardholderAuthentication, created=$created, financialAccountToken=$financialAccountToken, merchant=$merchant, merchantAmount=$merchantAmount, merchantAuthorizationAmount=$merchantAuthorizationAmount, merchantCurrency=$merchantCurrency, network=$network, networkRiskScore=$networkRiskScore, pos=$pos, result=$result, settledAmount=$settledAmount, status=$status, tokenInfo=$tokenInfo, updated=$updated, events=$events, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationApprovalRequestWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationApprovalRequestWebhookEvent.kt new file mode 100644 index 000000000..13f1bbeb7 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationApprovalRequestWebhookEvent.kt @@ -0,0 +1,1887 @@ +// 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 + +class DigitalWalletTokenizationApprovalRequestWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val customerTokenizationDecision: JsonField, + private val eventType: JsonField, + private val issuerDecision: JsonField, + private val tokenizationChannel: JsonField, + private val tokenizationToken: JsonField, + private val walletDecisioningInfo: JsonField, + private val device: JsonField, + private val digitalWalletTokenMetadata: JsonField, + private val ruleResults: JsonField>, + private val tokenizationDeclineReasons: JsonField>, + private val tokenizationSource: JsonField, + private val tokenizationTfaReasons: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("customer_tokenization_decision") + @ExcludeMissing + customerTokenizationDecision: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("issuer_decision") + @ExcludeMissing + issuerDecision: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_channel") + @ExcludeMissing + tokenizationChannel: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + @JsonProperty("wallet_decisioning_info") + @ExcludeMissing + walletDecisioningInfo: JsonField = JsonMissing.of(), + @JsonProperty("device") @ExcludeMissing device: JsonField = JsonMissing.of(), + @JsonProperty("digital_wallet_token_metadata") + @ExcludeMissing + digitalWalletTokenMetadata: JsonField = JsonMissing.of(), + @JsonProperty("rule_results") + @ExcludeMissing + ruleResults: JsonField> = JsonMissing.of(), + @JsonProperty("tokenization_decline_reasons") + @ExcludeMissing + tokenizationDeclineReasons: JsonField> = JsonMissing.of(), + @JsonProperty("tokenization_source") + @ExcludeMissing + tokenizationSource: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_tfa_reasons") + @ExcludeMissing + tokenizationTfaReasons: JsonField> = JsonMissing.of(), + ) : this( + accountToken, + cardToken, + created, + customerTokenizationDecision, + eventType, + issuerDecision, + tokenizationChannel, + tokenizationToken, + walletDecisioningInfo, + device, + digitalWalletTokenMetadata, + ruleResults, + tokenizationDeclineReasons, + tokenizationSource, + tokenizationTfaReasons, + mutableMapOf(), + ) + + /** + * Unique identifier for the user tokenizing a 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * Unique identifier for the card being tokenized + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Indicate when the request was received from Mastercard or Visa + * + * @throws LithicInvalidDataException if 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") + + /** + * Contains the metadata for the customer tokenization decision. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerTokenizationDecision(): Optional = + customerTokenizationDecision.getOptional("customer_tokenization_decision") + + /** + * The name of this event + * + * @throws LithicInvalidDataException if 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") + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun issuerDecision(): IssuerDecision = issuerDecision.getRequired("issuer_decision") + + /** + * The channel through which the tokenization was made. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationChannel(): TokenizationChannel = + tokenizationChannel.getRequired("tokenization_channel") + + /** + * Unique identifier for the digital wallet token attempt + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun walletDecisioningInfo(): WalletDecisioningInfo = + walletDecisioningInfo.getRequired("wallet_decisioning_info") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun device(): Optional = device.getOptional("device") + + /** + * Contains the metadata for the digital wallet being tokenized. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun digitalWalletTokenMetadata(): Optional = + digitalWalletTokenMetadata.getOptional("digital_wallet_token_metadata") + + /** + * Results from rules that were evaluated for this tokenization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ruleResults(): Optional> = + ruleResults.getOptional("rule_results") + + /** + * List of reasons why the tokenization was declined + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationDeclineReasons(): Optional> = + tokenizationDeclineReasons.getOptional("tokenization_decline_reasons") + + /** + * The source of the tokenization. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationSource(): Optional = + tokenizationSource.getOptional("tokenization_source") + + /** + * List of reasons why two-factor authentication was required + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationTfaReasons(): Optional> = + tokenizationTfaReasons.getOptional("tokenization_tfa_reasons") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [customerTokenizationDecision]. + * + * Unlike [customerTokenizationDecision], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customer_tokenization_decision") + @ExcludeMissing + fun _customerTokenizationDecision(): JsonField = + customerTokenizationDecision + + /** + * 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 [issuerDecision]. + * + * Unlike [issuerDecision], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issuer_decision") + @ExcludeMissing + fun _issuerDecision(): JsonField = issuerDecision + + /** + * Returns the raw JSON value of [tokenizationChannel]. + * + * Unlike [tokenizationChannel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_channel") + @ExcludeMissing + fun _tokenizationChannel(): JsonField = tokenizationChannel + + /** + * Returns the raw JSON value of [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + /** + * Returns the raw JSON value of [walletDecisioningInfo]. + * + * Unlike [walletDecisioningInfo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wallet_decisioning_info") + @ExcludeMissing + fun _walletDecisioningInfo(): JsonField = walletDecisioningInfo + + /** + * Returns the raw JSON value of [device]. + * + * Unlike [device], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device") @ExcludeMissing fun _device(): JsonField = device + + /** + * Returns the raw JSON value of [digitalWalletTokenMetadata]. + * + * Unlike [digitalWalletTokenMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("digital_wallet_token_metadata") + @ExcludeMissing + fun _digitalWalletTokenMetadata(): JsonField = + digitalWalletTokenMetadata + + /** + * Returns the raw JSON value of [ruleResults]. + * + * Unlike [ruleResults], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_results") + @ExcludeMissing + fun _ruleResults(): JsonField> = ruleResults + + /** + * Returns the raw JSON value of [tokenizationDeclineReasons]. + * + * Unlike [tokenizationDeclineReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_decline_reasons") + @ExcludeMissing + fun _tokenizationDeclineReasons(): JsonField> = + tokenizationDeclineReasons + + /** + * Returns the raw JSON value of [tokenizationSource]. + * + * Unlike [tokenizationSource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_source") + @ExcludeMissing + fun _tokenizationSource(): JsonField = tokenizationSource + + /** + * Returns the raw JSON value of [tokenizationTfaReasons]. + * + * Unlike [tokenizationTfaReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_tfa_reasons") + @ExcludeMissing + fun _tokenizationTfaReasons(): JsonField> = tokenizationTfaReasons + + @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 + * [DigitalWalletTokenizationApprovalRequestWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .customerTokenizationDecision() + * .eventType() + * .issuerDecision() + * .tokenizationChannel() + * .tokenizationToken() + * .walletDecisioningInfo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DigitalWalletTokenizationApprovalRequestWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var customerTokenizationDecision: JsonField? = null + private var eventType: JsonField? = null + private var issuerDecision: JsonField? = null + private var tokenizationChannel: JsonField? = null + private var tokenizationToken: JsonField? = null + private var walletDecisioningInfo: JsonField? = null + private var device: JsonField = JsonMissing.of() + private var digitalWalletTokenMetadata: JsonField = + JsonMissing.of() + private var ruleResults: JsonField>? = null + private var tokenizationDeclineReasons: JsonField>? = + null + private var tokenizationSource: JsonField = JsonMissing.of() + private var tokenizationTfaReasons: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + digitalWalletTokenizationApprovalRequestWebhookEvent: + DigitalWalletTokenizationApprovalRequestWebhookEvent + ) = apply { + accountToken = digitalWalletTokenizationApprovalRequestWebhookEvent.accountToken + cardToken = digitalWalletTokenizationApprovalRequestWebhookEvent.cardToken + created = digitalWalletTokenizationApprovalRequestWebhookEvent.created + customerTokenizationDecision = + digitalWalletTokenizationApprovalRequestWebhookEvent.customerTokenizationDecision + eventType = digitalWalletTokenizationApprovalRequestWebhookEvent.eventType + issuerDecision = digitalWalletTokenizationApprovalRequestWebhookEvent.issuerDecision + tokenizationChannel = + digitalWalletTokenizationApprovalRequestWebhookEvent.tokenizationChannel + tokenizationToken = + digitalWalletTokenizationApprovalRequestWebhookEvent.tokenizationToken + walletDecisioningInfo = + digitalWalletTokenizationApprovalRequestWebhookEvent.walletDecisioningInfo + device = digitalWalletTokenizationApprovalRequestWebhookEvent.device + digitalWalletTokenMetadata = + digitalWalletTokenizationApprovalRequestWebhookEvent.digitalWalletTokenMetadata + ruleResults = + digitalWalletTokenizationApprovalRequestWebhookEvent.ruleResults.map { + it.toMutableList() + } + tokenizationDeclineReasons = + digitalWalletTokenizationApprovalRequestWebhookEvent.tokenizationDeclineReasons + .map { it.toMutableList() } + tokenizationSource = + digitalWalletTokenizationApprovalRequestWebhookEvent.tokenizationSource + tokenizationTfaReasons = + digitalWalletTokenizationApprovalRequestWebhookEvent.tokenizationTfaReasons.map { + it.toMutableList() + } + additionalProperties = + digitalWalletTokenizationApprovalRequestWebhookEvent.additionalProperties + .toMutableMap() + } + + /** Unique identifier for the user tokenizing a card */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Unique identifier for the card being tokenized */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Indicate when the request was received from Mastercard or Visa */ + 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 } + + /** Contains the metadata for the customer tokenization decision. */ + fun customerTokenizationDecision( + customerTokenizationDecision: CustomerTokenizationDecision? + ) = customerTokenizationDecision(JsonField.ofNullable(customerTokenizationDecision)) + + /** + * Alias for calling [Builder.customerTokenizationDecision] with + * `customerTokenizationDecision.orElse(null)`. + */ + fun customerTokenizationDecision( + customerTokenizationDecision: Optional + ) = customerTokenizationDecision(customerTokenizationDecision.getOrNull()) + + /** + * Sets [Builder.customerTokenizationDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.customerTokenizationDecision] with a well-typed + * [CustomerTokenizationDecision] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customerTokenizationDecision( + customerTokenizationDecision: JsonField + ) = apply { this.customerTokenizationDecision = customerTokenizationDecision } + + /** The name of this event */ + 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 } + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + */ + fun issuerDecision(issuerDecision: IssuerDecision) = + issuerDecision(JsonField.of(issuerDecision)) + + /** + * Sets [Builder.issuerDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerDecision] with a well-typed [IssuerDecision] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuerDecision(issuerDecision: JsonField) = apply { + this.issuerDecision = issuerDecision + } + + /** The channel through which the tokenization was made. */ + fun tokenizationChannel(tokenizationChannel: TokenizationChannel) = + tokenizationChannel(JsonField.of(tokenizationChannel)) + + /** + * Sets [Builder.tokenizationChannel] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationChannel] with a well-typed + * [TokenizationChannel] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenizationChannel(tokenizationChannel: JsonField) = apply { + this.tokenizationChannel = tokenizationChannel + } + + /** Unique identifier for the digital wallet token attempt */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + fun walletDecisioningInfo(walletDecisioningInfo: WalletDecisioningInfo) = + walletDecisioningInfo(JsonField.of(walletDecisioningInfo)) + + /** + * Sets [Builder.walletDecisioningInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.walletDecisioningInfo] with a well-typed + * [WalletDecisioningInfo] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun walletDecisioningInfo(walletDecisioningInfo: JsonField) = apply { + this.walletDecisioningInfo = walletDecisioningInfo + } + + fun device(device: Device) = device(JsonField.of(device)) + + /** + * Sets [Builder.device] to an arbitrary JSON value. + * + * You should usually call [Builder.device] with a well-typed [Device] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun device(device: JsonField) = apply { this.device = device } + + /** Contains the metadata for the digital wallet being tokenized. */ + fun digitalWalletTokenMetadata(digitalWalletTokenMetadata: DigitalWalletTokenMetadata) = + digitalWalletTokenMetadata(JsonField.of(digitalWalletTokenMetadata)) + + /** + * Sets [Builder.digitalWalletTokenMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.digitalWalletTokenMetadata] with a well-typed + * [DigitalWalletTokenMetadata] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun digitalWalletTokenMetadata( + digitalWalletTokenMetadata: JsonField + ) = apply { this.digitalWalletTokenMetadata = digitalWalletTokenMetadata } + + /** Results from rules that were evaluated for this tokenization */ + fun ruleResults(ruleResults: List) = + ruleResults(JsonField.of(ruleResults)) + + /** + * Sets [Builder.ruleResults] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleResults] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun ruleResults(ruleResults: JsonField>) = apply { + this.ruleResults = ruleResults.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationRuleResult] to [ruleResults]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRuleResult(ruleResult: TokenizationRuleResult) = apply { + ruleResults = + (ruleResults ?: JsonField.of(mutableListOf())).also { + checkKnown("ruleResults", it).add(ruleResult) + } + } + + /** List of reasons why the tokenization was declined */ + fun tokenizationDeclineReasons( + tokenizationDeclineReasons: List + ) = tokenizationDeclineReasons(JsonField.of(tokenizationDeclineReasons)) + + /** + * Sets [Builder.tokenizationDeclineReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationDeclineReasons] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tokenizationDeclineReasons( + tokenizationDeclineReasons: JsonField> + ) = apply { + this.tokenizationDeclineReasons = tokenizationDeclineReasons.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationDeclineReason] to [tokenizationDeclineReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTokenizationDeclineReason(tokenizationDeclineReason: TokenizationDeclineReason) = + apply { + tokenizationDeclineReasons = + (tokenizationDeclineReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("tokenizationDeclineReasons", it).add(tokenizationDeclineReason) + } + } + + /** The source of the tokenization. */ + fun tokenizationSource(tokenizationSource: TokenizationSource) = + tokenizationSource(JsonField.of(tokenizationSource)) + + /** + * Sets [Builder.tokenizationSource] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationSource] with a well-typed + * [TokenizationSource] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenizationSource(tokenizationSource: JsonField) = apply { + this.tokenizationSource = tokenizationSource + } + + /** List of reasons why two-factor authentication was required */ + fun tokenizationTfaReasons(tokenizationTfaReasons: List) = + tokenizationTfaReasons(JsonField.of(tokenizationTfaReasons)) + + /** + * Sets [Builder.tokenizationTfaReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationTfaReasons] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tokenizationTfaReasons(tokenizationTfaReasons: JsonField>) = + apply { + this.tokenizationTfaReasons = tokenizationTfaReasons.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationTfaReason] to [tokenizationTfaReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTokenizationTfaReason(tokenizationTfaReason: TokenizationTfaReason) = apply { + tokenizationTfaReasons = + (tokenizationTfaReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("tokenizationTfaReasons", it).add(tokenizationTfaReason) + } + } + + 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 [DigitalWalletTokenizationApprovalRequestWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .customerTokenizationDecision() + * .eventType() + * .issuerDecision() + * .tokenizationChannel() + * .tokenizationToken() + * .walletDecisioningInfo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DigitalWalletTokenizationApprovalRequestWebhookEvent = + DigitalWalletTokenizationApprovalRequestWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("customerTokenizationDecision", customerTokenizationDecision), + checkRequired("eventType", eventType), + checkRequired("issuerDecision", issuerDecision), + checkRequired("tokenizationChannel", tokenizationChannel), + checkRequired("tokenizationToken", tokenizationToken), + checkRequired("walletDecisioningInfo", walletDecisioningInfo), + device, + digitalWalletTokenMetadata, + (ruleResults ?: JsonMissing.of()).map { it.toImmutable() }, + (tokenizationDeclineReasons ?: JsonMissing.of()).map { it.toImmutable() }, + tokenizationSource, + (tokenizationTfaReasons ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DigitalWalletTokenizationApprovalRequestWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + cardToken() + created() + customerTokenizationDecision().ifPresent { it.validate() } + eventType().validate() + issuerDecision().validate() + tokenizationChannel().validate() + tokenizationToken() + walletDecisioningInfo().validate() + device().ifPresent { it.validate() } + digitalWalletTokenMetadata().ifPresent { it.validate() } + ruleResults().ifPresent { it.forEach { it.validate() } } + tokenizationDeclineReasons().ifPresent { it.forEach { it.validate() } } + tokenizationSource().ifPresent { it.validate() } + tokenizationTfaReasons().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (customerTokenizationDecision.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (issuerDecision.asKnown().getOrNull()?.validity() ?: 0) + + (tokenizationChannel.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + (walletDecisioningInfo.asKnown().getOrNull()?.validity() ?: 0) + + (device.asKnown().getOrNull()?.validity() ?: 0) + + (digitalWalletTokenMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (ruleResults.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tokenizationDeclineReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (tokenizationSource.asKnown().getOrNull()?.validity() ?: 0) + + (tokenizationTfaReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Contains the metadata for the customer tokenization decision. */ + class CustomerTokenizationDecision + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val outcome: JsonField, + private val responderUrl: JsonField, + private val latency: JsonField, + private val responseCode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("outcome") @ExcludeMissing outcome: JsonField = JsonMissing.of(), + @JsonProperty("responder_url") + @ExcludeMissing + responderUrl: JsonField = JsonMissing.of(), + @JsonProperty("latency") @ExcludeMissing latency: JsonField = JsonMissing.of(), + @JsonProperty("response_code") + @ExcludeMissing + responseCode: JsonField = JsonMissing.of(), + ) : this(outcome, responderUrl, latency, responseCode, mutableMapOf()) + + /** + * The outcome of the customer's decision + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun outcome(): Outcome = outcome.getRequired("outcome") + + /** + * The customer's subscribed URL + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun responderUrl(): String = responderUrl.getRequired("responder_url") + + /** + * Time in ms it took for the customer's URL to respond + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun latency(): Optional = latency.getOptional("latency") + + /** + * The response code that the customer provided + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseCode(): Optional = responseCode.getOptional("response_code") + + /** + * Returns the raw JSON value of [outcome]. + * + * Unlike [outcome], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outcome") @ExcludeMissing fun _outcome(): JsonField = outcome + + /** + * Returns the raw JSON value of [responderUrl]. + * + * Unlike [responderUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("responder_url") + @ExcludeMissing + fun _responderUrl(): JsonField = responderUrl + + /** + * Returns the raw JSON value of [latency]. + * + * Unlike [latency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency") @ExcludeMissing fun _latency(): JsonField = latency + + /** + * Returns the raw JSON value of [responseCode]. + * + * Unlike [responseCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("response_code") + @ExcludeMissing + fun _responseCode(): JsonField = responseCode + + @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 + * [CustomerTokenizationDecision]. + * + * The following fields are required: + * ```java + * .outcome() + * .responderUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerTokenizationDecision]. */ + class Builder internal constructor() { + + private var outcome: JsonField? = null + private var responderUrl: JsonField? = null + private var latency: JsonField = JsonMissing.of() + private var responseCode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerTokenizationDecision: CustomerTokenizationDecision) = apply { + outcome = customerTokenizationDecision.outcome + responderUrl = customerTokenizationDecision.responderUrl + latency = customerTokenizationDecision.latency + responseCode = customerTokenizationDecision.responseCode + additionalProperties = + customerTokenizationDecision.additionalProperties.toMutableMap() + } + + /** The outcome of the customer's decision */ + fun outcome(outcome: Outcome) = outcome(JsonField.of(outcome)) + + /** + * Sets [Builder.outcome] to an arbitrary JSON value. + * + * You should usually call [Builder.outcome] with a well-typed [Outcome] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outcome(outcome: JsonField) = apply { this.outcome = outcome } + + /** The customer's subscribed URL */ + fun responderUrl(responderUrl: String) = responderUrl(JsonField.of(responderUrl)) + + /** + * Sets [Builder.responderUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.responderUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun responderUrl(responderUrl: JsonField) = apply { + this.responderUrl = responderUrl + } + + /** Time in ms it took for the customer's URL to respond */ + fun latency(latency: String) = latency(JsonField.of(latency)) + + /** + * Sets [Builder.latency] to an arbitrary JSON value. + * + * You should usually call [Builder.latency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latency(latency: JsonField) = apply { this.latency = latency } + + /** The response code that the customer provided */ + fun responseCode(responseCode: String) = responseCode(JsonField.of(responseCode)) + + /** + * Sets [Builder.responseCode] to an arbitrary JSON value. + * + * You should usually call [Builder.responseCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun responseCode(responseCode: JsonField) = apply { + this.responseCode = responseCode + } + + 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 [CustomerTokenizationDecision]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .outcome() + * .responderUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerTokenizationDecision = + CustomerTokenizationDecision( + checkRequired("outcome", outcome), + checkRequired("responderUrl", responderUrl), + latency, + responseCode, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomerTokenizationDecision = apply { + if (validated) { + return@apply + } + + outcome().validate() + responderUrl() + latency() + responseCode() + 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 = + (outcome.asKnown().getOrNull()?.validity() ?: 0) + + (if (responderUrl.asKnown().isPresent) 1 else 0) + + (if (latency.asKnown().isPresent) 1 else 0) + + (if (responseCode.asKnown().isPresent) 1 else 0) + + /** The outcome of the customer's decision */ + class Outcome @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val ERROR = of("ERROR") + + @JvmField val INVALID_RESPONSE = of("INVALID_RESPONSE") + + @JvmField + val REQUIRE_ADDITIONAL_AUTHENTICATION = of("REQUIRE_ADDITIONAL_AUTHENTICATION") + + @JvmField val TIMEOUT = of("TIMEOUT") + + @JvmStatic fun of(value: String) = Outcome(JsonField.of(value)) + } + + /** An enum containing [Outcome]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + ERROR, + INVALID_RESPONSE, + REQUIRE_ADDITIONAL_AUTHENTICATION, + TIMEOUT, + } + + /** + * An enum containing [Outcome]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Outcome] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPROVED, + DECLINED, + ERROR, + INVALID_RESPONSE, + REQUIRE_ADDITIONAL_AUTHENTICATION, + TIMEOUT, + /** + * An enum member indicating that [Outcome] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + ERROR -> Value.ERROR + INVALID_RESPONSE -> Value.INVALID_RESPONSE + REQUIRE_ADDITIONAL_AUTHENTICATION -> Value.REQUIRE_ADDITIONAL_AUTHENTICATION + TIMEOUT -> Value.TIMEOUT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + ERROR -> Known.ERROR + INVALID_RESPONSE -> Known.INVALID_RESPONSE + REQUIRE_ADDITIONAL_AUTHENTICATION -> Known.REQUIRE_ADDITIONAL_AUTHENTICATION + TIMEOUT -> Known.TIMEOUT + else -> throw LithicInvalidDataException("Unknown Outcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Outcome = 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 Outcome && 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 CustomerTokenizationDecision && + outcome == other.outcome && + responderUrl == other.responderUrl && + latency == other.latency && + responseCode == other.responseCode && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(outcome, responderUrl, latency, responseCode, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerTokenizationDecision{outcome=$outcome, responderUrl=$responderUrl, latency=$latency, responseCode=$responseCode, additionalProperties=$additionalProperties}" + } + + /** The name of this event */ + 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 DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST = + of("digital_wallet.tokenization_approval_request") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DIGITAL_WALLET_TOKENIZATION_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 { + DIGITAL_WALLET_TOKENIZATION_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) { + DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST -> + Value.DIGITAL_WALLET_TOKENIZATION_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) { + DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST -> + Known.DIGITAL_WALLET_TOKENIZATION_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 + + 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() + } + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + */ + class IssuerDecision @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPROVED = of("APPROVED") + + @JvmField val DENIED = of("DENIED") + + @JvmField val VERIFICATION_REQUIRED = of("VERIFICATION_REQUIRED") + + @JvmStatic fun of(value: String) = IssuerDecision(JsonField.of(value)) + } + + /** An enum containing [IssuerDecision]'s known values. */ + enum class Known { + APPROVED, + DENIED, + VERIFICATION_REQUIRED, + } + + /** + * An enum containing [IssuerDecision]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IssuerDecision] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPROVED, + DENIED, + VERIFICATION_REQUIRED, + /** + * An enum member indicating that [IssuerDecision] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DENIED -> Value.DENIED + VERIFICATION_REQUIRED -> Value.VERIFICATION_REQUIRED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DENIED -> Known.DENIED + VERIFICATION_REQUIRED -> Known.VERIFICATION_REQUIRED + else -> throw LithicInvalidDataException("Unknown IssuerDecision: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): IssuerDecision = 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 IssuerDecision && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The channel through which the tokenization was made. */ + class TokenizationChannel + @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 DIGITAL_WALLET = of("DIGITAL_WALLET") + + @JvmField val MERCHANT = of("MERCHANT") + + @JvmStatic fun of(value: String) = TokenizationChannel(JsonField.of(value)) + } + + /** An enum containing [TokenizationChannel]'s known values. */ + enum class Known { + DIGITAL_WALLET, + MERCHANT, + } + + /** + * An enum containing [TokenizationChannel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TokenizationChannel] 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 { + DIGITAL_WALLET, + MERCHANT, + /** + * An enum member indicating that [TokenizationChannel] 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) { + DIGITAL_WALLET -> Value.DIGITAL_WALLET + MERCHANT -> Value.MERCHANT + 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) { + DIGITAL_WALLET -> Known.DIGITAL_WALLET + MERCHANT -> Known.MERCHANT + else -> throw LithicInvalidDataException("Unknown TokenizationChannel: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenizationChannel = 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 TokenizationChannel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The source of the tokenization. */ + class TokenizationSource + @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 ACCOUNT_ON_FILE = of("ACCOUNT_ON_FILE") + + @JvmField val CONTACTLESS_TAP = of("CONTACTLESS_TAP") + + @JvmField val MANUAL_PROVISION = of("MANUAL_PROVISION") + + @JvmField val PUSH_PROVISION = of("PUSH_PROVISION") + + @JvmField val TOKEN = of("TOKEN") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = TokenizationSource(JsonField.of(value)) + } + + /** An enum containing [TokenizationSource]'s known values. */ + enum class Known { + ACCOUNT_ON_FILE, + CONTACTLESS_TAP, + MANUAL_PROVISION, + PUSH_PROVISION, + TOKEN, + UNKNOWN, + } + + /** + * An enum containing [TokenizationSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TokenizationSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_ON_FILE, + CONTACTLESS_TAP, + MANUAL_PROVISION, + PUSH_PROVISION, + TOKEN, + UNKNOWN, + /** + * An enum member indicating that [TokenizationSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_ON_FILE -> Value.ACCOUNT_ON_FILE + CONTACTLESS_TAP -> Value.CONTACTLESS_TAP + MANUAL_PROVISION -> Value.MANUAL_PROVISION + PUSH_PROVISION -> Value.PUSH_PROVISION + TOKEN -> Value.TOKEN + 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) { + ACCOUNT_ON_FILE -> Known.ACCOUNT_ON_FILE + CONTACTLESS_TAP -> Known.CONTACTLESS_TAP + MANUAL_PROVISION -> Known.MANUAL_PROVISION + PUSH_PROVISION -> Known.PUSH_PROVISION + TOKEN -> Known.TOKEN + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown TokenizationSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenizationSource = 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 TokenizationSource && 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 DigitalWalletTokenizationApprovalRequestWebhookEvent && + accountToken == other.accountToken && + cardToken == other.cardToken && + created == other.created && + customerTokenizationDecision == other.customerTokenizationDecision && + eventType == other.eventType && + issuerDecision == other.issuerDecision && + tokenizationChannel == other.tokenizationChannel && + tokenizationToken == other.tokenizationToken && + walletDecisioningInfo == other.walletDecisioningInfo && + device == other.device && + digitalWalletTokenMetadata == other.digitalWalletTokenMetadata && + ruleResults == other.ruleResults && + tokenizationDeclineReasons == other.tokenizationDeclineReasons && + tokenizationSource == other.tokenizationSource && + tokenizationTfaReasons == other.tokenizationTfaReasons && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + cardToken, + created, + customerTokenizationDecision, + eventType, + issuerDecision, + tokenizationChannel, + tokenizationToken, + walletDecisioningInfo, + device, + digitalWalletTokenMetadata, + ruleResults, + tokenizationDeclineReasons, + tokenizationSource, + tokenizationTfaReasons, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DigitalWalletTokenizationApprovalRequestWebhookEvent{accountToken=$accountToken, cardToken=$cardToken, created=$created, customerTokenizationDecision=$customerTokenizationDecision, eventType=$eventType, issuerDecision=$issuerDecision, tokenizationChannel=$tokenizationChannel, tokenizationToken=$tokenizationToken, walletDecisioningInfo=$walletDecisioningInfo, device=$device, digitalWalletTokenMetadata=$digitalWalletTokenMetadata, ruleResults=$ruleResults, tokenizationDeclineReasons=$tokenizationDeclineReasons, tokenizationSource=$tokenizationSource, tokenizationTfaReasons=$tokenizationTfaReasons, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationResultWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationResultWebhookEvent.kt new file mode 100644 index 000000000..00c3e292d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationResultWebhookEvent.kt @@ -0,0 +1,1267 @@ +// 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 + +class DigitalWalletTokenizationResultWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val tokenizationResultDetails: JsonField, + private val tokenizationToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_result_details") + @ExcludeMissing + tokenizationResultDetails: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + ) : this( + accountToken, + cardToken, + created, + eventType, + tokenizationResultDetails, + tokenizationToken, + mutableMapOf(), + ) + + /** + * Account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountToken(): String = accountToken.getRequired("account_token") + + /** + * Card token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Created date + * + * @throws LithicInvalidDataException if 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") + + /** + * 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") + + /** + * The result of the tokenization request. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationResultDetails(): TokenizationResultDetails = + tokenizationResultDetails.getRequired("tokenization_result_details") + + /** + * Tokenization token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [tokenizationResultDetails]. + * + * Unlike [tokenizationResultDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_result_details") + @ExcludeMissing + fun _tokenizationResultDetails(): JsonField = + tokenizationResultDetails + + /** + * Returns the raw JSON value of [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + @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 + * [DigitalWalletTokenizationResultWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .tokenizationResultDetails() + * .tokenizationToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DigitalWalletTokenizationResultWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var tokenizationResultDetails: JsonField? = null + private var tokenizationToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + digitalWalletTokenizationResultWebhookEvent: DigitalWalletTokenizationResultWebhookEvent + ) = apply { + accountToken = digitalWalletTokenizationResultWebhookEvent.accountToken + cardToken = digitalWalletTokenizationResultWebhookEvent.cardToken + created = digitalWalletTokenizationResultWebhookEvent.created + eventType = digitalWalletTokenizationResultWebhookEvent.eventType + tokenizationResultDetails = + digitalWalletTokenizationResultWebhookEvent.tokenizationResultDetails + tokenizationToken = digitalWalletTokenizationResultWebhookEvent.tokenizationToken + additionalProperties = + digitalWalletTokenizationResultWebhookEvent.additionalProperties.toMutableMap() + } + + /** Account token */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Card token */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Created date */ + 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 } + + /** 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 } + + /** The result of the tokenization request. */ + fun tokenizationResultDetails(tokenizationResultDetails: TokenizationResultDetails) = + tokenizationResultDetails(JsonField.of(tokenizationResultDetails)) + + /** + * Sets [Builder.tokenizationResultDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationResultDetails] with a well-typed + * [TokenizationResultDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tokenizationResultDetails( + tokenizationResultDetails: JsonField + ) = apply { this.tokenizationResultDetails = tokenizationResultDetails } + + /** Tokenization token */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + 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 [DigitalWalletTokenizationResultWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .tokenizationResultDetails() + * .tokenizationToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DigitalWalletTokenizationResultWebhookEvent = + DigitalWalletTokenizationResultWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("tokenizationResultDetails", tokenizationResultDetails), + checkRequired("tokenizationToken", tokenizationToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DigitalWalletTokenizationResultWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + cardToken() + created() + eventType().validate() + tokenizationResultDetails().validate() + tokenizationToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (tokenizationResultDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + /** 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 DIGITAL_WALLET_TOKENIZATION_RESULT = of("digital_wallet.tokenization_result") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DIGITAL_WALLET_TOKENIZATION_RESULT + } + + /** + * 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 { + DIGITAL_WALLET_TOKENIZATION_RESULT, + /** + * 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) { + DIGITAL_WALLET_TOKENIZATION_RESULT -> Value.DIGITAL_WALLET_TOKENIZATION_RESULT + 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) { + DIGITAL_WALLET_TOKENIZATION_RESULT -> Known.DIGITAL_WALLET_TOKENIZATION_RESULT + 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 + + 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() + } + + /** The result of the tokenization request. */ + class TokenizationResultDetails + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val issuerDecision: JsonField, + private val tokenizationDeclineReasons: JsonField>, + private val customerDecision: JsonField, + private val ruleResults: JsonField>, + private val tokenActivatedDateTime: JsonField, + private val tokenizationTfaReasons: JsonField>, + private val walletDecision: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("issuer_decision") + @ExcludeMissing + issuerDecision: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_decline_reasons") + @ExcludeMissing + tokenizationDeclineReasons: JsonField> = + JsonMissing.of(), + @JsonProperty("customer_decision") + @ExcludeMissing + customerDecision: JsonField = JsonMissing.of(), + @JsonProperty("rule_results") + @ExcludeMissing + ruleResults: JsonField> = JsonMissing.of(), + @JsonProperty("token_activated_date_time") + @ExcludeMissing + tokenActivatedDateTime: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_tfa_reasons") + @ExcludeMissing + tokenizationTfaReasons: JsonField> = JsonMissing.of(), + @JsonProperty("wallet_decision") + @ExcludeMissing + walletDecision: JsonField = JsonMissing.of(), + ) : this( + issuerDecision, + tokenizationDeclineReasons, + customerDecision, + ruleResults, + tokenActivatedDateTime, + tokenizationTfaReasons, + walletDecision, + mutableMapOf(), + ) + + /** + * Lithic's tokenization decision. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun issuerDecision(): String = issuerDecision.getRequired("issuer_decision") + + /** + * List of reasons why the tokenization was declined + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationDeclineReasons(): List = + tokenizationDeclineReasons.getRequired("tokenization_decline_reasons") + + /** + * The customer's tokenization decision if applicable. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerDecision(): Optional = customerDecision.getOptional("customer_decision") + + /** + * Results from rules that were evaluated for this tokenization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ruleResults(): Optional> = + ruleResults.getOptional("rule_results") + + /** + * An RFC 3339 timestamp indicating when the tokenization succeeded. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenActivatedDateTime(): Optional = + tokenActivatedDateTime.getOptional("token_activated_date_time") + + /** + * List of reasons why two-factor authentication was required + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationTfaReasons(): Optional> = + tokenizationTfaReasons.getOptional("tokenization_tfa_reasons") + + /** + * The wallet's recommended decision. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun walletDecision(): Optional = walletDecision.getOptional("wallet_decision") + + /** + * Returns the raw JSON value of [issuerDecision]. + * + * Unlike [issuerDecision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("issuer_decision") + @ExcludeMissing + fun _issuerDecision(): JsonField = issuerDecision + + /** + * Returns the raw JSON value of [tokenizationDeclineReasons]. + * + * Unlike [tokenizationDeclineReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_decline_reasons") + @ExcludeMissing + fun _tokenizationDeclineReasons(): JsonField> = + tokenizationDeclineReasons + + /** + * Returns the raw JSON value of [customerDecision]. + * + * Unlike [customerDecision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_decision") + @ExcludeMissing + fun _customerDecision(): JsonField = customerDecision + + /** + * Returns the raw JSON value of [ruleResults]. + * + * Unlike [ruleResults], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_results") + @ExcludeMissing + fun _ruleResults(): JsonField> = ruleResults + + /** + * Returns the raw JSON value of [tokenActivatedDateTime]. + * + * Unlike [tokenActivatedDateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("token_activated_date_time") + @ExcludeMissing + fun _tokenActivatedDateTime(): JsonField = tokenActivatedDateTime + + /** + * Returns the raw JSON value of [tokenizationTfaReasons]. + * + * Unlike [tokenizationTfaReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_tfa_reasons") + @ExcludeMissing + fun _tokenizationTfaReasons(): JsonField> = + tokenizationTfaReasons + + /** + * Returns the raw JSON value of [walletDecision]. + * + * Unlike [walletDecision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wallet_decision") + @ExcludeMissing + fun _walletDecision(): JsonField = walletDecision + + @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 + * [TokenizationResultDetails]. + * + * The following fields are required: + * ```java + * .issuerDecision() + * .tokenizationDeclineReasons() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationResultDetails]. */ + class Builder internal constructor() { + + private var issuerDecision: JsonField? = null + private var tokenizationDeclineReasons: + JsonField>? = + null + private var customerDecision: JsonField = JsonMissing.of() + private var ruleResults: JsonField>? = null + private var tokenActivatedDateTime: JsonField = JsonMissing.of() + private var tokenizationTfaReasons: JsonField>? = + null + private var walletDecision: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenizationResultDetails: TokenizationResultDetails) = apply { + issuerDecision = tokenizationResultDetails.issuerDecision + tokenizationDeclineReasons = + tokenizationResultDetails.tokenizationDeclineReasons.map { it.toMutableList() } + customerDecision = tokenizationResultDetails.customerDecision + ruleResults = tokenizationResultDetails.ruleResults.map { it.toMutableList() } + tokenActivatedDateTime = tokenizationResultDetails.tokenActivatedDateTime + tokenizationTfaReasons = + tokenizationResultDetails.tokenizationTfaReasons.map { it.toMutableList() } + walletDecision = tokenizationResultDetails.walletDecision + additionalProperties = tokenizationResultDetails.additionalProperties.toMutableMap() + } + + /** Lithic's tokenization decision. */ + fun issuerDecision(issuerDecision: String) = + issuerDecision(JsonField.of(issuerDecision)) + + /** + * Sets [Builder.issuerDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerDecision] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuerDecision(issuerDecision: JsonField) = apply { + this.issuerDecision = issuerDecision + } + + /** List of reasons why the tokenization was declined */ + fun tokenizationDeclineReasons( + tokenizationDeclineReasons: List + ) = tokenizationDeclineReasons(JsonField.of(tokenizationDeclineReasons)) + + /** + * Sets [Builder.tokenizationDeclineReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationDeclineReasons] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tokenizationDeclineReasons( + tokenizationDeclineReasons: JsonField> + ) = apply { + this.tokenizationDeclineReasons = + tokenizationDeclineReasons.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationDeclineReason] to [tokenizationDeclineReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTokenizationDeclineReason(tokenizationDeclineReason: TokenizationDeclineReason) = + apply { + tokenizationDeclineReasons = + (tokenizationDeclineReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("tokenizationDeclineReasons", it) + .add(tokenizationDeclineReason) + } + } + + /** The customer's tokenization decision if applicable. */ + fun customerDecision(customerDecision: String?) = + customerDecision(JsonField.ofNullable(customerDecision)) + + /** + * Alias for calling [Builder.customerDecision] with `customerDecision.orElse(null)`. + */ + fun customerDecision(customerDecision: Optional) = + customerDecision(customerDecision.getOrNull()) + + /** + * Sets [Builder.customerDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.customerDecision] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerDecision(customerDecision: JsonField) = apply { + this.customerDecision = customerDecision + } + + /** Results from rules that were evaluated for this tokenization */ + fun ruleResults(ruleResults: List) = + ruleResults(JsonField.of(ruleResults)) + + /** + * Sets [Builder.ruleResults] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleResults] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun ruleResults(ruleResults: JsonField>) = apply { + this.ruleResults = ruleResults.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationRuleResult] to [ruleResults]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRuleResult(ruleResult: TokenizationRuleResult) = apply { + ruleResults = + (ruleResults ?: JsonField.of(mutableListOf())).also { + checkKnown("ruleResults", it).add(ruleResult) + } + } + + /** An RFC 3339 timestamp indicating when the tokenization succeeded. */ + fun tokenActivatedDateTime(tokenActivatedDateTime: OffsetDateTime?) = + tokenActivatedDateTime(JsonField.ofNullable(tokenActivatedDateTime)) + + /** + * Alias for calling [Builder.tokenActivatedDateTime] with + * `tokenActivatedDateTime.orElse(null)`. + */ + fun tokenActivatedDateTime(tokenActivatedDateTime: Optional) = + tokenActivatedDateTime(tokenActivatedDateTime.getOrNull()) + + /** + * Sets [Builder.tokenActivatedDateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenActivatedDateTime] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenActivatedDateTime(tokenActivatedDateTime: JsonField) = apply { + this.tokenActivatedDateTime = tokenActivatedDateTime + } + + /** List of reasons why two-factor authentication was required */ + fun tokenizationTfaReasons(tokenizationTfaReasons: List) = + tokenizationTfaReasons(JsonField.of(tokenizationTfaReasons)) + + /** + * Sets [Builder.tokenizationTfaReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationTfaReasons] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tokenizationTfaReasons( + tokenizationTfaReasons: JsonField> + ) = apply { + this.tokenizationTfaReasons = tokenizationTfaReasons.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationTfaReason] to [tokenizationTfaReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTokenizationTfaReason(tokenizationTfaReason: TokenizationTfaReason) = apply { + tokenizationTfaReasons = + (tokenizationTfaReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("tokenizationTfaReasons", it).add(tokenizationTfaReason) + } + } + + /** The wallet's recommended decision. */ + fun walletDecision(walletDecision: String?) = + walletDecision(JsonField.ofNullable(walletDecision)) + + /** Alias for calling [Builder.walletDecision] with `walletDecision.orElse(null)`. */ + fun walletDecision(walletDecision: Optional) = + walletDecision(walletDecision.getOrNull()) + + /** + * Sets [Builder.walletDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.walletDecision] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun walletDecision(walletDecision: JsonField) = apply { + this.walletDecision = walletDecision + } + + 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 [TokenizationResultDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .issuerDecision() + * .tokenizationDeclineReasons() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationResultDetails = + TokenizationResultDetails( + checkRequired("issuerDecision", issuerDecision), + checkRequired("tokenizationDeclineReasons", tokenizationDeclineReasons).map { + it.toImmutable() + }, + customerDecision, + (ruleResults ?: JsonMissing.of()).map { it.toImmutable() }, + tokenActivatedDateTime, + (tokenizationTfaReasons ?: JsonMissing.of()).map { it.toImmutable() }, + walletDecision, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationResultDetails = apply { + if (validated) { + return@apply + } + + issuerDecision() + tokenizationDeclineReasons().forEach { it.validate() } + customerDecision() + ruleResults().ifPresent { it.forEach { it.validate() } } + tokenActivatedDateTime() + tokenizationTfaReasons().ifPresent { it.forEach { it.validate() } } + walletDecision() + 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 (issuerDecision.asKnown().isPresent) 1 else 0) + + (tokenizationDeclineReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (customerDecision.asKnown().isPresent) 1 else 0) + + (ruleResults.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (tokenActivatedDateTime.asKnown().isPresent) 1 else 0) + + (tokenizationTfaReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (walletDecision.asKnown().isPresent) 1 else 0) + + class TokenizationDeclineReason + @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 ACCOUNT_SCORE_1 = of("ACCOUNT_SCORE_1") + + @JvmField + val ALL_WALLET_DECLINE_REASONS_PRESENT = of("ALL_WALLET_DECLINE_REASONS_PRESENT") + + @JvmField val CARD_EXPIRY_MONTH_MISMATCH = of("CARD_EXPIRY_MONTH_MISMATCH") + + @JvmField val CARD_EXPIRY_YEAR_MISMATCH = of("CARD_EXPIRY_YEAR_MISMATCH") + + @JvmField val CARD_INVALID_STATE = of("CARD_INVALID_STATE") + + @JvmField val CUSTOMER_RED_PATH = of("CUSTOMER_RED_PATH") + + @JvmField val CVC_MISMATCH = of("CVC_MISMATCH") + + @JvmField val DEVICE_SCORE_1 = of("DEVICE_SCORE_1") + + @JvmField val GENERIC_DECLINE = of("GENERIC_DECLINE") + + @JvmField val INVALID_CUSTOMER_RESPONSE = of("INVALID_CUSTOMER_RESPONSE") + + @JvmField val NETWORK_FAILURE = of("NETWORK_FAILURE") + + @JvmField + val WALLET_RECOMMENDED_DECISION_RED = of("WALLET_RECOMMENDED_DECISION_RED") + + @JvmStatic fun of(value: String) = TokenizationDeclineReason(JsonField.of(value)) + } + + /** An enum containing [TokenizationDeclineReason]'s known values. */ + enum class Known { + ACCOUNT_SCORE_1, + ALL_WALLET_DECLINE_REASONS_PRESENT, + CARD_EXPIRY_MONTH_MISMATCH, + CARD_EXPIRY_YEAR_MISMATCH, + CARD_INVALID_STATE, + CUSTOMER_RED_PATH, + CVC_MISMATCH, + DEVICE_SCORE_1, + GENERIC_DECLINE, + INVALID_CUSTOMER_RESPONSE, + NETWORK_FAILURE, + WALLET_RECOMMENDED_DECISION_RED, + } + + /** + * An enum containing [TokenizationDeclineReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [TokenizationDeclineReason] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_SCORE_1, + ALL_WALLET_DECLINE_REASONS_PRESENT, + CARD_EXPIRY_MONTH_MISMATCH, + CARD_EXPIRY_YEAR_MISMATCH, + CARD_INVALID_STATE, + CUSTOMER_RED_PATH, + CVC_MISMATCH, + DEVICE_SCORE_1, + GENERIC_DECLINE, + INVALID_CUSTOMER_RESPONSE, + NETWORK_FAILURE, + WALLET_RECOMMENDED_DECISION_RED, + /** + * An enum member indicating that [TokenizationDeclineReason] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_SCORE_1 -> Value.ACCOUNT_SCORE_1 + ALL_WALLET_DECLINE_REASONS_PRESENT -> Value.ALL_WALLET_DECLINE_REASONS_PRESENT + CARD_EXPIRY_MONTH_MISMATCH -> Value.CARD_EXPIRY_MONTH_MISMATCH + CARD_EXPIRY_YEAR_MISMATCH -> Value.CARD_EXPIRY_YEAR_MISMATCH + CARD_INVALID_STATE -> Value.CARD_INVALID_STATE + CUSTOMER_RED_PATH -> Value.CUSTOMER_RED_PATH + CVC_MISMATCH -> Value.CVC_MISMATCH + DEVICE_SCORE_1 -> Value.DEVICE_SCORE_1 + GENERIC_DECLINE -> Value.GENERIC_DECLINE + INVALID_CUSTOMER_RESPONSE -> Value.INVALID_CUSTOMER_RESPONSE + NETWORK_FAILURE -> Value.NETWORK_FAILURE + WALLET_RECOMMENDED_DECISION_RED -> Value.WALLET_RECOMMENDED_DECISION_RED + 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) { + ACCOUNT_SCORE_1 -> Known.ACCOUNT_SCORE_1 + ALL_WALLET_DECLINE_REASONS_PRESENT -> Known.ALL_WALLET_DECLINE_REASONS_PRESENT + CARD_EXPIRY_MONTH_MISMATCH -> Known.CARD_EXPIRY_MONTH_MISMATCH + CARD_EXPIRY_YEAR_MISMATCH -> Known.CARD_EXPIRY_YEAR_MISMATCH + CARD_INVALID_STATE -> Known.CARD_INVALID_STATE + CUSTOMER_RED_PATH -> Known.CUSTOMER_RED_PATH + CVC_MISMATCH -> Known.CVC_MISMATCH + DEVICE_SCORE_1 -> Known.DEVICE_SCORE_1 + GENERIC_DECLINE -> Known.GENERIC_DECLINE + INVALID_CUSTOMER_RESPONSE -> Known.INVALID_CUSTOMER_RESPONSE + NETWORK_FAILURE -> Known.NETWORK_FAILURE + WALLET_RECOMMENDED_DECISION_RED -> Known.WALLET_RECOMMENDED_DECISION_RED + else -> + throw LithicInvalidDataException( + "Unknown TokenizationDeclineReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TokenizationDeclineReason = 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 TokenizationDeclineReason && 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 TokenizationResultDetails && + issuerDecision == other.issuerDecision && + tokenizationDeclineReasons == other.tokenizationDeclineReasons && + customerDecision == other.customerDecision && + ruleResults == other.ruleResults && + tokenActivatedDateTime == other.tokenActivatedDateTime && + tokenizationTfaReasons == other.tokenizationTfaReasons && + walletDecision == other.walletDecision && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + issuerDecision, + tokenizationDeclineReasons, + customerDecision, + ruleResults, + tokenActivatedDateTime, + tokenizationTfaReasons, + walletDecision, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationResultDetails{issuerDecision=$issuerDecision, tokenizationDeclineReasons=$tokenizationDeclineReasons, customerDecision=$customerDecision, ruleResults=$ruleResults, tokenActivatedDateTime=$tokenActivatedDateTime, tokenizationTfaReasons=$tokenizationTfaReasons, walletDecision=$walletDecision, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DigitalWalletTokenizationResultWebhookEvent && + accountToken == other.accountToken && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + tokenizationResultDetails == other.tokenizationResultDetails && + tokenizationToken == other.tokenizationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + cardToken, + created, + eventType, + tokenizationResultDetails, + tokenizationToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DigitalWalletTokenizationResultWebhookEvent{accountToken=$accountToken, cardToken=$cardToken, created=$created, eventType=$eventType, tokenizationResultDetails=$tokenizationResultDetails, tokenizationToken=$tokenizationToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.kt new file mode 100644 index 000000000..1d0074a28 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.kt @@ -0,0 +1,888 @@ +// 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 DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val activationMethod: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val tokenizationToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("activation_method") + @ExcludeMissing + activationMethod: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + ) : this( + accountToken, + activationMethod, + cardToken, + created, + eventType, + tokenizationToken, + mutableMapOf(), + ) + + /** + * Unique identifier for the user tokenizing a 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun activationMethod(): ActivationMethod = activationMethod.getRequired("activation_method") + + /** + * Unique identifier for the card being tokenized + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Indicate when the request was received from Mastercard or Visa + * + * @throws LithicInvalidDataException if 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") + + /** + * 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") + + /** + * Unique identifier for the tokenization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [activationMethod]. + * + * Unlike [activationMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("activation_method") + @ExcludeMissing + fun _activationMethod(): JsonField = activationMethod + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + @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 + * [DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .activationMethod() + * .cardToken() + * .created() + * .eventType() + * .tokenizationToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var activationMethod: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var tokenizationToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent: + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ) = apply { + accountToken = + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.accountToken + activationMethod = + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .activationMethod + cardToken = + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.cardToken + created = digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.created + eventType = + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.eventType + tokenizationToken = + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .tokenizationToken + additionalProperties = + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .additionalProperties + .toMutableMap() + } + + /** Unique identifier for the user tokenizing a card */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + fun activationMethod(activationMethod: ActivationMethod) = + activationMethod(JsonField.of(activationMethod)) + + /** + * Sets [Builder.activationMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.activationMethod] with a well-typed [ActivationMethod] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun activationMethod(activationMethod: JsonField) = apply { + this.activationMethod = activationMethod + } + + /** Unique identifier for the card being tokenized */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Indicate when the request was received from Mastercard or Visa */ + 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 } + + /** 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 } + + /** Unique identifier for the tokenization */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + 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 + * [DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .activationMethod() + * .cardToken() + * .created() + * .eventType() + * .tokenizationToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("activationMethod", activationMethod), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("tokenizationToken", tokenizationToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + activationMethod().validate() + cardToken() + created() + eventType().validate() + tokenizationToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (activationMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + class ActivationMethod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(type, value, mutableMapOf()) + + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_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 type(): Type = type.getRequired("type") + + /** + * The location to which the authentication code was sent. The format depends on the + * ActivationMethod.Type field. If Type is Email, the Value will be the email address. If + * the Type is Sms, the Value will be the phone 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 value(): String = value.getRequired("value") + + /** + * 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 [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [ActivationMethod]. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActivationMethod]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(activationMethod: ActivationMethod) = apply { + type = activationMethod.type + value = activationMethod.value + additionalProperties = activationMethod.additionalProperties.toMutableMap() + } + + /** + * The communication method that the user has selected to use to receive the + * authentication code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * The location to which the authentication code was sent. The format depends on the + * ActivationMethod.Type field. If Type is Email, the Value will be the email address. + * If the Type is Sms, the Value will be the phone number. + */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + 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 [ActivationMethod]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ActivationMethod = + ActivationMethod( + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ActivationMethod = apply { + if (validated) { + return@apply + } + + type().validate() + value() + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + 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 EMAIL_TO_CARDHOLDER_ADDRESS = of("EMAIL_TO_CARDHOLDER_ADDRESS") + + @JvmField val TEXT_TO_CARDHOLDER_NUMBER = of("TEXT_TO_CARDHOLDER_NUMBER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + EMAIL_TO_CARDHOLDER_ADDRESS, + TEXT_TO_CARDHOLDER_NUMBER, + } + + /** + * 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 { + EMAIL_TO_CARDHOLDER_ADDRESS, + TEXT_TO_CARDHOLDER_NUMBER, + /** 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) { + EMAIL_TO_CARDHOLDER_ADDRESS -> Value.EMAIL_TO_CARDHOLDER_ADDRESS + TEXT_TO_CARDHOLDER_NUMBER -> Value.TEXT_TO_CARDHOLDER_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) { + EMAIL_TO_CARDHOLDER_ADDRESS -> Known.EMAIL_TO_CARDHOLDER_ADDRESS + TEXT_TO_CARDHOLDER_NUMBER -> Known.TEXT_TO_CARDHOLDER_NUMBER + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 ActivationMethod && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActivationMethod{type=$type, value=$value, 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 DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT = + of("digital_wallet.tokenization_two_factor_authentication_code_sent") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + } + + /** + * 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 { + DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT, + /** + * 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) { + DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT -> + Value.DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + 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) { + DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT -> + Known.DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + 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 + + 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 DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent && + accountToken == other.accountToken && + activationMethod == other.activationMethod && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + tokenizationToken == other.tokenizationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + activationMethod, + cardToken, + created, + eventType, + tokenizationToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent{accountToken=$accountToken, activationMethod=$activationMethod, cardToken=$cardToken, created=$created, eventType=$eventType, tokenizationToken=$tokenizationToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.kt new file mode 100644 index 000000000..54d1c639e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.kt @@ -0,0 +1,932 @@ +// 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 DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val activationMethod: JsonField, + private val authenticationCode: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val tokenizationToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("activation_method") + @ExcludeMissing + activationMethod: JsonField = JsonMissing.of(), + @JsonProperty("authentication_code") + @ExcludeMissing + authenticationCode: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + ) : this( + accountToken, + activationMethod, + authenticationCode, + cardToken, + created, + eventType, + tokenizationToken, + mutableMapOf(), + ) + + /** + * Unique identifier for the user tokenizing a 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun activationMethod(): ActivationMethod = activationMethod.getRequired("activation_method") + + /** + * Authentication code to provide to the user tokenizing a 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 authenticationCode(): String = authenticationCode.getRequired("authentication_code") + + /** + * Unique identifier for the card being tokenized + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Indicate when the request was received from Mastercard or Visa + * + * @throws LithicInvalidDataException if 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") + + /** + * 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") + + /** + * Unique identifier for the tokenization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [activationMethod]. + * + * Unlike [activationMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("activation_method") + @ExcludeMissing + fun _activationMethod(): JsonField = activationMethod + + /** + * Returns the raw JSON value of [authenticationCode]. + * + * Unlike [authenticationCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_code") + @ExcludeMissing + fun _authenticationCode(): JsonField = authenticationCode + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + @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 + * [DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .activationMethod() + * .authenticationCode() + * .cardToken() + * .created() + * .eventType() + * .tokenizationToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var activationMethod: JsonField? = null + private var authenticationCode: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var tokenizationToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent: + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + ) = apply { + accountToken = + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.accountToken + activationMethod = + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.activationMethod + authenticationCode = + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.authenticationCode + cardToken = digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.cardToken + created = digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.created + eventType = digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.eventType + tokenizationToken = + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.tokenizationToken + additionalProperties = + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .additionalProperties + .toMutableMap() + } + + /** Unique identifier for the user tokenizing a card */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + fun activationMethod(activationMethod: ActivationMethod) = + activationMethod(JsonField.of(activationMethod)) + + /** + * Sets [Builder.activationMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.activationMethod] with a well-typed [ActivationMethod] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun activationMethod(activationMethod: JsonField) = apply { + this.activationMethod = activationMethod + } + + /** Authentication code to provide to the user tokenizing a card. */ + fun authenticationCode(authenticationCode: String) = + authenticationCode(JsonField.of(authenticationCode)) + + /** + * Sets [Builder.authenticationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authenticationCode(authenticationCode: JsonField) = apply { + this.authenticationCode = authenticationCode + } + + /** Unique identifier for the card being tokenized */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Indicate when the request was received from Mastercard or Visa */ + 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 } + + /** 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 } + + /** Unique identifier for the tokenization */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + 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 + * [DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .activationMethod() + * .authenticationCode() + * .cardToken() + * .created() + * .eventType() + * .tokenizationToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent = + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("activationMethod", activationMethod), + checkRequired("authenticationCode", authenticationCode), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("tokenizationToken", tokenizationToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + activationMethod().validate() + authenticationCode() + cardToken() + created() + eventType().validate() + tokenizationToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (activationMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (authenticationCode.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + class ActivationMethod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(type, value, mutableMapOf()) + + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_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 type(): Type = type.getRequired("type") + + /** + * The location where the user wants to receive the authentication code. The format depends + * on the ActivationMethod.Type field. If Type is Email, the Value will be the email + * address. If the Type is Sms, the Value will be the phone 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 value(): String = value.getRequired("value") + + /** + * 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 [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [ActivationMethod]. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActivationMethod]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(activationMethod: ActivationMethod) = apply { + type = activationMethod.type + value = activationMethod.value + additionalProperties = activationMethod.additionalProperties.toMutableMap() + } + + /** + * The communication method that the user has selected to use to receive the + * authentication code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * The location where the user wants to receive the authentication code. The format + * depends on the ActivationMethod.Type field. If Type is Email, the Value will be the + * email address. If the Type is Sms, the Value will be the phone number. + */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + 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 [ActivationMethod]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ActivationMethod = + ActivationMethod( + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ActivationMethod = apply { + if (validated) { + return@apply + } + + type().validate() + value() + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + 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 EMAIL_TO_CARDHOLDER_ADDRESS = of("EMAIL_TO_CARDHOLDER_ADDRESS") + + @JvmField val TEXT_TO_CARDHOLDER_NUMBER = of("TEXT_TO_CARDHOLDER_NUMBER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + EMAIL_TO_CARDHOLDER_ADDRESS, + TEXT_TO_CARDHOLDER_NUMBER, + } + + /** + * 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 { + EMAIL_TO_CARDHOLDER_ADDRESS, + TEXT_TO_CARDHOLDER_NUMBER, + /** 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) { + EMAIL_TO_CARDHOLDER_ADDRESS -> Value.EMAIL_TO_CARDHOLDER_ADDRESS + TEXT_TO_CARDHOLDER_NUMBER -> Value.TEXT_TO_CARDHOLDER_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) { + EMAIL_TO_CARDHOLDER_ADDRESS -> Known.EMAIL_TO_CARDHOLDER_ADDRESS + TEXT_TO_CARDHOLDER_NUMBER -> Known.TEXT_TO_CARDHOLDER_NUMBER + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 ActivationMethod && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActivationMethod{type=$type, value=$value, 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 DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE = + of("digital_wallet.tokenization_two_factor_authentication_code") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + } + + /** + * 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 { + DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE, + /** + * 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) { + DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE -> + Value.DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + 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) { + DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE -> + Known.DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + 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 + + 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 DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent && + accountToken == other.accountToken && + activationMethod == other.activationMethod && + authenticationCode == other.authenticationCode && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + tokenizationToken == other.tokenizationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + activationMethod, + authenticationCode, + cardToken, + created, + eventType, + tokenizationToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent{accountToken=$accountToken, activationMethod=$activationMethod, authenticationCode=$authenticationCode, cardToken=$cardToken, created=$created, eventType=$eventType, tokenizationToken=$tokenizationToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationUpdatedWebhookEvent.kt new file mode 100644 index 000000000..e7c7ea9e8 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DigitalWalletTokenizationUpdatedWebhookEvent.kt @@ -0,0 +1,477 @@ +// 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 DigitalWalletTokenizationUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val tokenization: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("tokenization") + @ExcludeMissing + tokenization: JsonField = JsonMissing.of(), + ) : this(accountToken, cardToken, created, eventType, tokenization, mutableMapOf()) + + /** + * Account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountToken(): String = accountToken.getRequired("account_token") + + /** + * Card token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Created date + * + * @throws LithicInvalidDataException if 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") + + /** + * 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") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenization(): Tokenization = tokenization.getRequired("tokenization") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [tokenization]. + * + * Unlike [tokenization], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tokenization") + @ExcludeMissing + fun _tokenization(): JsonField = tokenization + + @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 + * [DigitalWalletTokenizationUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .tokenization() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DigitalWalletTokenizationUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var tokenization: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + digitalWalletTokenizationUpdatedWebhookEvent: + DigitalWalletTokenizationUpdatedWebhookEvent + ) = apply { + accountToken = digitalWalletTokenizationUpdatedWebhookEvent.accountToken + cardToken = digitalWalletTokenizationUpdatedWebhookEvent.cardToken + created = digitalWalletTokenizationUpdatedWebhookEvent.created + eventType = digitalWalletTokenizationUpdatedWebhookEvent.eventType + tokenization = digitalWalletTokenizationUpdatedWebhookEvent.tokenization + additionalProperties = + digitalWalletTokenizationUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Account token */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Card token */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Created date */ + 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 } + + /** 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 tokenization(tokenization: Tokenization) = tokenization(JsonField.of(tokenization)) + + /** + * Sets [Builder.tokenization] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenization] with a well-typed [Tokenization] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenization(tokenization: JsonField) = apply { + this.tokenization = tokenization + } + + 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 [DigitalWalletTokenizationUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .tokenization() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DigitalWalletTokenizationUpdatedWebhookEvent = + DigitalWalletTokenizationUpdatedWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("tokenization", tokenization), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DigitalWalletTokenizationUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + cardToken() + created() + eventType().validate() + tokenization().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 (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (tokenization.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 DIGITAL_WALLET_TOKENIZATION_UPDATED = of("digital_wallet.tokenization_updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DIGITAL_WALLET_TOKENIZATION_UPDATED + } + + /** + * 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 { + DIGITAL_WALLET_TOKENIZATION_UPDATED, + /** + * 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) { + DIGITAL_WALLET_TOKENIZATION_UPDATED -> Value.DIGITAL_WALLET_TOKENIZATION_UPDATED + 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) { + DIGITAL_WALLET_TOKENIZATION_UPDATED -> Known.DIGITAL_WALLET_TOKENIZATION_UPDATED + 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 + + 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 DigitalWalletTokenizationUpdatedWebhookEvent && + accountToken == other.accountToken && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + tokenization == other.tokenization && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + cardToken, + created, + eventType, + tokenization, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DigitalWalletTokenizationUpdatedWebhookEvent{accountToken=$accountToken, cardToken=$cardToken, created=$created, eventType=$eventType, tokenization=$tokenization, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeEvidenceUploadFailedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeEvidenceUploadFailedWebhookEvent.kt new file mode 100644 index 000000000..3ec958c7a --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeEvidenceUploadFailedWebhookEvent.kt @@ -0,0 +1,627 @@ +// 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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Dispute evidence. */ +class DisputeEvidenceUploadFailedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val created: JsonField, + private val disputeToken: JsonField, + private val uploadStatus: JsonField, + private val downloadUrl: JsonField, + private val filename: JsonField, + private val uploadUrl: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("dispute_token") + @ExcludeMissing + disputeToken: JsonField = JsonMissing.of(), + @JsonProperty("upload_status") + @ExcludeMissing + uploadStatus: JsonField = JsonMissing.of(), + @JsonProperty("download_url") + @ExcludeMissing + downloadUrl: JsonField = JsonMissing.of(), + @JsonProperty("filename") @ExcludeMissing filename: JsonField = JsonMissing.of(), + @JsonProperty("upload_url") @ExcludeMissing uploadUrl: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + created, + disputeToken, + uploadStatus, + downloadUrl, + filename, + uploadUrl, + eventType, + mutableMapOf(), + ) + + fun toDisputeEvidence(): DisputeEvidence = + DisputeEvidence.builder() + .token(token) + .created(created) + .disputeToken(disputeToken) + .uploadStatus(uploadStatus) + .downloadUrl(downloadUrl) + .filename(filename) + .uploadUrl(uploadUrl) + .build() + + /** + * Globally unique identifier. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Timestamp of when dispute evidence was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * Dispute token evidence is attached to. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun disputeToken(): String = disputeToken.getRequired("dispute_token") + + /** + * Upload status types: + * * `DELETED` - Evidence was deleted. + * * `ERROR` - Evidence upload failed. + * * `PENDING` - Evidence is pending upload. + * * `REJECTED` - Evidence was rejected. + * * `UPLOADED` - Evidence was uploaded. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun uploadStatus(): DisputeEvidence.UploadStatus = uploadStatus.getRequired("upload_status") + + /** + * URL to download evidence. Only shown when `upload_status` is `UPLOADED`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun downloadUrl(): Optional = downloadUrl.getOptional("download_url") + + /** + * File name of evidence. Recommended to give the dispute evidence a human-readable identifier. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filename(): Optional = filename.getOptional("filename") + + /** + * URL to upload evidence. Only shown when `upload_status` is `PENDING`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun uploadUrl(): Optional = uploadUrl.getOptional("upload_url") + + /** + * 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 [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 [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 [disputeToken]. + * + * Unlike [disputeToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dispute_token") + @ExcludeMissing + fun _disputeToken(): JsonField = disputeToken + + /** + * Returns the raw JSON value of [uploadStatus]. + * + * Unlike [uploadStatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("upload_status") + @ExcludeMissing + fun _uploadStatus(): JsonField = uploadStatus + + /** + * Returns the raw JSON value of [downloadUrl]. + * + * Unlike [downloadUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("download_url") + @ExcludeMissing + fun _downloadUrl(): JsonField = downloadUrl + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [uploadUrl]. + * + * Unlike [uploadUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("upload_url") @ExcludeMissing fun _uploadUrl(): JsonField = uploadUrl + + /** + * 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 + * [DisputeEvidenceUploadFailedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .disputeToken() + * .uploadStatus() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DisputeEvidenceUploadFailedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var created: JsonField? = null + private var disputeToken: JsonField? = null + private var uploadStatus: JsonField? = null + private var downloadUrl: JsonField = JsonMissing.of() + private var filename: JsonField = JsonMissing.of() + private var uploadUrl: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + disputeEvidenceUploadFailedWebhookEvent: DisputeEvidenceUploadFailedWebhookEvent + ) = apply { + token = disputeEvidenceUploadFailedWebhookEvent.token + created = disputeEvidenceUploadFailedWebhookEvent.created + disputeToken = disputeEvidenceUploadFailedWebhookEvent.disputeToken + uploadStatus = disputeEvidenceUploadFailedWebhookEvent.uploadStatus + downloadUrl = disputeEvidenceUploadFailedWebhookEvent.downloadUrl + filename = disputeEvidenceUploadFailedWebhookEvent.filename + uploadUrl = disputeEvidenceUploadFailedWebhookEvent.uploadUrl + eventType = disputeEvidenceUploadFailedWebhookEvent.eventType + additionalProperties = + disputeEvidenceUploadFailedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Timestamp of when dispute evidence was created. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Dispute token evidence is attached to. */ + fun disputeToken(disputeToken: String) = disputeToken(JsonField.of(disputeToken)) + + /** + * Sets [Builder.disputeToken] to an arbitrary JSON value. + * + * You should usually call [Builder.disputeToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disputeToken(disputeToken: JsonField) = apply { + this.disputeToken = disputeToken + } + + /** + * Upload status types: + * * `DELETED` - Evidence was deleted. + * * `ERROR` - Evidence upload failed. + * * `PENDING` - Evidence is pending upload. + * * `REJECTED` - Evidence was rejected. + * * `UPLOADED` - Evidence was uploaded. + */ + fun uploadStatus(uploadStatus: DisputeEvidence.UploadStatus) = + uploadStatus(JsonField.of(uploadStatus)) + + /** + * Sets [Builder.uploadStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.uploadStatus] with a well-typed + * [DisputeEvidence.UploadStatus] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun uploadStatus(uploadStatus: JsonField) = apply { + this.uploadStatus = uploadStatus + } + + /** URL to download evidence. Only shown when `upload_status` is `UPLOADED`. */ + fun downloadUrl(downloadUrl: String) = downloadUrl(JsonField.of(downloadUrl)) + + /** + * Sets [Builder.downloadUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.downloadUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun downloadUrl(downloadUrl: JsonField) = apply { this.downloadUrl = downloadUrl } + + /** + * File name of evidence. Recommended to give the dispute evidence a human-readable + * identifier. + */ + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filename(filename: JsonField) = apply { this.filename = filename } + + /** URL to upload evidence. Only shown when `upload_status` is `PENDING`. */ + fun uploadUrl(uploadUrl: String) = uploadUrl(JsonField.of(uploadUrl)) + + /** + * Sets [Builder.uploadUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.uploadUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun uploadUrl(uploadUrl: JsonField) = apply { this.uploadUrl = uploadUrl } + + /** 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 [DisputeEvidenceUploadFailedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .disputeToken() + * .uploadStatus() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DisputeEvidenceUploadFailedWebhookEvent = + DisputeEvidenceUploadFailedWebhookEvent( + checkRequired("token", token), + checkRequired("created", created), + checkRequired("disputeToken", disputeToken), + checkRequired("uploadStatus", uploadStatus), + downloadUrl, + filename, + uploadUrl, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DisputeEvidenceUploadFailedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + created() + disputeToken() + uploadStatus().validate() + downloadUrl() + filename() + uploadUrl() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (disputeToken.asKnown().isPresent) 1 else 0) + + (uploadStatus.asKnown().getOrNull()?.validity() ?: 0) + + (if (downloadUrl.asKnown().isPresent) 1 else 0) + + (if (filename.asKnown().isPresent) 1 else 0) + + (if (uploadUrl.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 DISPUTE_EVIDENCE_UPLOAD_FAILED = of("dispute_evidence.upload_failed") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DISPUTE_EVIDENCE_UPLOAD_FAILED + } + + /** + * 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 { + DISPUTE_EVIDENCE_UPLOAD_FAILED, + /** + * 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) { + DISPUTE_EVIDENCE_UPLOAD_FAILED -> Value.DISPUTE_EVIDENCE_UPLOAD_FAILED + 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) { + DISPUTE_EVIDENCE_UPLOAD_FAILED -> Known.DISPUTE_EVIDENCE_UPLOAD_FAILED + 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 + + 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 DisputeEvidenceUploadFailedWebhookEvent && + token == other.token && + created == other.created && + disputeToken == other.disputeToken && + uploadStatus == other.uploadStatus && + downloadUrl == other.downloadUrl && + filename == other.filename && + uploadUrl == other.uploadUrl && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + created, + disputeToken, + uploadStatus, + downloadUrl, + filename, + uploadUrl, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DisputeEvidenceUploadFailedWebhookEvent{token=$token, created=$created, disputeToken=$disputeToken, uploadStatus=$uploadStatus, downloadUrl=$downloadUrl, filename=$filename, uploadUrl=$uploadUrl, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeTransactionCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeTransactionCreatedWebhookEvent.kt new file mode 100644 index 000000000..7bfdb617f --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeTransactionCreatedWebhookEvent.kt @@ -0,0 +1,951 @@ +// 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 + +/** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ +class DisputeTransactionCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountToken: JsonField, + private val cardToken: JsonField, + private val caseId: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val disposition: JsonField, + private val events: JsonField>, + private val liabilityAllocation: JsonField, + private val merchant: JsonField, + private val network: JsonField, + private val status: JsonField, + private val transactionSeries: JsonField, + private val updated: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("case_id") @ExcludeMissing caseId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("disposition") + @ExcludeMissing + disposition: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("liability_allocation") + @ExcludeMissing + liabilityAllocation: JsonField = JsonMissing.of(), + @JsonProperty("merchant") @ExcludeMissing merchant: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountToken, + cardToken, + caseId, + created, + currency, + disposition, + events, + liabilityAllocation, + merchant, + network, + status, + transactionSeries, + updated, + eventType, + mutableMapOf(), + ) + + fun toDisputeV2(): DisputeV2 = + DisputeV2.builder() + .token(token) + .accountToken(accountToken) + .cardToken(cardToken) + .caseId(caseId) + .created(created) + .currency(currency) + .disposition(disposition) + .events(events) + .liabilityAllocation(liabilityAllocation) + .merchant(merchant) + .network(network) + .status(status) + .transactionSeries(transactionSeries) + .updated(updated) + .build() + + /** + * Token assigned by Lithic for the dispute, in UUID format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Token for the account associated with the dispute, in UUID format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountToken(): String = accountToken.getRequired("account_token") + + /** + * Token for the card used in the dispute, in UUID format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Identifier assigned by the network for this dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caseId(): Optional = caseId.getOptional("case_id") + + /** + * When the dispute was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * Three-letter ISO 4217 currency 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 currency(): String = currency.getRequired("currency") + + /** + * Dispute resolution outcome + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun disposition(): Optional = disposition.getOptional("disposition") + + /** + * Chronological list of events that have occurred in the dispute lifecycle + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * Current breakdown of how liability is allocated for the disputed 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 liabilityAllocation(): DisputeV2.LiabilityAllocation = + liabilityAllocation.getRequired("liability_allocation") + + /** + * @throws LithicInvalidDataException if 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(): Merchant = merchant.getRequired("merchant") + + /** + * Card network handling the dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): DisputeV2.Network = network.getRequired("network") + + /** + * Current status of the dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Contains identifiers for the transaction and specific event within being disputed; null if no + * transaction can be identified + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + + /** + * When the dispute was last updated. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [caseId]. + * + * Unlike [caseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("case_id") @ExcludeMissing fun _caseId(): JsonField = caseId + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [disposition]. + * + * Unlike [disposition], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disposition") + @ExcludeMissing + fun _disposition(): JsonField = disposition + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [liabilityAllocation]. + * + * Unlike [liabilityAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("liability_allocation") + @ExcludeMissing + fun _liabilityAllocation(): JsonField = liabilityAllocation + + /** + * 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 [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 [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 [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = transactionSeries + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [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 + * [DisputeTransactionCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .cardToken() + * .caseId() + * .created() + * .currency() + * .disposition() + * .events() + * .liabilityAllocation() + * .merchant() + * .network() + * .status() + * .transactionSeries() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DisputeTransactionCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var caseId: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var disposition: JsonField? = null + private var events: JsonField>? = null + private var liabilityAllocation: JsonField? = null + private var merchant: JsonField? = null + private var network: JsonField? = null + private var status: JsonField? = null + private var transactionSeries: JsonField? = null + private var updated: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + disputeTransactionCreatedWebhookEvent: DisputeTransactionCreatedWebhookEvent + ) = apply { + token = disputeTransactionCreatedWebhookEvent.token + accountToken = disputeTransactionCreatedWebhookEvent.accountToken + cardToken = disputeTransactionCreatedWebhookEvent.cardToken + caseId = disputeTransactionCreatedWebhookEvent.caseId + created = disputeTransactionCreatedWebhookEvent.created + currency = disputeTransactionCreatedWebhookEvent.currency + disposition = disputeTransactionCreatedWebhookEvent.disposition + events = disputeTransactionCreatedWebhookEvent.events.map { it.toMutableList() } + liabilityAllocation = disputeTransactionCreatedWebhookEvent.liabilityAllocation + merchant = disputeTransactionCreatedWebhookEvent.merchant + network = disputeTransactionCreatedWebhookEvent.network + status = disputeTransactionCreatedWebhookEvent.status + transactionSeries = disputeTransactionCreatedWebhookEvent.transactionSeries + updated = disputeTransactionCreatedWebhookEvent.updated + eventType = disputeTransactionCreatedWebhookEvent.eventType + additionalProperties = + disputeTransactionCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Token assigned by Lithic for the dispute, in UUID format. */ + 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 } + + /** Token for the account associated with the dispute, in UUID format. */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Token for the card used in the dispute, in UUID format. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Identifier assigned by the network for this dispute. */ + fun caseId(caseId: String?) = caseId(JsonField.ofNullable(caseId)) + + /** Alias for calling [Builder.caseId] with `caseId.orElse(null)`. */ + fun caseId(caseId: Optional) = caseId(caseId.getOrNull()) + + /** + * Sets [Builder.caseId] to an arbitrary JSON value. + * + * You should usually call [Builder.caseId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun caseId(caseId: JsonField) = apply { this.caseId = caseId } + + /** When the dispute was created. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Three-letter ISO 4217 currency code. */ + 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 } + + /** Dispute resolution outcome */ + fun disposition(disposition: DisputeV2.Disposition?) = + disposition(JsonField.ofNullable(disposition)) + + /** Alias for calling [Builder.disposition] with `disposition.orElse(null)`. */ + fun disposition(disposition: Optional) = + disposition(disposition.getOrNull()) + + /** + * Sets [Builder.disposition] to an arbitrary JSON value. + * + * You should usually call [Builder.disposition] with a well-typed [DisputeV2.Disposition] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun disposition(disposition: JsonField) = apply { + this.disposition = disposition + } + + /** Chronological list of events that have occurred in the dispute lifecycle */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [DisputeV2.Event] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: DisputeV2.Event) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** Current breakdown of how liability is allocated for the disputed amount */ + fun liabilityAllocation(liabilityAllocation: DisputeV2.LiabilityAllocation) = + liabilityAllocation(JsonField.of(liabilityAllocation)) + + /** + * Sets [Builder.liabilityAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.liabilityAllocation] with a well-typed + * [DisputeV2.LiabilityAllocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun liabilityAllocation(liabilityAllocation: JsonField) = + apply { + this.liabilityAllocation = liabilityAllocation + } + + fun merchant(merchant: Merchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed [Merchant] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchant(merchant: JsonField) = apply { this.merchant = merchant } + + /** Card network handling the dispute. */ + fun network(network: DisputeV2.Network) = network(JsonField.of(network)) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [DisputeV2.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 } + + /** Current status of the dispute. */ + fun status(status: DisputeV2.Status?) = status(JsonField.ofNullable(status)) + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [DisputeV2.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 } + + /** + * Contains identifiers for the transaction and specific event within being disputed; null + * if no transaction can be identified + */ + fun transactionSeries(transactionSeries: DisputeV2.TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed + * [DisputeV2.TransactionSeries] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transactionSeries(transactionSeries: JsonField) = apply { + this.transactionSeries = transactionSeries + } + + /** When the dispute was last updated. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** 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 [DisputeTransactionCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .cardToken() + * .caseId() + * .created() + * .currency() + * .disposition() + * .events() + * .liabilityAllocation() + * .merchant() + * .network() + * .status() + * .transactionSeries() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DisputeTransactionCreatedWebhookEvent = + DisputeTransactionCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("caseId", caseId), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("disposition", disposition), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("liabilityAllocation", liabilityAllocation), + checkRequired("merchant", merchant), + checkRequired("network", network), + checkRequired("status", status), + checkRequired("transactionSeries", transactionSeries), + checkRequired("updated", updated), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DisputeTransactionCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountToken() + cardToken() + caseId() + created() + currency() + disposition().ifPresent { it.validate() } + events().forEach { it.validate() } + liabilityAllocation().validate() + merchant().validate() + network().validate() + status().ifPresent { it.validate() } + transactionSeries().ifPresent { it.validate() } + updated() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (caseId.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (disposition.asKnown().getOrNull()?.validity() ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (liabilityAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 DISPUTE_TRANSACTION_CREATED = of("dispute_transaction.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DISPUTE_TRANSACTION_CREATED + } + + /** + * 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 { + DISPUTE_TRANSACTION_CREATED, + /** + * 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) { + DISPUTE_TRANSACTION_CREATED -> Value.DISPUTE_TRANSACTION_CREATED + 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) { + DISPUTE_TRANSACTION_CREATED -> Known.DISPUTE_TRANSACTION_CREATED + 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 + + 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 DisputeTransactionCreatedWebhookEvent && + token == other.token && + accountToken == other.accountToken && + cardToken == other.cardToken && + caseId == other.caseId && + created == other.created && + currency == other.currency && + disposition == other.disposition && + events == other.events && + liabilityAllocation == other.liabilityAllocation && + merchant == other.merchant && + network == other.network && + status == other.status && + transactionSeries == other.transactionSeries && + updated == other.updated && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountToken, + cardToken, + caseId, + created, + currency, + disposition, + events, + liabilityAllocation, + merchant, + network, + status, + transactionSeries, + updated, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DisputeTransactionCreatedWebhookEvent{token=$token, accountToken=$accountToken, cardToken=$cardToken, caseId=$caseId, created=$created, currency=$currency, disposition=$disposition, events=$events, liabilityAllocation=$liabilityAllocation, merchant=$merchant, network=$network, status=$status, transactionSeries=$transactionSeries, updated=$updated, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeTransactionUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeTransactionUpdatedWebhookEvent.kt new file mode 100644 index 000000000..1c6073980 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeTransactionUpdatedWebhookEvent.kt @@ -0,0 +1,951 @@ +// 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 + +/** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ +class DisputeTransactionUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountToken: JsonField, + private val cardToken: JsonField, + private val caseId: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val disposition: JsonField, + private val events: JsonField>, + private val liabilityAllocation: JsonField, + private val merchant: JsonField, + private val network: JsonField, + private val status: JsonField, + private val transactionSeries: JsonField, + private val updated: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("case_id") @ExcludeMissing caseId: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("disposition") + @ExcludeMissing + disposition: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("liability_allocation") + @ExcludeMissing + liabilityAllocation: JsonField = JsonMissing.of(), + @JsonProperty("merchant") @ExcludeMissing merchant: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountToken, + cardToken, + caseId, + created, + currency, + disposition, + events, + liabilityAllocation, + merchant, + network, + status, + transactionSeries, + updated, + eventType, + mutableMapOf(), + ) + + fun toDisputeV2(): DisputeV2 = + DisputeV2.builder() + .token(token) + .accountToken(accountToken) + .cardToken(cardToken) + .caseId(caseId) + .created(created) + .currency(currency) + .disposition(disposition) + .events(events) + .liabilityAllocation(liabilityAllocation) + .merchant(merchant) + .network(network) + .status(status) + .transactionSeries(transactionSeries) + .updated(updated) + .build() + + /** + * Token assigned by Lithic for the dispute, in UUID format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Token for the account associated with the dispute, in UUID format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountToken(): String = accountToken.getRequired("account_token") + + /** + * Token for the card used in the dispute, in UUID format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Identifier assigned by the network for this dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caseId(): Optional = caseId.getOptional("case_id") + + /** + * When the dispute was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * Three-letter ISO 4217 currency 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 currency(): String = currency.getRequired("currency") + + /** + * Dispute resolution outcome + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun disposition(): Optional = disposition.getOptional("disposition") + + /** + * Chronological list of events that have occurred in the dispute lifecycle + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * Current breakdown of how liability is allocated for the disputed 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 liabilityAllocation(): DisputeV2.LiabilityAllocation = + liabilityAllocation.getRequired("liability_allocation") + + /** + * @throws LithicInvalidDataException if 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(): Merchant = merchant.getRequired("merchant") + + /** + * Card network handling the dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): DisputeV2.Network = network.getRequired("network") + + /** + * Current status of the dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Contains identifiers for the transaction and specific event within being disputed; null if no + * transaction can be identified + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + + /** + * When the dispute was last updated. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [caseId]. + * + * Unlike [caseId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("case_id") @ExcludeMissing fun _caseId(): JsonField = caseId + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [disposition]. + * + * Unlike [disposition], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disposition") + @ExcludeMissing + fun _disposition(): JsonField = disposition + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [liabilityAllocation]. + * + * Unlike [liabilityAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("liability_allocation") + @ExcludeMissing + fun _liabilityAllocation(): JsonField = liabilityAllocation + + /** + * 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 [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 [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 [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = transactionSeries + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [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 + * [DisputeTransactionUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .cardToken() + * .caseId() + * .created() + * .currency() + * .disposition() + * .events() + * .liabilityAllocation() + * .merchant() + * .network() + * .status() + * .transactionSeries() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DisputeTransactionUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var caseId: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var disposition: JsonField? = null + private var events: JsonField>? = null + private var liabilityAllocation: JsonField? = null + private var merchant: JsonField? = null + private var network: JsonField? = null + private var status: JsonField? = null + private var transactionSeries: JsonField? = null + private var updated: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + disputeTransactionUpdatedWebhookEvent: DisputeTransactionUpdatedWebhookEvent + ) = apply { + token = disputeTransactionUpdatedWebhookEvent.token + accountToken = disputeTransactionUpdatedWebhookEvent.accountToken + cardToken = disputeTransactionUpdatedWebhookEvent.cardToken + caseId = disputeTransactionUpdatedWebhookEvent.caseId + created = disputeTransactionUpdatedWebhookEvent.created + currency = disputeTransactionUpdatedWebhookEvent.currency + disposition = disputeTransactionUpdatedWebhookEvent.disposition + events = disputeTransactionUpdatedWebhookEvent.events.map { it.toMutableList() } + liabilityAllocation = disputeTransactionUpdatedWebhookEvent.liabilityAllocation + merchant = disputeTransactionUpdatedWebhookEvent.merchant + network = disputeTransactionUpdatedWebhookEvent.network + status = disputeTransactionUpdatedWebhookEvent.status + transactionSeries = disputeTransactionUpdatedWebhookEvent.transactionSeries + updated = disputeTransactionUpdatedWebhookEvent.updated + eventType = disputeTransactionUpdatedWebhookEvent.eventType + additionalProperties = + disputeTransactionUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Token assigned by Lithic for the dispute, in UUID format. */ + 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 } + + /** Token for the account associated with the dispute, in UUID format. */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Token for the card used in the dispute, in UUID format. */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Identifier assigned by the network for this dispute. */ + fun caseId(caseId: String?) = caseId(JsonField.ofNullable(caseId)) + + /** Alias for calling [Builder.caseId] with `caseId.orElse(null)`. */ + fun caseId(caseId: Optional) = caseId(caseId.getOrNull()) + + /** + * Sets [Builder.caseId] to an arbitrary JSON value. + * + * You should usually call [Builder.caseId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun caseId(caseId: JsonField) = apply { this.caseId = caseId } + + /** When the dispute was created. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Three-letter ISO 4217 currency code. */ + 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 } + + /** Dispute resolution outcome */ + fun disposition(disposition: DisputeV2.Disposition?) = + disposition(JsonField.ofNullable(disposition)) + + /** Alias for calling [Builder.disposition] with `disposition.orElse(null)`. */ + fun disposition(disposition: Optional) = + disposition(disposition.getOrNull()) + + /** + * Sets [Builder.disposition] to an arbitrary JSON value. + * + * You should usually call [Builder.disposition] with a well-typed [DisputeV2.Disposition] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun disposition(disposition: JsonField) = apply { + this.disposition = disposition + } + + /** Chronological list of events that have occurred in the dispute lifecycle */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [DisputeV2.Event] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: DisputeV2.Event) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** Current breakdown of how liability is allocated for the disputed amount */ + fun liabilityAllocation(liabilityAllocation: DisputeV2.LiabilityAllocation) = + liabilityAllocation(JsonField.of(liabilityAllocation)) + + /** + * Sets [Builder.liabilityAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.liabilityAllocation] with a well-typed + * [DisputeV2.LiabilityAllocation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun liabilityAllocation(liabilityAllocation: JsonField) = + apply { + this.liabilityAllocation = liabilityAllocation + } + + fun merchant(merchant: Merchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed [Merchant] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchant(merchant: JsonField) = apply { this.merchant = merchant } + + /** Card network handling the dispute. */ + fun network(network: DisputeV2.Network) = network(JsonField.of(network)) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [DisputeV2.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 } + + /** Current status of the dispute. */ + fun status(status: DisputeV2.Status?) = status(JsonField.ofNullable(status)) + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [DisputeV2.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 } + + /** + * Contains identifiers for the transaction and specific event within being disputed; null + * if no transaction can be identified + */ + fun transactionSeries(transactionSeries: DisputeV2.TransactionSeries?) = + transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. */ + fun transactionSeries(transactionSeries: Optional) = + transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed + * [DisputeV2.TransactionSeries] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transactionSeries(transactionSeries: JsonField) = apply { + this.transactionSeries = transactionSeries + } + + /** When the dispute was last updated. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** 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 [DisputeTransactionUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .cardToken() + * .caseId() + * .created() + * .currency() + * .disposition() + * .events() + * .liabilityAllocation() + * .merchant() + * .network() + * .status() + * .transactionSeries() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DisputeTransactionUpdatedWebhookEvent = + DisputeTransactionUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("caseId", caseId), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("disposition", disposition), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("liabilityAllocation", liabilityAllocation), + checkRequired("merchant", merchant), + checkRequired("network", network), + checkRequired("status", status), + checkRequired("transactionSeries", transactionSeries), + checkRequired("updated", updated), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DisputeTransactionUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountToken() + cardToken() + caseId() + created() + currency() + disposition().ifPresent { it.validate() } + events().forEach { it.validate() } + liabilityAllocation().validate() + merchant().validate() + network().validate() + status().ifPresent { it.validate() } + transactionSeries().ifPresent { it.validate() } + updated() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (caseId.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (disposition.asKnown().getOrNull()?.validity() ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (liabilityAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 DISPUTE_TRANSACTION_UPDATED = of("dispute_transaction.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DISPUTE_TRANSACTION_UPDATED + } + + /** + * 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 { + DISPUTE_TRANSACTION_UPDATED, + /** + * 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) { + DISPUTE_TRANSACTION_UPDATED -> Value.DISPUTE_TRANSACTION_UPDATED + 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) { + DISPUTE_TRANSACTION_UPDATED -> Known.DISPUTE_TRANSACTION_UPDATED + 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 + + 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 DisputeTransactionUpdatedWebhookEvent && + token == other.token && + accountToken == other.accountToken && + cardToken == other.cardToken && + caseId == other.caseId && + created == other.created && + currency == other.currency && + disposition == other.disposition && + events == other.events && + liabilityAllocation == other.liabilityAllocation && + merchant == other.merchant && + network == other.network && + status == other.status && + transactionSeries == other.transactionSeries && + updated == other.updated && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountToken, + cardToken, + caseId, + created, + currency, + disposition, + events, + liabilityAllocation, + merchant, + network, + status, + transactionSeries, + updated, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DisputeTransactionUpdatedWebhookEvent{token=$token, accountToken=$accountToken, cardToken=$cardToken, caseId=$caseId, created=$created, currency=$currency, disposition=$disposition, events=$events, liabilityAllocation=$liabilityAllocation, merchant=$merchant, network=$network, status=$status, transactionSeries=$transactionSeries, updated=$updated, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeUpdatedWebhookEvent.kt new file mode 100644 index 000000000..ca1a568e4 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/DisputeUpdatedWebhookEvent.kt @@ -0,0 +1,1300 @@ +// 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 + +/** Dispute. */ +class DisputeUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val amount: JsonField, + private val arbitrationDate: JsonField, + private val created: JsonField, + private val customerFiledDate: JsonField, + private val customerNote: JsonField, + private val networkClaimIds: JsonField>, + private val networkFiledDate: JsonField, + private val networkReasonCode: JsonField, + private val prearbitrationDate: JsonField, + private val primaryClaimId: JsonField, + private val reason: JsonField, + private val representmentDate: JsonField, + private val resolutionDate: JsonField, + private val resolutionNote: JsonField, + private val resolutionReason: JsonField, + private val status: JsonField, + private val transactionToken: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("arbitration_date") + @ExcludeMissing + arbitrationDate: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("customer_filed_date") + @ExcludeMissing + customerFiledDate: JsonField = JsonMissing.of(), + @JsonProperty("customer_note") + @ExcludeMissing + customerNote: JsonField = JsonMissing.of(), + @JsonProperty("network_claim_ids") + @ExcludeMissing + networkClaimIds: JsonField> = JsonMissing.of(), + @JsonProperty("network_filed_date") + @ExcludeMissing + networkFiledDate: JsonField = JsonMissing.of(), + @JsonProperty("network_reason_code") + @ExcludeMissing + networkReasonCode: JsonField = JsonMissing.of(), + @JsonProperty("prearbitration_date") + @ExcludeMissing + prearbitrationDate: JsonField = JsonMissing.of(), + @JsonProperty("primary_claim_id") + @ExcludeMissing + primaryClaimId: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("representment_date") + @ExcludeMissing + representmentDate: JsonField = JsonMissing.of(), + @JsonProperty("resolution_date") + @ExcludeMissing + resolutionDate: JsonField = JsonMissing.of(), + @JsonProperty("resolution_note") + @ExcludeMissing + resolutionNote: JsonField = JsonMissing.of(), + @JsonProperty("resolution_reason") + @ExcludeMissing + resolutionReason: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("transaction_token") + @ExcludeMissing + transactionToken: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + amount, + arbitrationDate, + created, + customerFiledDate, + customerNote, + networkClaimIds, + networkFiledDate, + networkReasonCode, + prearbitrationDate, + primaryClaimId, + reason, + representmentDate, + resolutionDate, + resolutionNote, + resolutionReason, + status, + transactionToken, + eventType, + mutableMapOf(), + ) + + fun toDispute(): Dispute = + Dispute.builder() + .token(token) + .amount(amount) + .arbitrationDate(arbitrationDate) + .created(created) + .customerFiledDate(customerFiledDate) + .customerNote(customerNote) + .networkClaimIds(networkClaimIds) + .networkFiledDate(networkFiledDate) + .networkReasonCode(networkReasonCode) + .prearbitrationDate(prearbitrationDate) + .primaryClaimId(primaryClaimId) + .reason(reason) + .representmentDate(representmentDate) + .resolutionDate(resolutionDate) + .resolutionNote(resolutionNote) + .resolutionReason(resolutionReason) + .status(status) + .transactionToken(transactionToken) + .build() + + /** + * Globally unique identifier. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Amount under dispute. May be different from the original transaction 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 amount(): Long = amount.getRequired("amount") + + /** + * Date dispute entered arbitration. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun arbitrationDate(): Optional = + arbitrationDate.getOptional("arbitration_date") + + /** + * Timestamp of when first Dispute was reported. + * + * @throws LithicInvalidDataException if 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") + + /** + * Date that the dispute was filed by the customer making the dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerFiledDate(): Optional = + customerFiledDate.getOptional("customer_filed_date") + + /** + * End customer description of the reason for the dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerNote(): Optional = customerNote.getOptional("customer_note") + + /** + * Unique identifiers for the dispute from the network. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkClaimIds(): Optional> = networkClaimIds.getOptional("network_claim_ids") + + /** + * Date that the dispute was submitted to the network. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkFiledDate(): Optional = + networkFiledDate.getOptional("network_filed_date") + + /** + * Network reason code used to file the dispute. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun networkReasonCode(): Optional = networkReasonCode.getOptional("network_reason_code") + + /** + * Date dispute entered pre-arbitration. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun prearbitrationDate(): Optional = + prearbitrationDate.getOptional("prearbitration_date") + + /** + * Unique identifier for the dispute from the network. If there are multiple, this will be the + * first claim id set by the network + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun primaryClaimId(): Optional = primaryClaimId.getOptional("primary_claim_id") + + /** + * Dispute reason: + * * `ATM_CASH_MISDISPENSE`: ATM cash misdispense. + * * `CANCELLED`: Transaction was cancelled by the customer. + * * `DUPLICATED`: The transaction was a duplicate. + * * `FRAUD_CARD_NOT_PRESENT`: Fraudulent transaction, card not present. + * * `FRAUD_CARD_PRESENT`: Fraudulent transaction, card present. + * * `FRAUD_OTHER`: Fraudulent transaction, other types such as questionable merchant activity. + * * `GOODS_SERVICES_NOT_AS_DESCRIBED`: The goods or services were not as described. + * * `GOODS_SERVICES_NOT_RECEIVED`: The goods or services were not received. + * * `INCORRECT_AMOUNT`: The transaction amount was incorrect. + * * `MISSING_AUTH`: The transaction was missing authorization. + * * `OTHER`: Other reason. + * * `PROCESSING_ERROR`: Processing error. + * * `REFUND_NOT_PROCESSED`: The refund was not processed. + * * `RECURRING_TRANSACTION_NOT_CANCELLED`: The recurring transaction was not cancelled. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun reason(): Dispute.Reason = reason.getRequired("reason") + + /** + * Date the representment was received. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun representmentDate(): Optional = + representmentDate.getOptional("representment_date") + + /** + * Date that the dispute was resolved. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resolutionDate(): Optional = resolutionDate.getOptional("resolution_date") + + /** + * Note by Dispute team on the case resolution. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resolutionNote(): Optional = resolutionNote.getOptional("resolution_note") + + /** + * Reason for the dispute resolution: + * * `CASE_LOST`: This case was lost at final arbitration. + * * `NETWORK_REJECTED`: Network rejected. + * * `NO_DISPUTE_RIGHTS_3DS`: No dispute rights, 3DS. + * * `NO_DISPUTE_RIGHTS_BELOW_THRESHOLD`: No dispute rights, below threshold. + * * `NO_DISPUTE_RIGHTS_CONTACTLESS`: No dispute rights, contactless. + * * `NO_DISPUTE_RIGHTS_HYBRID`: No dispute rights, hybrid. + * * `NO_DISPUTE_RIGHTS_MAX_CHARGEBACKS`: No dispute rights, max chargebacks. + * * `NO_DISPUTE_RIGHTS_OTHER`: No dispute rights, other. + * * `PAST_FILING_DATE`: Past filing date. + * * `PREARBITRATION_REJECTED`: Prearbitration rejected. + * * `PROCESSOR_REJECTED_OTHER`: Processor rejected, other. + * * `REFUNDED`: Refunded. + * * `REFUNDED_AFTER_CHARGEBACK`: Refunded after chargeback. + * * `WITHDRAWN`: Withdrawn. + * * `WON_ARBITRATION`: Won arbitration. + * * `WON_FIRST_CHARGEBACK`: Won first chargeback. + * * `WON_PREARBITRATION`: Won prearbitration. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resolutionReason(): Optional = + resolutionReason.getOptional("resolution_reason") + + /** + * Status types: + * * `NEW` - New dispute case is opened. + * * `PENDING_CUSTOMER` - Lithic is waiting for customer to provide more information. + * * `SUBMITTED` - Dispute is submitted to the card network. + * * `REPRESENTMENT` - Case has entered second presentment. + * * `PREARBITRATION` - Case has entered prearbitration. + * * `ARBITRATION` - Case has entered arbitration. + * * `CASE_WON` - Case was won and credit will be issued. + * * `CASE_CLOSED` - Case was lost or withdrawn. + * + * @throws LithicInvalidDataException if 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(): Dispute.Status = status.getRequired("status") + + /** + * The transaction that is being disputed. A transaction can only be disputed once but may have + * multiple dispute cases. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun transactionToken(): String = transactionToken.getRequired("transaction_token") + + /** + * 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 [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 [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 [arbitrationDate]. + * + * Unlike [arbitrationDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("arbitration_date") + @ExcludeMissing + fun _arbitrationDate(): JsonField = arbitrationDate + + /** + * 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 [customerFiledDate]. + * + * Unlike [customerFiledDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_filed_date") + @ExcludeMissing + fun _customerFiledDate(): JsonField = customerFiledDate + + /** + * Returns the raw JSON value of [customerNote]. + * + * Unlike [customerNote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_note") + @ExcludeMissing + fun _customerNote(): JsonField = customerNote + + /** + * Returns the raw JSON value of [networkClaimIds]. + * + * Unlike [networkClaimIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("network_claim_ids") + @ExcludeMissing + fun _networkClaimIds(): JsonField> = networkClaimIds + + /** + * Returns the raw JSON value of [networkFiledDate]. + * + * Unlike [networkFiledDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_filed_date") + @ExcludeMissing + fun _networkFiledDate(): JsonField = networkFiledDate + + /** + * Returns the raw JSON value of [networkReasonCode]. + * + * Unlike [networkReasonCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_reason_code") + @ExcludeMissing + fun _networkReasonCode(): JsonField = networkReasonCode + + /** + * Returns the raw JSON value of [prearbitrationDate]. + * + * Unlike [prearbitrationDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("prearbitration_date") + @ExcludeMissing + fun _prearbitrationDate(): JsonField = prearbitrationDate + + /** + * Returns the raw JSON value of [primaryClaimId]. + * + * Unlike [primaryClaimId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("primary_claim_id") + @ExcludeMissing + fun _primaryClaimId(): JsonField = primaryClaimId + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [representmentDate]. + * + * Unlike [representmentDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("representment_date") + @ExcludeMissing + fun _representmentDate(): JsonField = representmentDate + + /** + * Returns the raw JSON value of [resolutionDate]. + * + * Unlike [resolutionDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resolution_date") + @ExcludeMissing + fun _resolutionDate(): JsonField = resolutionDate + + /** + * Returns the raw JSON value of [resolutionNote]. + * + * Unlike [resolutionNote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resolution_note") + @ExcludeMissing + fun _resolutionNote(): JsonField = resolutionNote + + /** + * Returns the raw JSON value of [resolutionReason]. + * + * Unlike [resolutionReason], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("resolution_reason") + @ExcludeMissing + fun _resolutionReason(): JsonField = resolutionReason + + /** + * 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 [transactionToken]. + * + * Unlike [transactionToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken + + /** + * 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 [DisputeUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .amount() + * .arbitrationDate() + * .created() + * .customerFiledDate() + * .customerNote() + * .networkClaimIds() + * .networkFiledDate() + * .networkReasonCode() + * .prearbitrationDate() + * .primaryClaimId() + * .reason() + * .representmentDate() + * .resolutionDate() + * .resolutionNote() + * .resolutionReason() + * .status() + * .transactionToken() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DisputeUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var amount: JsonField? = null + private var arbitrationDate: JsonField? = null + private var created: JsonField? = null + private var customerFiledDate: JsonField? = null + private var customerNote: JsonField? = null + private var networkClaimIds: JsonField>? = null + private var networkFiledDate: JsonField? = null + private var networkReasonCode: JsonField? = null + private var prearbitrationDate: JsonField? = null + private var primaryClaimId: JsonField? = null + private var reason: JsonField? = null + private var representmentDate: JsonField? = null + private var resolutionDate: JsonField? = null + private var resolutionNote: JsonField? = null + private var resolutionReason: JsonField? = null + private var status: JsonField? = null + private var transactionToken: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(disputeUpdatedWebhookEvent: DisputeUpdatedWebhookEvent) = apply { + token = disputeUpdatedWebhookEvent.token + amount = disputeUpdatedWebhookEvent.amount + arbitrationDate = disputeUpdatedWebhookEvent.arbitrationDate + created = disputeUpdatedWebhookEvent.created + customerFiledDate = disputeUpdatedWebhookEvent.customerFiledDate + customerNote = disputeUpdatedWebhookEvent.customerNote + networkClaimIds = disputeUpdatedWebhookEvent.networkClaimIds.map { it.toMutableList() } + networkFiledDate = disputeUpdatedWebhookEvent.networkFiledDate + networkReasonCode = disputeUpdatedWebhookEvent.networkReasonCode + prearbitrationDate = disputeUpdatedWebhookEvent.prearbitrationDate + primaryClaimId = disputeUpdatedWebhookEvent.primaryClaimId + reason = disputeUpdatedWebhookEvent.reason + representmentDate = disputeUpdatedWebhookEvent.representmentDate + resolutionDate = disputeUpdatedWebhookEvent.resolutionDate + resolutionNote = disputeUpdatedWebhookEvent.resolutionNote + resolutionReason = disputeUpdatedWebhookEvent.resolutionReason + status = disputeUpdatedWebhookEvent.status + transactionToken = disputeUpdatedWebhookEvent.transactionToken + eventType = disputeUpdatedWebhookEvent.eventType + additionalProperties = disputeUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Amount under dispute. May be different from the original transaction amount. */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Date dispute entered arbitration. */ + fun arbitrationDate(arbitrationDate: OffsetDateTime?) = + arbitrationDate(JsonField.ofNullable(arbitrationDate)) + + /** Alias for calling [Builder.arbitrationDate] with `arbitrationDate.orElse(null)`. */ + fun arbitrationDate(arbitrationDate: Optional) = + arbitrationDate(arbitrationDate.getOrNull()) + + /** + * Sets [Builder.arbitrationDate] to an arbitrary JSON value. + * + * You should usually call [Builder.arbitrationDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun arbitrationDate(arbitrationDate: JsonField) = apply { + this.arbitrationDate = arbitrationDate + } + + /** Timestamp of when first Dispute was reported. */ + 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 } + + /** Date that the dispute was filed by the customer making the dispute. */ + fun customerFiledDate(customerFiledDate: OffsetDateTime?) = + customerFiledDate(JsonField.ofNullable(customerFiledDate)) + + /** Alias for calling [Builder.customerFiledDate] with `customerFiledDate.orElse(null)`. */ + fun customerFiledDate(customerFiledDate: Optional) = + customerFiledDate(customerFiledDate.getOrNull()) + + /** + * Sets [Builder.customerFiledDate] to an arbitrary JSON value. + * + * You should usually call [Builder.customerFiledDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun customerFiledDate(customerFiledDate: JsonField) = apply { + this.customerFiledDate = customerFiledDate + } + + /** End customer description of the reason for the dispute. */ + fun customerNote(customerNote: String?) = customerNote(JsonField.ofNullable(customerNote)) + + /** Alias for calling [Builder.customerNote] with `customerNote.orElse(null)`. */ + fun customerNote(customerNote: Optional) = customerNote(customerNote.getOrNull()) + + /** + * Sets [Builder.customerNote] to an arbitrary JSON value. + * + * You should usually call [Builder.customerNote] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun customerNote(customerNote: JsonField) = apply { + this.customerNote = customerNote + } + + /** Unique identifiers for the dispute from the network. */ + fun networkClaimIds(networkClaimIds: List?) = + networkClaimIds(JsonField.ofNullable(networkClaimIds)) + + /** Alias for calling [Builder.networkClaimIds] with `networkClaimIds.orElse(null)`. */ + fun networkClaimIds(networkClaimIds: Optional>) = + networkClaimIds(networkClaimIds.getOrNull()) + + /** + * Sets [Builder.networkClaimIds] to an arbitrary JSON value. + * + * You should usually call [Builder.networkClaimIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkClaimIds(networkClaimIds: JsonField>) = apply { + this.networkClaimIds = networkClaimIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [networkClaimIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNetworkClaimId(networkClaimId: String) = apply { + networkClaimIds = + (networkClaimIds ?: JsonField.of(mutableListOf())).also { + checkKnown("networkClaimIds", it).add(networkClaimId) + } + } + + /** Date that the dispute was submitted to the network. */ + fun networkFiledDate(networkFiledDate: OffsetDateTime?) = + networkFiledDate(JsonField.ofNullable(networkFiledDate)) + + /** Alias for calling [Builder.networkFiledDate] with `networkFiledDate.orElse(null)`. */ + fun networkFiledDate(networkFiledDate: Optional) = + networkFiledDate(networkFiledDate.getOrNull()) + + /** + * Sets [Builder.networkFiledDate] to an arbitrary JSON value. + * + * You should usually call [Builder.networkFiledDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun networkFiledDate(networkFiledDate: JsonField) = apply { + this.networkFiledDate = networkFiledDate + } + + /** Network reason code used to file the dispute. */ + fun networkReasonCode(networkReasonCode: String?) = + networkReasonCode(JsonField.ofNullable(networkReasonCode)) + + /** Alias for calling [Builder.networkReasonCode] with `networkReasonCode.orElse(null)`. */ + fun networkReasonCode(networkReasonCode: Optional) = + networkReasonCode(networkReasonCode.getOrNull()) + + /** + * Sets [Builder.networkReasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.networkReasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun networkReasonCode(networkReasonCode: JsonField) = apply { + this.networkReasonCode = networkReasonCode + } + + /** Date dispute entered pre-arbitration. */ + fun prearbitrationDate(prearbitrationDate: OffsetDateTime?) = + prearbitrationDate(JsonField.ofNullable(prearbitrationDate)) + + /** + * Alias for calling [Builder.prearbitrationDate] with `prearbitrationDate.orElse(null)`. + */ + fun prearbitrationDate(prearbitrationDate: Optional) = + prearbitrationDate(prearbitrationDate.getOrNull()) + + /** + * Sets [Builder.prearbitrationDate] to an arbitrary JSON value. + * + * You should usually call [Builder.prearbitrationDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun prearbitrationDate(prearbitrationDate: JsonField) = apply { + this.prearbitrationDate = prearbitrationDate + } + + /** + * Unique identifier for the dispute from the network. If there are multiple, this will be + * the first claim id set by the network + */ + fun primaryClaimId(primaryClaimId: String?) = + primaryClaimId(JsonField.ofNullable(primaryClaimId)) + + /** Alias for calling [Builder.primaryClaimId] with `primaryClaimId.orElse(null)`. */ + fun primaryClaimId(primaryClaimId: Optional) = + primaryClaimId(primaryClaimId.getOrNull()) + + /** + * Sets [Builder.primaryClaimId] to an arbitrary JSON value. + * + * You should usually call [Builder.primaryClaimId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun primaryClaimId(primaryClaimId: JsonField) = apply { + this.primaryClaimId = primaryClaimId + } + + /** + * Dispute reason: + * * `ATM_CASH_MISDISPENSE`: ATM cash misdispense. + * * `CANCELLED`: Transaction was cancelled by the customer. + * * `DUPLICATED`: The transaction was a duplicate. + * * `FRAUD_CARD_NOT_PRESENT`: Fraudulent transaction, card not present. + * * `FRAUD_CARD_PRESENT`: Fraudulent transaction, card present. + * * `FRAUD_OTHER`: Fraudulent transaction, other types such as questionable merchant + * activity. + * * `GOODS_SERVICES_NOT_AS_DESCRIBED`: The goods or services were not as described. + * * `GOODS_SERVICES_NOT_RECEIVED`: The goods or services were not received. + * * `INCORRECT_AMOUNT`: The transaction amount was incorrect. + * * `MISSING_AUTH`: The transaction was missing authorization. + * * `OTHER`: Other reason. + * * `PROCESSING_ERROR`: Processing error. + * * `REFUND_NOT_PROCESSED`: The refund was not processed. + * * `RECURRING_TRANSACTION_NOT_CANCELLED`: The recurring transaction was not cancelled. + */ + fun reason(reason: Dispute.Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [Dispute.Reason] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** Date the representment was received. */ + fun representmentDate(representmentDate: OffsetDateTime?) = + representmentDate(JsonField.ofNullable(representmentDate)) + + /** Alias for calling [Builder.representmentDate] with `representmentDate.orElse(null)`. */ + fun representmentDate(representmentDate: Optional) = + representmentDate(representmentDate.getOrNull()) + + /** + * Sets [Builder.representmentDate] to an arbitrary JSON value. + * + * You should usually call [Builder.representmentDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun representmentDate(representmentDate: JsonField) = apply { + this.representmentDate = representmentDate + } + + /** Date that the dispute was resolved. */ + fun resolutionDate(resolutionDate: OffsetDateTime?) = + resolutionDate(JsonField.ofNullable(resolutionDate)) + + /** Alias for calling [Builder.resolutionDate] with `resolutionDate.orElse(null)`. */ + fun resolutionDate(resolutionDate: Optional) = + resolutionDate(resolutionDate.getOrNull()) + + /** + * Sets [Builder.resolutionDate] to an arbitrary JSON value. + * + * You should usually call [Builder.resolutionDate] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resolutionDate(resolutionDate: JsonField) = apply { + this.resolutionDate = resolutionDate + } + + /** Note by Dispute team on the case resolution. */ + fun resolutionNote(resolutionNote: String?) = + resolutionNote(JsonField.ofNullable(resolutionNote)) + + /** Alias for calling [Builder.resolutionNote] with `resolutionNote.orElse(null)`. */ + fun resolutionNote(resolutionNote: Optional) = + resolutionNote(resolutionNote.getOrNull()) + + /** + * Sets [Builder.resolutionNote] to an arbitrary JSON value. + * + * You should usually call [Builder.resolutionNote] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resolutionNote(resolutionNote: JsonField) = apply { + this.resolutionNote = resolutionNote + } + + /** + * Reason for the dispute resolution: + * * `CASE_LOST`: This case was lost at final arbitration. + * * `NETWORK_REJECTED`: Network rejected. + * * `NO_DISPUTE_RIGHTS_3DS`: No dispute rights, 3DS. + * * `NO_DISPUTE_RIGHTS_BELOW_THRESHOLD`: No dispute rights, below threshold. + * * `NO_DISPUTE_RIGHTS_CONTACTLESS`: No dispute rights, contactless. + * * `NO_DISPUTE_RIGHTS_HYBRID`: No dispute rights, hybrid. + * * `NO_DISPUTE_RIGHTS_MAX_CHARGEBACKS`: No dispute rights, max chargebacks. + * * `NO_DISPUTE_RIGHTS_OTHER`: No dispute rights, other. + * * `PAST_FILING_DATE`: Past filing date. + * * `PREARBITRATION_REJECTED`: Prearbitration rejected. + * * `PROCESSOR_REJECTED_OTHER`: Processor rejected, other. + * * `REFUNDED`: Refunded. + * * `REFUNDED_AFTER_CHARGEBACK`: Refunded after chargeback. + * * `WITHDRAWN`: Withdrawn. + * * `WON_ARBITRATION`: Won arbitration. + * * `WON_FIRST_CHARGEBACK`: Won first chargeback. + * * `WON_PREARBITRATION`: Won prearbitration. + */ + fun resolutionReason(resolutionReason: Dispute.ResolutionReason?) = + resolutionReason(JsonField.ofNullable(resolutionReason)) + + /** Alias for calling [Builder.resolutionReason] with `resolutionReason.orElse(null)`. */ + fun resolutionReason(resolutionReason: Optional) = + resolutionReason(resolutionReason.getOrNull()) + + /** + * Sets [Builder.resolutionReason] to an arbitrary JSON value. + * + * You should usually call [Builder.resolutionReason] with a well-typed + * [Dispute.ResolutionReason] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun resolutionReason(resolutionReason: JsonField) = apply { + this.resolutionReason = resolutionReason + } + + /** + * Status types: + * * `NEW` - New dispute case is opened. + * * `PENDING_CUSTOMER` - Lithic is waiting for customer to provide more information. + * * `SUBMITTED` - Dispute is submitted to the card network. + * * `REPRESENTMENT` - Case has entered second presentment. + * * `PREARBITRATION` - Case has entered prearbitration. + * * `ARBITRATION` - Case has entered arbitration. + * * `CASE_WON` - Case was won and credit will be issued. + * * `CASE_CLOSED` - Case was lost or withdrawn. + */ + fun status(status: Dispute.Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Dispute.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 transaction that is being disputed. A transaction can only be disputed once but may + * have multiple dispute cases. + */ + fun transactionToken(transactionToken: String) = + transactionToken(JsonField.of(transactionToken)) + + /** + * Sets [Builder.transactionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transactionToken(transactionToken: JsonField) = apply { + this.transactionToken = transactionToken + } + + /** 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 [DisputeUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .amount() + * .arbitrationDate() + * .created() + * .customerFiledDate() + * .customerNote() + * .networkClaimIds() + * .networkFiledDate() + * .networkReasonCode() + * .prearbitrationDate() + * .primaryClaimId() + * .reason() + * .representmentDate() + * .resolutionDate() + * .resolutionNote() + * .resolutionReason() + * .status() + * .transactionToken() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DisputeUpdatedWebhookEvent = + DisputeUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("amount", amount), + checkRequired("arbitrationDate", arbitrationDate), + checkRequired("created", created), + checkRequired("customerFiledDate", customerFiledDate), + checkRequired("customerNote", customerNote), + checkRequired("networkClaimIds", networkClaimIds).map { it.toImmutable() }, + checkRequired("networkFiledDate", networkFiledDate), + checkRequired("networkReasonCode", networkReasonCode), + checkRequired("prearbitrationDate", prearbitrationDate), + checkRequired("primaryClaimId", primaryClaimId), + checkRequired("reason", reason), + checkRequired("representmentDate", representmentDate), + checkRequired("resolutionDate", resolutionDate), + checkRequired("resolutionNote", resolutionNote), + checkRequired("resolutionReason", resolutionReason), + checkRequired("status", status), + checkRequired("transactionToken", transactionToken), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DisputeUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + amount() + arbitrationDate() + created() + customerFiledDate() + customerNote() + networkClaimIds() + networkFiledDate() + networkReasonCode() + prearbitrationDate() + primaryClaimId() + reason().validate() + representmentDate() + resolutionDate() + resolutionNote() + resolutionReason().ifPresent { it.validate() } + status().validate() + transactionToken() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (arbitrationDate.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (customerFiledDate.asKnown().isPresent) 1 else 0) + + (if (customerNote.asKnown().isPresent) 1 else 0) + + (networkClaimIds.asKnown().getOrNull()?.size ?: 0) + + (if (networkFiledDate.asKnown().isPresent) 1 else 0) + + (if (networkReasonCode.asKnown().isPresent) 1 else 0) + + (if (prearbitrationDate.asKnown().isPresent) 1 else 0) + + (if (primaryClaimId.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + (if (representmentDate.asKnown().isPresent) 1 else 0) + + (if (resolutionDate.asKnown().isPresent) 1 else 0) + + (if (resolutionNote.asKnown().isPresent) 1 else 0) + + (resolutionReason.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionToken.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 DISPUTE_UPDATED = of("dispute.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DISPUTE_UPDATED + } + + /** + * 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 { + DISPUTE_UPDATED, + /** + * 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) { + DISPUTE_UPDATED -> Value.DISPUTE_UPDATED + 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) { + DISPUTE_UPDATED -> Known.DISPUTE_UPDATED + 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 + + 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 DisputeUpdatedWebhookEvent && + token == other.token && + amount == other.amount && + arbitrationDate == other.arbitrationDate && + created == other.created && + customerFiledDate == other.customerFiledDate && + customerNote == other.customerNote && + networkClaimIds == other.networkClaimIds && + networkFiledDate == other.networkFiledDate && + networkReasonCode == other.networkReasonCode && + prearbitrationDate == other.prearbitrationDate && + primaryClaimId == other.primaryClaimId && + reason == other.reason && + representmentDate == other.representmentDate && + resolutionDate == other.resolutionDate && + resolutionNote == other.resolutionNote && + resolutionReason == other.resolutionReason && + status == other.status && + transactionToken == other.transactionToken && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + amount, + arbitrationDate, + created, + customerFiledDate, + customerNote, + networkClaimIds, + networkFiledDate, + networkReasonCode, + prearbitrationDate, + primaryClaimId, + reason, + representmentDate, + resolutionDate, + resolutionNote, + resolutionReason, + status, + transactionToken, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DisputeUpdatedWebhookEvent{token=$token, amount=$amount, arbitrationDate=$arbitrationDate, created=$created, customerFiledDate=$customerFiledDate, customerNote=$customerNote, networkClaimIds=$networkClaimIds, networkFiledDate=$networkFiledDate, networkReasonCode=$networkReasonCode, prearbitrationDate=$prearbitrationDate, primaryClaimId=$primaryClaimId, reason=$reason, representmentDate=$representmentDate, resolutionDate=$resolutionDate, resolutionNote=$resolutionNote, resolutionReason=$resolutionReason, status=$status, transactionToken=$transactionToken, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreatedWebhookEvent.kt new file mode 100644 index 000000000..52af81a06 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountCreatedWebhookEvent.kt @@ -0,0 +1,1331 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ExternalBankAccountCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val country: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val lastFour: JsonField, + private val owner: JsonField, + private val ownerType: JsonField, + private val routingNumber: JsonField, + private val state: JsonField, + private val type: JsonField, + private val verificationAttempts: JsonField, + private val verificationMethod: JsonField, + private val verificationState: JsonField, + private val accountToken: JsonField, + private val address: JsonField, + private val companyId: JsonField, + private val dob: JsonField, + private val doingBusinessAs: JsonField, + private val financialAccountToken: JsonField, + private val name: JsonField, + private val userDefinedId: JsonField, + private val verificationFailedReason: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("last_four") @ExcludeMissing lastFour: JsonField = JsonMissing.of(), + @JsonProperty("owner") @ExcludeMissing owner: JsonField = JsonMissing.of(), + @JsonProperty("owner_type") + @ExcludeMissing + ownerType: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + routingNumber: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + state: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("verification_attempts") + @ExcludeMissing + verificationAttempts: JsonField = JsonMissing.of(), + @JsonProperty("verification_method") + @ExcludeMissing + verificationMethod: JsonField = JsonMissing.of(), + @JsonProperty("verification_state") + @ExcludeMissing + verificationState: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("address") + @ExcludeMissing + address: JsonField = JsonMissing.of(), + @JsonProperty("company_id") @ExcludeMissing companyId: JsonField = JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), + @JsonProperty("doing_business_as") + @ExcludeMissing + doingBusinessAs: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("verification_failed_reason") + @ExcludeMissing + verificationFailedReason: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + country, + created, + currency, + lastFour, + owner, + ownerType, + routingNumber, + state, + type, + verificationAttempts, + verificationMethod, + verificationState, + accountToken, + address, + companyId, + dob, + doingBusinessAs, + financialAccountToken, + name, + userDefinedId, + verificationFailedReason, + eventType, + mutableMapOf(), + ) + + fun toExternalBankAccount(): ExternalBankAccount = + ExternalBankAccount.builder() + .token(token) + .country(country) + .created(created) + .currency(currency) + .lastFour(lastFour) + .owner(owner) + .ownerType(ownerType) + .routingNumber(routingNumber) + .state(state) + .type(type) + .verificationAttempts(verificationAttempts) + .verificationMethod(verificationMethod) + .verificationState(verificationState) + .accountToken(accountToken) + .address(address) + .companyId(companyId) + .dob(dob) + .doingBusinessAs(doingBusinessAs) + .financialAccountToken(financialAccountToken) + .name(name) + .userDefinedId(userDefinedId) + .verificationFailedReason(verificationFailedReason) + .build() + + /** + * A globally unique identifier for this record of an external bank account association. If a + * program links an external bank account to more than one end-user or to both the program and + * the end-user, then Lithic will return each record of the association + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * The country that the bank account is located in using ISO 3166-1. We will only accept USA + * bank accounts e.g., USA + * + * @throws LithicInvalidDataException if 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") + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic account. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * currency of the external account 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number passed + * + * @throws LithicInvalidDataException if 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") + + /** + * Legal Name of the business or individual who owns the external account. This will appear in + * statements + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun owner(): String = owner.getRequired("owner") + + /** + * Owner 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 ownerType(): OwnerType = ownerType.getRequired("owner_type") + + /** + * Routing 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 routingNumber(): String = routingNumber.getRequired("routing_number") + + /** + * Account 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 state(): ExternalBankAccount.State = state.getRequired("state") + + /** + * Account 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(): ExternalBankAccount.AccountType = type.getRequired("type") + + /** + * The number of attempts at verification + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun verificationAttempts(): Long = verificationAttempts.getRequired("verification_attempts") + + /** + * Verification Method + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun verificationMethod(): VerificationMethod = + verificationMethod.getRequired("verification_method") + + /** + * Verification 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 verificationState(): ExternalBankAccount.VerificationState = + verificationState.getRequired("verification_state") + + /** + * Indicates which Lithic account the external account is associated with. For external accounts + * that are associated with the program, account_token field returned will be null + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * Address + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun address(): Optional = address.getOptional("address") + + /** + * Optional field that helps identify bank accounts in receipts + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyId(): Optional = companyId.getOptional("company_id") + + /** + * Date of Birth of the Individual that owns the external bank account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dob(): Optional = dob.getOptional("dob") + + /** + * Doing Business As + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun doingBusinessAs(): Optional = doingBusinessAs.getOptional("doing_business_as") + + /** + * The financial account token of the operating account to fund the micro deposits + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun financialAccountToken(): Optional = + financialAccountToken.getOptional("financial_account_token") + + /** + * The nickname for this External Bank Account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * User Defined ID + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * Optional free text description of the reason for the failed verification. For ACH + * micro-deposits returned, this field will display the reason return code sent by the ACH + * network + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun verificationFailedReason(): Optional = + verificationFailedReason.getOptional("verification_failed_reason") + + /** + * 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 [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 [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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [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 [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner + + /** + * Returns the raw JSON value of [ownerType]. + * + * Unlike [ownerType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType + + /** + * Returns the raw JSON value of [routingNumber]. + * + * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber + + /** + * Returns the raw JSON value of [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 + + /** + * Returns the raw JSON value of [verificationAttempts]. + * + * Unlike [verificationAttempts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("verification_attempts") + @ExcludeMissing + fun _verificationAttempts(): JsonField = verificationAttempts + + /** + * Returns the raw JSON value of [verificationMethod]. + * + * Unlike [verificationMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("verification_method") + @ExcludeMissing + fun _verificationMethod(): JsonField = verificationMethod + + /** + * Returns the raw JSON value of [verificationState]. + * + * Unlike [verificationState], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [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 [companyId]. + * + * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + + /** + * Returns the raw JSON value of [dob]. + * + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + + /** + * Returns the raw JSON value of [doingBusinessAs]. + * + * Unlike [doingBusinessAs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + /** + * Returns the raw JSON value of [verificationFailedReason]. + * + * Unlike [verificationFailedReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("verification_failed_reason") + @ExcludeMissing + fun _verificationFailedReason(): JsonField = verificationFailedReason + + /** + * 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 + * [ExternalBankAccountCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .country() + * .created() + * .currency() + * .lastFour() + * .owner() + * .ownerType() + * .routingNumber() + * .state() + * .type() + * .verificationAttempts() + * .verificationMethod() + * .verificationState() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExternalBankAccountCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null + private var accountToken: JsonField = JsonMissing.of() + private var address: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var doingBusinessAs: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var verificationFailedReason: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + externalBankAccountCreatedWebhookEvent: ExternalBankAccountCreatedWebhookEvent + ) = apply { + token = externalBankAccountCreatedWebhookEvent.token + country = externalBankAccountCreatedWebhookEvent.country + created = externalBankAccountCreatedWebhookEvent.created + currency = externalBankAccountCreatedWebhookEvent.currency + lastFour = externalBankAccountCreatedWebhookEvent.lastFour + owner = externalBankAccountCreatedWebhookEvent.owner + ownerType = externalBankAccountCreatedWebhookEvent.ownerType + routingNumber = externalBankAccountCreatedWebhookEvent.routingNumber + state = externalBankAccountCreatedWebhookEvent.state + type = externalBankAccountCreatedWebhookEvent.type + verificationAttempts = externalBankAccountCreatedWebhookEvent.verificationAttempts + verificationMethod = externalBankAccountCreatedWebhookEvent.verificationMethod + verificationState = externalBankAccountCreatedWebhookEvent.verificationState + accountToken = externalBankAccountCreatedWebhookEvent.accountToken + address = externalBankAccountCreatedWebhookEvent.address + companyId = externalBankAccountCreatedWebhookEvent.companyId + dob = externalBankAccountCreatedWebhookEvent.dob + doingBusinessAs = externalBankAccountCreatedWebhookEvent.doingBusinessAs + financialAccountToken = externalBankAccountCreatedWebhookEvent.financialAccountToken + name = externalBankAccountCreatedWebhookEvent.name + userDefinedId = externalBankAccountCreatedWebhookEvent.userDefinedId + verificationFailedReason = + externalBankAccountCreatedWebhookEvent.verificationFailedReason + eventType = externalBankAccountCreatedWebhookEvent.eventType + additionalProperties = + externalBankAccountCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** + * A globally unique identifier for this record of an external bank account association. If + * a program links an external bank account to more than one end-user or to both the program + * and the end-user, then Lithic will return each record of the association + */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** + * The country that the bank account is located in using ISO 3166-1. We will only accept USA + * bank accounts e.g., USA + */ + 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 } + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic account. + */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** currency of the external account 3-character alphabetic ISO 4217 code */ + 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 } + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number passed + */ + 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 } + + /** + * Legal Name of the business or individual who owns the external account. This will appear + * in statements + */ + fun owner(owner: String) = owner(JsonField.of(owner)) + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun owner(owner: JsonField) = apply { this.owner = owner } + + /** Owner Type */ + fun ownerType(ownerType: OwnerType) = ownerType(JsonField.of(ownerType)) + + /** + * Sets [Builder.ownerType] to an arbitrary JSON value. + * + * You should usually call [Builder.ownerType] with a well-typed [OwnerType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ownerType(ownerType: JsonField) = apply { this.ownerType = ownerType } + + /** Routing Number */ + fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) + + /** + * Sets [Builder.routingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.routingNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } + + /** Account State */ + fun state(state: ExternalBankAccount.State) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [ExternalBankAccount.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 } + + /** Account Type */ + fun type(type: ExternalBankAccount.AccountType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed + * [ExternalBankAccount.AccountType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The number of attempts at verification */ + fun verificationAttempts(verificationAttempts: Long) = + verificationAttempts(JsonField.of(verificationAttempts)) + + /** + * Sets [Builder.verificationAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.verificationAttempts] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun verificationAttempts(verificationAttempts: JsonField) = apply { + this.verificationAttempts = verificationAttempts + } + + /** Verification Method */ + fun verificationMethod(verificationMethod: VerificationMethod) = + verificationMethod(JsonField.of(verificationMethod)) + + /** + * Sets [Builder.verificationMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.verificationMethod] with a well-typed + * [VerificationMethod] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun verificationMethod(verificationMethod: JsonField) = apply { + this.verificationMethod = verificationMethod + } + + /** Verification State */ + fun verificationState(verificationState: ExternalBankAccount.VerificationState) = + verificationState(JsonField.of(verificationState)) + + /** + * Sets [Builder.verificationState] to an arbitrary JSON value. + * + * You should usually call [Builder.verificationState] with a well-typed + * [ExternalBankAccount.VerificationState] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun verificationState(verificationState: JsonField) = + apply { + this.verificationState = verificationState + } + + /** + * Indicates which Lithic account the external account is associated with. For external + * accounts that are associated with the program, account_token field returned will be null + */ + fun accountToken(accountToken: String?) = accountToken(JsonField.ofNullable(accountToken)) + + /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ + fun accountToken(accountToken: Optional) = accountToken(accountToken.getOrNull()) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Address */ + fun address(address: ExternalBankAccountAddress?) = address(JsonField.ofNullable(address)) + + /** Alias for calling [Builder.address] with `address.orElse(null)`. */ + fun address(address: Optional) = address(address.getOrNull()) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [ExternalBankAccountAddress] + * 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 + } + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(companyId: String?) = companyId(JsonField.ofNullable(companyId)) + + /** Alias for calling [Builder.companyId] with `companyId.orElse(null)`. */ + fun companyId(companyId: Optional) = companyId(companyId.getOrNull()) + + /** + * Sets [Builder.companyId] to an arbitrary JSON value. + * + * You should usually call [Builder.companyId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyId(companyId: JsonField) = apply { this.companyId = companyId } + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(dob: LocalDate?) = dob(JsonField.ofNullable(dob)) + + /** Alias for calling [Builder.dob] with `dob.orElse(null)`. */ + fun dob(dob: Optional) = dob(dob.getOrNull()) + + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [LocalDate] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** Doing Business As */ + fun doingBusinessAs(doingBusinessAs: String?) = + doingBusinessAs(JsonField.ofNullable(doingBusinessAs)) + + /** Alias for calling [Builder.doingBusinessAs] with `doingBusinessAs.orElse(null)`. */ + fun doingBusinessAs(doingBusinessAs: Optional) = + doingBusinessAs(doingBusinessAs.getOrNull()) + + /** + * Sets [Builder.doingBusinessAs] to an arbitrary JSON value. + * + * You should usually call [Builder.doingBusinessAs] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun doingBusinessAs(doingBusinessAs: JsonField) = apply { + this.doingBusinessAs = doingBusinessAs + } + + /** The financial account token of the operating account to fund the micro deposits */ + fun financialAccountToken(financialAccountToken: String?) = + financialAccountToken(JsonField.ofNullable(financialAccountToken)) + + /** + * Alias for calling [Builder.financialAccountToken] with + * `financialAccountToken.orElse(null)`. + */ + fun financialAccountToken(financialAccountToken: Optional) = + financialAccountToken(financialAccountToken.getOrNull()) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** The nickname for this External Bank Account */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** User Defined ID */ + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** + * Optional free text description of the reason for the failed verification. For ACH + * micro-deposits returned, this field will display the reason return code sent by the ACH + * network + */ + fun verificationFailedReason(verificationFailedReason: String?) = + verificationFailedReason(JsonField.ofNullable(verificationFailedReason)) + + /** + * Alias for calling [Builder.verificationFailedReason] with + * `verificationFailedReason.orElse(null)`. + */ + fun verificationFailedReason(verificationFailedReason: Optional) = + verificationFailedReason(verificationFailedReason.getOrNull()) + + /** + * Sets [Builder.verificationFailedReason] to an arbitrary JSON value. + * + * You should usually call [Builder.verificationFailedReason] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun verificationFailedReason(verificationFailedReason: JsonField) = apply { + this.verificationFailedReason = verificationFailedReason + } + + /** 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 [ExternalBankAccountCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .country() + * .created() + * .currency() + * .lastFour() + * .owner() + * .ownerType() + * .routingNumber() + * .state() + * .type() + * .verificationAttempts() + * .verificationMethod() + * .verificationState() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExternalBankAccountCreatedWebhookEvent = + ExternalBankAccountCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("country", country), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("lastFour", lastFour), + checkRequired("owner", owner), + checkRequired("ownerType", ownerType), + checkRequired("routingNumber", routingNumber), + checkRequired("state", state), + checkRequired("type", type), + checkRequired("verificationAttempts", verificationAttempts), + checkRequired("verificationMethod", verificationMethod), + checkRequired("verificationState", verificationState), + accountToken, + address, + companyId, + dob, + doingBusinessAs, + financialAccountToken, + name, + userDefinedId, + verificationFailedReason, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExternalBankAccountCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + country() + created() + currency() + lastFour() + owner() + ownerType().validate() + routingNumber() + state().validate() + type().validate() + verificationAttempts() + verificationMethod().validate() + verificationState().validate() + accountToken() + address().ifPresent { it.validate() } + companyId() + dob() + doingBusinessAs() + financialAccountToken() + name() + userDefinedId() + verificationFailedReason() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (lastFour.asKnown().isPresent) 1 else 0) + + (if (owner.asKnown().isPresent) 1 else 0) + + (ownerType.asKnown().getOrNull()?.validity() ?: 0) + + (if (routingNumber.asKnown().isPresent) 1 else 0) + + (state.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (verificationAttempts.asKnown().isPresent) 1 else 0) + + (verificationMethod.asKnown().getOrNull()?.validity() ?: 0) + + (verificationState.asKnown().getOrNull()?.validity() ?: 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (address.asKnown().getOrNull()?.validity() ?: 0) + + (if (companyId.asKnown().isPresent) 1 else 0) + + (if (dob.asKnown().isPresent) 1 else 0) + + (if (doingBusinessAs.asKnown().isPresent) 1 else 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + (if (verificationFailedReason.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 EXTERNAL_BANK_ACCOUNT_CREATED = of("external_bank_account.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + EXTERNAL_BANK_ACCOUNT_CREATED + } + + /** + * 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 { + EXTERNAL_BANK_ACCOUNT_CREATED, + /** + * 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) { + EXTERNAL_BANK_ACCOUNT_CREATED -> Value.EXTERNAL_BANK_ACCOUNT_CREATED + 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) { + EXTERNAL_BANK_ACCOUNT_CREATED -> Known.EXTERNAL_BANK_ACCOUNT_CREATED + 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 + + 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 ExternalBankAccountCreatedWebhookEvent && + token == other.token && + country == other.country && + created == other.created && + currency == other.currency && + lastFour == other.lastFour && + owner == other.owner && + ownerType == other.ownerType && + routingNumber == other.routingNumber && + state == other.state && + type == other.type && + verificationAttempts == other.verificationAttempts && + verificationMethod == other.verificationMethod && + verificationState == other.verificationState && + accountToken == other.accountToken && + address == other.address && + companyId == other.companyId && + dob == other.dob && + doingBusinessAs == other.doingBusinessAs && + financialAccountToken == other.financialAccountToken && + name == other.name && + userDefinedId == other.userDefinedId && + verificationFailedReason == other.verificationFailedReason && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + country, + created, + currency, + lastFour, + owner, + ownerType, + routingNumber, + state, + type, + verificationAttempts, + verificationMethod, + verificationState, + accountToken, + address, + companyId, + dob, + doingBusinessAs, + financialAccountToken, + name, + userDefinedId, + verificationFailedReason, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExternalBankAccountCreatedWebhookEvent{token=$token, country=$country, created=$created, currency=$currency, lastFour=$lastFour, owner=$owner, ownerType=$ownerType, routingNumber=$routingNumber, state=$state, type=$type, verificationAttempts=$verificationAttempts, verificationMethod=$verificationMethod, verificationState=$verificationState, accountToken=$accountToken, address=$address, companyId=$companyId, dob=$dob, doingBusinessAs=$doingBusinessAs, financialAccountToken=$financialAccountToken, name=$name, userDefinedId=$userDefinedId, verificationFailedReason=$verificationFailedReason, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdatedWebhookEvent.kt new file mode 100644 index 000000000..9971dcf7f --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalBankAccountUpdatedWebhookEvent.kt @@ -0,0 +1,1331 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ExternalBankAccountUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val country: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val lastFour: JsonField, + private val owner: JsonField, + private val ownerType: JsonField, + private val routingNumber: JsonField, + private val state: JsonField, + private val type: JsonField, + private val verificationAttempts: JsonField, + private val verificationMethod: JsonField, + private val verificationState: JsonField, + private val accountToken: JsonField, + private val address: JsonField, + private val companyId: JsonField, + private val dob: JsonField, + private val doingBusinessAs: JsonField, + private val financialAccountToken: JsonField, + private val name: JsonField, + private val userDefinedId: JsonField, + private val verificationFailedReason: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("country") @ExcludeMissing country: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("last_four") @ExcludeMissing lastFour: JsonField = JsonMissing.of(), + @JsonProperty("owner") @ExcludeMissing owner: JsonField = JsonMissing.of(), + @JsonProperty("owner_type") + @ExcludeMissing + ownerType: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + routingNumber: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + state: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("verification_attempts") + @ExcludeMissing + verificationAttempts: JsonField = JsonMissing.of(), + @JsonProperty("verification_method") + @ExcludeMissing + verificationMethod: JsonField = JsonMissing.of(), + @JsonProperty("verification_state") + @ExcludeMissing + verificationState: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("address") + @ExcludeMissing + address: JsonField = JsonMissing.of(), + @JsonProperty("company_id") @ExcludeMissing companyId: JsonField = JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), + @JsonProperty("doing_business_as") + @ExcludeMissing + doingBusinessAs: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("verification_failed_reason") + @ExcludeMissing + verificationFailedReason: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + country, + created, + currency, + lastFour, + owner, + ownerType, + routingNumber, + state, + type, + verificationAttempts, + verificationMethod, + verificationState, + accountToken, + address, + companyId, + dob, + doingBusinessAs, + financialAccountToken, + name, + userDefinedId, + verificationFailedReason, + eventType, + mutableMapOf(), + ) + + fun toExternalBankAccount(): ExternalBankAccount = + ExternalBankAccount.builder() + .token(token) + .country(country) + .created(created) + .currency(currency) + .lastFour(lastFour) + .owner(owner) + .ownerType(ownerType) + .routingNumber(routingNumber) + .state(state) + .type(type) + .verificationAttempts(verificationAttempts) + .verificationMethod(verificationMethod) + .verificationState(verificationState) + .accountToken(accountToken) + .address(address) + .companyId(companyId) + .dob(dob) + .doingBusinessAs(doingBusinessAs) + .financialAccountToken(financialAccountToken) + .name(name) + .userDefinedId(userDefinedId) + .verificationFailedReason(verificationFailedReason) + .build() + + /** + * A globally unique identifier for this record of an external bank account association. If a + * program links an external bank account to more than one end-user or to both the program and + * the end-user, then Lithic will return each record of the association + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * The country that the bank account is located in using ISO 3166-1. We will only accept USA + * bank accounts e.g., USA + * + * @throws LithicInvalidDataException if 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") + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic account. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * currency of the external account 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number passed + * + * @throws LithicInvalidDataException if 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") + + /** + * Legal Name of the business or individual who owns the external account. This will appear in + * statements + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun owner(): String = owner.getRequired("owner") + + /** + * Owner 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 ownerType(): OwnerType = ownerType.getRequired("owner_type") + + /** + * Routing 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 routingNumber(): String = routingNumber.getRequired("routing_number") + + /** + * Account 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 state(): ExternalBankAccount.State = state.getRequired("state") + + /** + * Account 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(): ExternalBankAccount.AccountType = type.getRequired("type") + + /** + * The number of attempts at verification + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun verificationAttempts(): Long = verificationAttempts.getRequired("verification_attempts") + + /** + * Verification Method + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun verificationMethod(): VerificationMethod = + verificationMethod.getRequired("verification_method") + + /** + * Verification 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 verificationState(): ExternalBankAccount.VerificationState = + verificationState.getRequired("verification_state") + + /** + * Indicates which Lithic account the external account is associated with. For external accounts + * that are associated with the program, account_token field returned will be null + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * Address + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun address(): Optional = address.getOptional("address") + + /** + * Optional field that helps identify bank accounts in receipts + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyId(): Optional = companyId.getOptional("company_id") + + /** + * Date of Birth of the Individual that owns the external bank account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dob(): Optional = dob.getOptional("dob") + + /** + * Doing Business As + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun doingBusinessAs(): Optional = doingBusinessAs.getOptional("doing_business_as") + + /** + * The financial account token of the operating account to fund the micro deposits + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun financialAccountToken(): Optional = + financialAccountToken.getOptional("financial_account_token") + + /** + * The nickname for this External Bank Account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * User Defined ID + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * Optional free text description of the reason for the failed verification. For ACH + * micro-deposits returned, this field will display the reason return code sent by the ACH + * network + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun verificationFailedReason(): Optional = + verificationFailedReason.getOptional("verification_failed_reason") + + /** + * 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 [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 [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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [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 [owner]. + * + * Unlike [owner], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("owner") @ExcludeMissing fun _owner(): JsonField = owner + + /** + * Returns the raw JSON value of [ownerType]. + * + * Unlike [ownerType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("owner_type") @ExcludeMissing fun _ownerType(): JsonField = ownerType + + /** + * Returns the raw JSON value of [routingNumber]. + * + * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber + + /** + * Returns the raw JSON value of [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 + + /** + * Returns the raw JSON value of [verificationAttempts]. + * + * Unlike [verificationAttempts], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("verification_attempts") + @ExcludeMissing + fun _verificationAttempts(): JsonField = verificationAttempts + + /** + * Returns the raw JSON value of [verificationMethod]. + * + * Unlike [verificationMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("verification_method") + @ExcludeMissing + fun _verificationMethod(): JsonField = verificationMethod + + /** + * Returns the raw JSON value of [verificationState]. + * + * Unlike [verificationState], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("verification_state") + @ExcludeMissing + fun _verificationState(): JsonField = verificationState + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [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 [companyId]. + * + * Unlike [companyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + + /** + * Returns the raw JSON value of [dob]. + * + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + + /** + * Returns the raw JSON value of [doingBusinessAs]. + * + * Unlike [doingBusinessAs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("doing_business_as") + @ExcludeMissing + fun _doingBusinessAs(): JsonField = doingBusinessAs + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + /** + * Returns the raw JSON value of [verificationFailedReason]. + * + * Unlike [verificationFailedReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("verification_failed_reason") + @ExcludeMissing + fun _verificationFailedReason(): JsonField = verificationFailedReason + + /** + * 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 + * [ExternalBankAccountUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .country() + * .created() + * .currency() + * .lastFour() + * .owner() + * .ownerType() + * .routingNumber() + * .state() + * .type() + * .verificationAttempts() + * .verificationMethod() + * .verificationState() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExternalBankAccountUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var country: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var lastFour: JsonField? = null + private var owner: JsonField? = null + private var ownerType: JsonField? = null + private var routingNumber: JsonField? = null + private var state: JsonField? = null + private var type: JsonField? = null + private var verificationAttempts: JsonField? = null + private var verificationMethod: JsonField? = null + private var verificationState: JsonField? = null + private var accountToken: JsonField = JsonMissing.of() + private var address: JsonField = JsonMissing.of() + private var companyId: JsonField = JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var doingBusinessAs: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var verificationFailedReason: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + externalBankAccountUpdatedWebhookEvent: ExternalBankAccountUpdatedWebhookEvent + ) = apply { + token = externalBankAccountUpdatedWebhookEvent.token + country = externalBankAccountUpdatedWebhookEvent.country + created = externalBankAccountUpdatedWebhookEvent.created + currency = externalBankAccountUpdatedWebhookEvent.currency + lastFour = externalBankAccountUpdatedWebhookEvent.lastFour + owner = externalBankAccountUpdatedWebhookEvent.owner + ownerType = externalBankAccountUpdatedWebhookEvent.ownerType + routingNumber = externalBankAccountUpdatedWebhookEvent.routingNumber + state = externalBankAccountUpdatedWebhookEvent.state + type = externalBankAccountUpdatedWebhookEvent.type + verificationAttempts = externalBankAccountUpdatedWebhookEvent.verificationAttempts + verificationMethod = externalBankAccountUpdatedWebhookEvent.verificationMethod + verificationState = externalBankAccountUpdatedWebhookEvent.verificationState + accountToken = externalBankAccountUpdatedWebhookEvent.accountToken + address = externalBankAccountUpdatedWebhookEvent.address + companyId = externalBankAccountUpdatedWebhookEvent.companyId + dob = externalBankAccountUpdatedWebhookEvent.dob + doingBusinessAs = externalBankAccountUpdatedWebhookEvent.doingBusinessAs + financialAccountToken = externalBankAccountUpdatedWebhookEvent.financialAccountToken + name = externalBankAccountUpdatedWebhookEvent.name + userDefinedId = externalBankAccountUpdatedWebhookEvent.userDefinedId + verificationFailedReason = + externalBankAccountUpdatedWebhookEvent.verificationFailedReason + eventType = externalBankAccountUpdatedWebhookEvent.eventType + additionalProperties = + externalBankAccountUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** + * A globally unique identifier for this record of an external bank account association. If + * a program links an external bank account to more than one end-user or to both the program + * and the end-user, then Lithic will return each record of the association + */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** + * The country that the bank account is located in using ISO 3166-1. We will only accept USA + * bank accounts e.g., USA + */ + 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 } + + /** + * An ISO 8601 string representing when this funding source was added to the Lithic account. + */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** currency of the external account 3-character alphabetic ISO 4217 code */ + 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 } + + /** + * The last 4 digits of the bank account. Derived by Lithic from the account number passed + */ + 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 } + + /** + * Legal Name of the business or individual who owns the external account. This will appear + * in statements + */ + fun owner(owner: String) = owner(JsonField.of(owner)) + + /** + * Sets [Builder.owner] to an arbitrary JSON value. + * + * You should usually call [Builder.owner] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun owner(owner: JsonField) = apply { this.owner = owner } + + /** Owner Type */ + fun ownerType(ownerType: OwnerType) = ownerType(JsonField.of(ownerType)) + + /** + * Sets [Builder.ownerType] to an arbitrary JSON value. + * + * You should usually call [Builder.ownerType] with a well-typed [OwnerType] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ownerType(ownerType: JsonField) = apply { this.ownerType = ownerType } + + /** Routing Number */ + fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) + + /** + * Sets [Builder.routingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.routingNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } + + /** Account State */ + fun state(state: ExternalBankAccount.State) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [ExternalBankAccount.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 } + + /** Account Type */ + fun type(type: ExternalBankAccount.AccountType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed + * [ExternalBankAccount.AccountType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The number of attempts at verification */ + fun verificationAttempts(verificationAttempts: Long) = + verificationAttempts(JsonField.of(verificationAttempts)) + + /** + * Sets [Builder.verificationAttempts] to an arbitrary JSON value. + * + * You should usually call [Builder.verificationAttempts] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun verificationAttempts(verificationAttempts: JsonField) = apply { + this.verificationAttempts = verificationAttempts + } + + /** Verification Method */ + fun verificationMethod(verificationMethod: VerificationMethod) = + verificationMethod(JsonField.of(verificationMethod)) + + /** + * Sets [Builder.verificationMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.verificationMethod] with a well-typed + * [VerificationMethod] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun verificationMethod(verificationMethod: JsonField) = apply { + this.verificationMethod = verificationMethod + } + + /** Verification State */ + fun verificationState(verificationState: ExternalBankAccount.VerificationState) = + verificationState(JsonField.of(verificationState)) + + /** + * Sets [Builder.verificationState] to an arbitrary JSON value. + * + * You should usually call [Builder.verificationState] with a well-typed + * [ExternalBankAccount.VerificationState] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun verificationState(verificationState: JsonField) = + apply { + this.verificationState = verificationState + } + + /** + * Indicates which Lithic account the external account is associated with. For external + * accounts that are associated with the program, account_token field returned will be null + */ + fun accountToken(accountToken: String?) = accountToken(JsonField.ofNullable(accountToken)) + + /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ + fun accountToken(accountToken: Optional) = accountToken(accountToken.getOrNull()) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Address */ + fun address(address: ExternalBankAccountAddress?) = address(JsonField.ofNullable(address)) + + /** Alias for calling [Builder.address] with `address.orElse(null)`. */ + fun address(address: Optional) = address(address.getOrNull()) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [ExternalBankAccountAddress] + * 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 + } + + /** Optional field that helps identify bank accounts in receipts */ + fun companyId(companyId: String?) = companyId(JsonField.ofNullable(companyId)) + + /** Alias for calling [Builder.companyId] with `companyId.orElse(null)`. */ + fun companyId(companyId: Optional) = companyId(companyId.getOrNull()) + + /** + * Sets [Builder.companyId] to an arbitrary JSON value. + * + * You should usually call [Builder.companyId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyId(companyId: JsonField) = apply { this.companyId = companyId } + + /** Date of Birth of the Individual that owns the external bank account */ + fun dob(dob: LocalDate?) = dob(JsonField.ofNullable(dob)) + + /** Alias for calling [Builder.dob] with `dob.orElse(null)`. */ + fun dob(dob: Optional) = dob(dob.getOrNull()) + + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [LocalDate] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** Doing Business As */ + fun doingBusinessAs(doingBusinessAs: String?) = + doingBusinessAs(JsonField.ofNullable(doingBusinessAs)) + + /** Alias for calling [Builder.doingBusinessAs] with `doingBusinessAs.orElse(null)`. */ + fun doingBusinessAs(doingBusinessAs: Optional) = + doingBusinessAs(doingBusinessAs.getOrNull()) + + /** + * Sets [Builder.doingBusinessAs] to an arbitrary JSON value. + * + * You should usually call [Builder.doingBusinessAs] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun doingBusinessAs(doingBusinessAs: JsonField) = apply { + this.doingBusinessAs = doingBusinessAs + } + + /** The financial account token of the operating account to fund the micro deposits */ + fun financialAccountToken(financialAccountToken: String?) = + financialAccountToken(JsonField.ofNullable(financialAccountToken)) + + /** + * Alias for calling [Builder.financialAccountToken] with + * `financialAccountToken.orElse(null)`. + */ + fun financialAccountToken(financialAccountToken: Optional) = + financialAccountToken(financialAccountToken.getOrNull()) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** The nickname for this External Bank Account */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** User Defined ID */ + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** + * Optional free text description of the reason for the failed verification. For ACH + * micro-deposits returned, this field will display the reason return code sent by the ACH + * network + */ + fun verificationFailedReason(verificationFailedReason: String?) = + verificationFailedReason(JsonField.ofNullable(verificationFailedReason)) + + /** + * Alias for calling [Builder.verificationFailedReason] with + * `verificationFailedReason.orElse(null)`. + */ + fun verificationFailedReason(verificationFailedReason: Optional) = + verificationFailedReason(verificationFailedReason.getOrNull()) + + /** + * Sets [Builder.verificationFailedReason] to an arbitrary JSON value. + * + * You should usually call [Builder.verificationFailedReason] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun verificationFailedReason(verificationFailedReason: JsonField) = apply { + this.verificationFailedReason = verificationFailedReason + } + + /** 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 [ExternalBankAccountUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .country() + * .created() + * .currency() + * .lastFour() + * .owner() + * .ownerType() + * .routingNumber() + * .state() + * .type() + * .verificationAttempts() + * .verificationMethod() + * .verificationState() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExternalBankAccountUpdatedWebhookEvent = + ExternalBankAccountUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("country", country), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("lastFour", lastFour), + checkRequired("owner", owner), + checkRequired("ownerType", ownerType), + checkRequired("routingNumber", routingNumber), + checkRequired("state", state), + checkRequired("type", type), + checkRequired("verificationAttempts", verificationAttempts), + checkRequired("verificationMethod", verificationMethod), + checkRequired("verificationState", verificationState), + accountToken, + address, + companyId, + dob, + doingBusinessAs, + financialAccountToken, + name, + userDefinedId, + verificationFailedReason, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExternalBankAccountUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + country() + created() + currency() + lastFour() + owner() + ownerType().validate() + routingNumber() + state().validate() + type().validate() + verificationAttempts() + verificationMethod().validate() + verificationState().validate() + accountToken() + address().ifPresent { it.validate() } + companyId() + dob() + doingBusinessAs() + financialAccountToken() + name() + userDefinedId() + verificationFailedReason() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (country.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (lastFour.asKnown().isPresent) 1 else 0) + + (if (owner.asKnown().isPresent) 1 else 0) + + (ownerType.asKnown().getOrNull()?.validity() ?: 0) + + (if (routingNumber.asKnown().isPresent) 1 else 0) + + (state.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (verificationAttempts.asKnown().isPresent) 1 else 0) + + (verificationMethod.asKnown().getOrNull()?.validity() ?: 0) + + (verificationState.asKnown().getOrNull()?.validity() ?: 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (address.asKnown().getOrNull()?.validity() ?: 0) + + (if (companyId.asKnown().isPresent) 1 else 0) + + (if (dob.asKnown().isPresent) 1 else 0) + + (if (doingBusinessAs.asKnown().isPresent) 1 else 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + (if (verificationFailedReason.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 EXTERNAL_BANK_ACCOUNT_UPDATED = of("external_bank_account.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + EXTERNAL_BANK_ACCOUNT_UPDATED + } + + /** + * 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 { + EXTERNAL_BANK_ACCOUNT_UPDATED, + /** + * 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) { + EXTERNAL_BANK_ACCOUNT_UPDATED -> Value.EXTERNAL_BANK_ACCOUNT_UPDATED + 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) { + EXTERNAL_BANK_ACCOUNT_UPDATED -> Known.EXTERNAL_BANK_ACCOUNT_UPDATED + 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 + + 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 ExternalBankAccountUpdatedWebhookEvent && + token == other.token && + country == other.country && + created == other.created && + currency == other.currency && + lastFour == other.lastFour && + owner == other.owner && + ownerType == other.ownerType && + routingNumber == other.routingNumber && + state == other.state && + type == other.type && + verificationAttempts == other.verificationAttempts && + verificationMethod == other.verificationMethod && + verificationState == other.verificationState && + accountToken == other.accountToken && + address == other.address && + companyId == other.companyId && + dob == other.dob && + doingBusinessAs == other.doingBusinessAs && + financialAccountToken == other.financialAccountToken && + name == other.name && + userDefinedId == other.userDefinedId && + verificationFailedReason == other.verificationFailedReason && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + country, + created, + currency, + lastFour, + owner, + ownerType, + routingNumber, + state, + type, + verificationAttempts, + verificationMethod, + verificationState, + accountToken, + address, + companyId, + dob, + doingBusinessAs, + financialAccountToken, + name, + userDefinedId, + verificationFailedReason, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExternalBankAccountUpdatedWebhookEvent{token=$token, country=$country, created=$created, currency=$currency, lastFour=$lastFour, owner=$owner, ownerType=$ownerType, routingNumber=$routingNumber, state=$state, type=$type, verificationAttempts=$verificationAttempts, verificationMethod=$verificationMethod, verificationState=$verificationState, accountToken=$accountToken, address=$address, companyId=$companyId, dob=$dob, doingBusinessAs=$doingBusinessAs, financialAccountToken=$financialAccountToken, name=$name, userDefinedId=$userDefinedId, verificationFailedReason=$verificationFailedReason, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreatedWebhookEvent.kt new file mode 100644 index 000000000..532973319 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentCreatedWebhookEvent.kt @@ -0,0 +1,921 @@ +// 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 + +class ExternalPaymentCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val created: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val category: JsonField, + private val currency: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val paymentType: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val userDefinedId: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("payment_type") + @ExcludeMissing + paymentType: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + created, + status, + updated, + category, + currency, + events, + family, + financialAccountToken, + paymentType, + pendingAmount, + result, + settledAmount, + userDefinedId, + eventType, + mutableMapOf(), + ) + + fun toExternalPayment(): ExternalPayment = + ExternalPayment.builder() + .token(token) + .created(created) + .status(status) + .updated(updated) + .category(category) + .currency(currency) + .events(events) + .family(family) + .financialAccountToken(financialAccountToken) + .paymentType(paymentType) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .userDefinedId(userDefinedId) + .build() + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): ExternalPayment.TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun category(): Optional = + category.getOptional("category") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun events(): Optional> = + events.getOptional("events") + + /** + * EXTERNAL_PAYMENT - External Payment Response + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun family(): Optional = family.getOptional("family") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun financialAccountToken(): Optional = + financialAccountToken.getOptional("financial_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentType(): Optional = + paymentType.getOptional("payment_type") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pendingAmount(): Optional = pendingAmount.getOptional("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun settledAmount(): Optional = settledAmount.getOptional("settled_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * 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 [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 [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 [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [paymentType]. + * + * Unlike [paymentType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_type") + @ExcludeMissing + fun _paymentType(): JsonField = paymentType + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + /** + * 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 + * [ExternalPaymentCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .status() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExternalPaymentCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var created: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var category: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var events: JsonField>? = null + private var family: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var paymentType: JsonField = + JsonMissing.of() + private var pendingAmount: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var settledAmount: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentCreatedWebhookEvent: ExternalPaymentCreatedWebhookEvent) = + apply { + token = externalPaymentCreatedWebhookEvent.token + created = externalPaymentCreatedWebhookEvent.created + status = externalPaymentCreatedWebhookEvent.status + updated = externalPaymentCreatedWebhookEvent.updated + category = externalPaymentCreatedWebhookEvent.category + currency = externalPaymentCreatedWebhookEvent.currency + events = externalPaymentCreatedWebhookEvent.events.map { it.toMutableList() } + family = externalPaymentCreatedWebhookEvent.family + financialAccountToken = externalPaymentCreatedWebhookEvent.financialAccountToken + paymentType = externalPaymentCreatedWebhookEvent.paymentType + pendingAmount = externalPaymentCreatedWebhookEvent.pendingAmount + result = externalPaymentCreatedWebhookEvent.result + settledAmount = externalPaymentCreatedWebhookEvent.settledAmount + userDefinedId = externalPaymentCreatedWebhookEvent.userDefinedId + eventType = externalPaymentCreatedWebhookEvent.eventType + additionalProperties = + externalPaymentCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** The status of the transaction */ + fun status(status: ExternalPayment.TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [ExternalPayment.TransactionStatus] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun category(category: ExternalPayment.ExternalPaymentCategory) = + category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [ExternalPayment.ExternalPaymentCategory] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun category(category: JsonField) = apply { + this.category = category + } + + fun 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 events(events: List) = + events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [ExternalPayment.ExternalPaymentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: ExternalPayment.ExternalPaymentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** EXTERNAL_PAYMENT - External Payment Response */ + fun family(family: ExternalPayment.Family) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [ExternalPayment.Family] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + fun paymentType(paymentType: ExternalPayment.ExternalPaymentDirection) = + paymentType(JsonField.of(paymentType)) + + /** + * Sets [Builder.paymentType] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentType] with a well-typed + * [ExternalPayment.ExternalPaymentDirection] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun paymentType(paymentType: JsonField) = apply { + this.paymentType = paymentType + } + + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: ExternalPayment.TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [ExternalPayment.TransactionResult] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** 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 [ExternalPaymentCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .status() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExternalPaymentCreatedWebhookEvent = + ExternalPaymentCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("created", created), + checkRequired("status", status), + checkRequired("updated", updated), + category, + currency, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + family, + financialAccountToken, + paymentType, + pendingAmount, + result, + settledAmount, + userDefinedId, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExternalPaymentCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + created() + status().validate() + updated() + category().ifPresent { it.validate() } + currency() + events().ifPresent { it.forEach { it.validate() } } + family().ifPresent { it.validate() } + financialAccountToken() + paymentType().ifPresent { it.validate() } + pendingAmount() + result().ifPresent { it.validate() } + settledAmount() + userDefinedId() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (paymentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 EXTERNAL_PAYMENT_CREATED = of("external_payment.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + EXTERNAL_PAYMENT_CREATED + } + + /** + * 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 { + EXTERNAL_PAYMENT_CREATED, + /** + * 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) { + EXTERNAL_PAYMENT_CREATED -> Value.EXTERNAL_PAYMENT_CREATED + 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) { + EXTERNAL_PAYMENT_CREATED -> Known.EXTERNAL_PAYMENT_CREATED + 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 + + 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 ExternalPaymentCreatedWebhookEvent && + token == other.token && + created == other.created && + status == other.status && + updated == other.updated && + category == other.category && + currency == other.currency && + events == other.events && + family == other.family && + financialAccountToken == other.financialAccountToken && + paymentType == other.paymentType && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + userDefinedId == other.userDefinedId && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + created, + status, + updated, + category, + currency, + events, + family, + financialAccountToken, + paymentType, + pendingAmount, + result, + settledAmount, + userDefinedId, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExternalPaymentCreatedWebhookEvent{token=$token, created=$created, status=$status, updated=$updated, category=$category, currency=$currency, events=$events, family=$family, financialAccountToken=$financialAccountToken, paymentType=$paymentType, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, userDefinedId=$userDefinedId, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentUpdatedWebhookEvent.kt new file mode 100644 index 000000000..dd7ad1eff --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ExternalPaymentUpdatedWebhookEvent.kt @@ -0,0 +1,921 @@ +// 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 + +class ExternalPaymentUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val created: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val category: JsonField, + private val currency: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val paymentType: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val userDefinedId: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("payment_type") + @ExcludeMissing + paymentType: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + created, + status, + updated, + category, + currency, + events, + family, + financialAccountToken, + paymentType, + pendingAmount, + result, + settledAmount, + userDefinedId, + eventType, + mutableMapOf(), + ) + + fun toExternalPayment(): ExternalPayment = + ExternalPayment.builder() + .token(token) + .created(created) + .status(status) + .updated(updated) + .category(category) + .currency(currency) + .events(events) + .family(family) + .financialAccountToken(financialAccountToken) + .paymentType(paymentType) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .userDefinedId(userDefinedId) + .build() + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): ExternalPayment.TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun category(): Optional = + category.getOptional("category") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun events(): Optional> = + events.getOptional("events") + + /** + * EXTERNAL_PAYMENT - External Payment Response + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun family(): Optional = family.getOptional("family") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun financialAccountToken(): Optional = + financialAccountToken.getOptional("financial_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentType(): Optional = + paymentType.getOptional("payment_type") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pendingAmount(): Optional = pendingAmount.getOptional("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun settledAmount(): Optional = settledAmount.getOptional("settled_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * 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 [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 [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 [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [paymentType]. + * + * Unlike [paymentType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_type") + @ExcludeMissing + fun _paymentType(): JsonField = paymentType + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + /** + * 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 + * [ExternalPaymentUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .status() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExternalPaymentUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var created: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var category: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var events: JsonField>? = null + private var family: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var paymentType: JsonField = + JsonMissing.of() + private var pendingAmount: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var settledAmount: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(externalPaymentUpdatedWebhookEvent: ExternalPaymentUpdatedWebhookEvent) = + apply { + token = externalPaymentUpdatedWebhookEvent.token + created = externalPaymentUpdatedWebhookEvent.created + status = externalPaymentUpdatedWebhookEvent.status + updated = externalPaymentUpdatedWebhookEvent.updated + category = externalPaymentUpdatedWebhookEvent.category + currency = externalPaymentUpdatedWebhookEvent.currency + events = externalPaymentUpdatedWebhookEvent.events.map { it.toMutableList() } + family = externalPaymentUpdatedWebhookEvent.family + financialAccountToken = externalPaymentUpdatedWebhookEvent.financialAccountToken + paymentType = externalPaymentUpdatedWebhookEvent.paymentType + pendingAmount = externalPaymentUpdatedWebhookEvent.pendingAmount + result = externalPaymentUpdatedWebhookEvent.result + settledAmount = externalPaymentUpdatedWebhookEvent.settledAmount + userDefinedId = externalPaymentUpdatedWebhookEvent.userDefinedId + eventType = externalPaymentUpdatedWebhookEvent.eventType + additionalProperties = + externalPaymentUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** The status of the transaction */ + fun status(status: ExternalPayment.TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [ExternalPayment.TransactionStatus] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun category(category: ExternalPayment.ExternalPaymentCategory) = + category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [ExternalPayment.ExternalPaymentCategory] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun category(category: JsonField) = apply { + this.category = category + } + + fun 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 events(events: List) = + events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [ExternalPayment.ExternalPaymentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: ExternalPayment.ExternalPaymentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** EXTERNAL_PAYMENT - External Payment Response */ + fun family(family: ExternalPayment.Family) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [ExternalPayment.Family] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + fun paymentType(paymentType: ExternalPayment.ExternalPaymentDirection) = + paymentType(JsonField.of(paymentType)) + + /** + * Sets [Builder.paymentType] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentType] with a well-typed + * [ExternalPayment.ExternalPaymentDirection] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun paymentType(paymentType: JsonField) = apply { + this.paymentType = paymentType + } + + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: ExternalPayment.TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [ExternalPayment.TransactionResult] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** 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 [ExternalPaymentUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .status() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ExternalPaymentUpdatedWebhookEvent = + ExternalPaymentUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("created", created), + checkRequired("status", status), + checkRequired("updated", updated), + category, + currency, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + family, + financialAccountToken, + paymentType, + pendingAmount, + result, + settledAmount, + userDefinedId, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ExternalPaymentUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + created() + status().validate() + updated() + category().ifPresent { it.validate() } + currency() + events().ifPresent { it.forEach { it.validate() } } + family().ifPresent { it.validate() } + financialAccountToken() + paymentType().ifPresent { it.validate() } + pendingAmount() + result().ifPresent { it.validate() } + settledAmount() + userDefinedId() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (paymentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 EXTERNAL_PAYMENT_UPDATED = of("external_payment.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + EXTERNAL_PAYMENT_UPDATED + } + + /** + * 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 { + EXTERNAL_PAYMENT_UPDATED, + /** + * 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) { + EXTERNAL_PAYMENT_UPDATED -> Value.EXTERNAL_PAYMENT_UPDATED + 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) { + EXTERNAL_PAYMENT_UPDATED -> Known.EXTERNAL_PAYMENT_UPDATED + 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 + + 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 ExternalPaymentUpdatedWebhookEvent && + token == other.token && + created == other.created && + status == other.status && + updated == other.updated && + category == other.category && + currency == other.currency && + events == other.events && + family == other.family && + financialAccountToken == other.financialAccountToken && + paymentType == other.paymentType && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + userDefinedId == other.userDefinedId && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + created, + status, + updated, + category, + currency, + events, + family, + financialAccountToken, + paymentType, + pendingAmount, + result, + settledAmount, + userDefinedId, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ExternalPaymentUpdatedWebhookEvent{token=$token, created=$created, status=$status, updated=$updated, category=$category, currency=$currency, events=$events, family=$family, financialAccountToken=$financialAccountToken, paymentType=$paymentType, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, userDefinedId=$userDefinedId, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreatedWebhookEvent.kt new file mode 100644 index 000000000..c6e3c854f --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreatedWebhookEvent.kt @@ -0,0 +1,853 @@ +// 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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class FinancialAccountCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountToken: JsonField, + private val created: JsonField, + private val creditConfiguration: JsonField, + private val isForBenefitOf: JsonField, + private val nickname: JsonField, + private val status: JsonField, + private val type: JsonField, + private val updated: JsonField, + private val accountNumber: JsonField, + private val routingNumber: JsonField, + private val substatus: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("credit_configuration") + @ExcludeMissing + creditConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("is_for_benefit_of") + @ExcludeMissing + isForBenefitOf: JsonField = JsonMissing.of(), + @JsonProperty("nickname") @ExcludeMissing nickname: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("account_number") + @ExcludeMissing + accountNumber: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + routingNumber: JsonField = JsonMissing.of(), + @JsonProperty("substatus") + @ExcludeMissing + substatus: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountToken, + created, + creditConfiguration, + isForBenefitOf, + nickname, + status, + type, + updated, + accountNumber, + routingNumber, + substatus, + eventType, + mutableMapOf(), + ) + + fun toFinancialAccount(): FinancialAccount = + FinancialAccount.builder() + .token(token) + .accountToken(accountToken) + .created(created) + .creditConfiguration(creditConfiguration) + .isForBenefitOf(isForBenefitOf) + .nickname(nickname) + .status(status) + .type(type) + .updated(updated) + .accountNumber(accountNumber) + .routingNumber(routingNumber) + .substatus(substatus) + .build() + + /** + * Globally unique identifier for the account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditConfiguration(): Optional = + creditConfiguration.getOptional("credit_configuration") + + /** + * Whether financial account is for the benefit of another entity + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isForBenefitOf(): Boolean = isForBenefitOf.getRequired("is_for_benefit_of") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nickname(): Optional = nickname.getOptional("nickname") + + /** + * Status of the financial account + * + * @throws LithicInvalidDataException if 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(): FinancialAccount.FinancialAccountStatus = status.getRequired("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): FinancialAccount.Type = type.getRequired("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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountNumber(): Optional = accountNumber.getOptional("account_number") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingNumber(): Optional = routingNumber.getOptional("routing_number") + + /** + * Substatus for the financial account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = + substatus.getOptional("substatus") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [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 [creditConfiguration]. + * + * Unlike [creditConfiguration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_configuration") + @ExcludeMissing + fun _creditConfiguration(): JsonField = + creditConfiguration + + /** + * Returns the raw JSON value of [isForBenefitOf]. + * + * Unlike [isForBenefitOf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_for_benefit_of") + @ExcludeMissing + fun _isForBenefitOf(): JsonField = isForBenefitOf + + /** + * Returns the raw JSON value of [nickname]. + * + * Unlike [nickname], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("nickname") @ExcludeMissing fun _nickname(): JsonField = nickname + + /** + * 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 [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 [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [accountNumber]. + * + * Unlike [accountNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber + + /** + * Returns the raw JSON value of [routingNumber]. + * + * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber + + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("substatus") + @ExcludeMissing + fun _substatus(): JsonField = substatus + + /** + * 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 + * [FinancialAccountCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .created() + * .creditConfiguration() + * .isForBenefitOf() + * .nickname() + * .status() + * .type() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FinancialAccountCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var created: JsonField? = null + private var creditConfiguration: JsonField? = + null + private var isForBenefitOf: JsonField? = null + private var nickname: JsonField? = null + private var status: JsonField? = null + private var type: JsonField? = null + private var updated: JsonField? = null + private var accountNumber: JsonField = JsonMissing.of() + private var routingNumber: JsonField = JsonMissing.of() + private var substatus: JsonField = + JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + financialAccountCreatedWebhookEvent: FinancialAccountCreatedWebhookEvent + ) = apply { + token = financialAccountCreatedWebhookEvent.token + accountToken = financialAccountCreatedWebhookEvent.accountToken + created = financialAccountCreatedWebhookEvent.created + creditConfiguration = financialAccountCreatedWebhookEvent.creditConfiguration + isForBenefitOf = financialAccountCreatedWebhookEvent.isForBenefitOf + nickname = financialAccountCreatedWebhookEvent.nickname + status = financialAccountCreatedWebhookEvent.status + type = financialAccountCreatedWebhookEvent.type + updated = financialAccountCreatedWebhookEvent.updated + accountNumber = financialAccountCreatedWebhookEvent.accountNumber + routingNumber = financialAccountCreatedWebhookEvent.routingNumber + substatus = financialAccountCreatedWebhookEvent.substatus + eventType = financialAccountCreatedWebhookEvent.eventType + additionalProperties = + financialAccountCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the account */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun accountToken(accountToken: String?) = accountToken(JsonField.ofNullable(accountToken)) + + /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ + fun accountToken(accountToken: Optional) = accountToken(accountToken.getOrNull()) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun creditConfiguration( + creditConfiguration: FinancialAccount.FinancialAccountCreditConfig? + ) = creditConfiguration(JsonField.ofNullable(creditConfiguration)) + + /** + * Alias for calling [Builder.creditConfiguration] with `creditConfiguration.orElse(null)`. + */ + fun creditConfiguration( + creditConfiguration: Optional + ) = creditConfiguration(creditConfiguration.getOrNull()) + + /** + * Sets [Builder.creditConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.creditConfiguration] with a well-typed + * [FinancialAccount.FinancialAccountCreditConfig] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun creditConfiguration( + creditConfiguration: JsonField + ) = apply { this.creditConfiguration = creditConfiguration } + + /** Whether financial account is for the benefit of another entity */ + fun isForBenefitOf(isForBenefitOf: Boolean) = isForBenefitOf(JsonField.of(isForBenefitOf)) + + /** + * Sets [Builder.isForBenefitOf] to an arbitrary JSON value. + * + * You should usually call [Builder.isForBenefitOf] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isForBenefitOf(isForBenefitOf: JsonField) = apply { + this.isForBenefitOf = isForBenefitOf + } + + fun nickname(nickname: String?) = nickname(JsonField.ofNullable(nickname)) + + /** Alias for calling [Builder.nickname] with `nickname.orElse(null)`. */ + fun nickname(nickname: Optional) = nickname(nickname.getOrNull()) + + /** + * Sets [Builder.nickname] to an arbitrary JSON value. + * + * You should usually call [Builder.nickname] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nickname(nickname: JsonField) = apply { this.nickname = nickname } + + /** Status of the financial account */ + fun status(status: FinancialAccount.FinancialAccountStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [FinancialAccount.FinancialAccountStatus] 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 type(type: FinancialAccount.Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FinancialAccount.Type] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun accountNumber(accountNumber: String?) = + accountNumber(JsonField.ofNullable(accountNumber)) + + /** Alias for calling [Builder.accountNumber] with `accountNumber.orElse(null)`. */ + fun accountNumber(accountNumber: Optional) = + accountNumber(accountNumber.getOrNull()) + + /** + * Sets [Builder.accountNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.accountNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } + + fun routingNumber(routingNumber: String?) = + routingNumber(JsonField.ofNullable(routingNumber)) + + /** Alias for calling [Builder.routingNumber] with `routingNumber.orElse(null)`. */ + fun routingNumber(routingNumber: Optional) = + routingNumber(routingNumber.getOrNull()) + + /** + * Sets [Builder.routingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.routingNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } + + /** Substatus for the financial account */ + fun substatus(substatus: FinancialAccount.FinancialAccountSubstatus?) = + substatus(JsonField.ofNullable(substatus)) + + /** Alias for calling [Builder.substatus] with `substatus.orElse(null)`. */ + fun substatus(substatus: Optional) = + substatus(substatus.getOrNull()) + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed + * [FinancialAccount.FinancialAccountSubstatus] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun substatus(substatus: JsonField) = apply { + this.substatus = substatus + } + + /** 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 [FinancialAccountCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .created() + * .creditConfiguration() + * .isForBenefitOf() + * .nickname() + * .status() + * .type() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FinancialAccountCreatedWebhookEvent = + FinancialAccountCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountToken", accountToken), + checkRequired("created", created), + checkRequired("creditConfiguration", creditConfiguration), + checkRequired("isForBenefitOf", isForBenefitOf), + checkRequired("nickname", nickname), + checkRequired("status", status), + checkRequired("type", type), + checkRequired("updated", updated), + accountNumber, + routingNumber, + substatus, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FinancialAccountCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountToken() + created() + creditConfiguration().ifPresent { it.validate() } + isForBenefitOf() + nickname() + status().validate() + type().validate() + updated() + accountNumber() + routingNumber() + substatus().ifPresent { it.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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (creditConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (isForBenefitOf.asKnown().isPresent) 1 else 0) + + (if (nickname.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (accountNumber.asKnown().isPresent) 1 else 0) + + (if (routingNumber.asKnown().isPresent) 1 else 0) + + (substatus.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 FINANCIAL_ACCOUNT_CREATED = of("financial_account.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + FINANCIAL_ACCOUNT_CREATED + } + + /** + * 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 { + FINANCIAL_ACCOUNT_CREATED, + /** + * 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) { + FINANCIAL_ACCOUNT_CREATED -> Value.FINANCIAL_ACCOUNT_CREATED + 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) { + FINANCIAL_ACCOUNT_CREATED -> Known.FINANCIAL_ACCOUNT_CREATED + 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 + + 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 FinancialAccountCreatedWebhookEvent && + token == other.token && + accountToken == other.accountToken && + created == other.created && + creditConfiguration == other.creditConfiguration && + isForBenefitOf == other.isForBenefitOf && + nickname == other.nickname && + status == other.status && + type == other.type && + updated == other.updated && + accountNumber == other.accountNumber && + routingNumber == other.routingNumber && + substatus == other.substatus && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountToken, + created, + creditConfiguration, + isForBenefitOf, + nickname, + status, + type, + updated, + accountNumber, + routingNumber, + substatus, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FinancialAccountCreatedWebhookEvent{token=$token, accountToken=$accountToken, created=$created, creditConfiguration=$creditConfiguration, isForBenefitOf=$isForBenefitOf, nickname=$nickname, status=$status, type=$type, updated=$updated, accountNumber=$accountNumber, routingNumber=$routingNumber, substatus=$substatus, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountUpdatedWebhookEvent.kt new file mode 100644 index 000000000..4856b37e2 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountUpdatedWebhookEvent.kt @@ -0,0 +1,853 @@ +// 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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class FinancialAccountUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountToken: JsonField, + private val created: JsonField, + private val creditConfiguration: JsonField, + private val isForBenefitOf: JsonField, + private val nickname: JsonField, + private val status: JsonField, + private val type: JsonField, + private val updated: JsonField, + private val accountNumber: JsonField, + private val routingNumber: JsonField, + private val substatus: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("credit_configuration") + @ExcludeMissing + creditConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("is_for_benefit_of") + @ExcludeMissing + isForBenefitOf: JsonField = JsonMissing.of(), + @JsonProperty("nickname") @ExcludeMissing nickname: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("account_number") + @ExcludeMissing + accountNumber: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + routingNumber: JsonField = JsonMissing.of(), + @JsonProperty("substatus") + @ExcludeMissing + substatus: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountToken, + created, + creditConfiguration, + isForBenefitOf, + nickname, + status, + type, + updated, + accountNumber, + routingNumber, + substatus, + eventType, + mutableMapOf(), + ) + + fun toFinancialAccount(): FinancialAccount = + FinancialAccount.builder() + .token(token) + .accountToken(accountToken) + .created(created) + .creditConfiguration(creditConfiguration) + .isForBenefitOf(isForBenefitOf) + .nickname(nickname) + .status(status) + .type(type) + .updated(updated) + .accountNumber(accountNumber) + .routingNumber(routingNumber) + .substatus(substatus) + .build() + + /** + * Globally unique identifier for the account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountToken(): Optional = accountToken.getOptional("account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditConfiguration(): Optional = + creditConfiguration.getOptional("credit_configuration") + + /** + * Whether financial account is for the benefit of another entity + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isForBenefitOf(): Boolean = isForBenefitOf.getRequired("is_for_benefit_of") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nickname(): Optional = nickname.getOptional("nickname") + + /** + * Status of the financial account + * + * @throws LithicInvalidDataException if 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(): FinancialAccount.FinancialAccountStatus = status.getRequired("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): FinancialAccount.Type = type.getRequired("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 updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountNumber(): Optional = accountNumber.getOptional("account_number") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routingNumber(): Optional = routingNumber.getOptional("routing_number") + + /** + * Substatus for the financial account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun substatus(): Optional = + substatus.getOptional("substatus") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [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 [creditConfiguration]. + * + * Unlike [creditConfiguration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_configuration") + @ExcludeMissing + fun _creditConfiguration(): JsonField = + creditConfiguration + + /** + * Returns the raw JSON value of [isForBenefitOf]. + * + * Unlike [isForBenefitOf], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_for_benefit_of") + @ExcludeMissing + fun _isForBenefitOf(): JsonField = isForBenefitOf + + /** + * Returns the raw JSON value of [nickname]. + * + * Unlike [nickname], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("nickname") @ExcludeMissing fun _nickname(): JsonField = nickname + + /** + * 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 [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 [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [accountNumber]. + * + * Unlike [accountNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber + + /** + * Returns the raw JSON value of [routingNumber]. + * + * Unlike [routingNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber + + /** + * Returns the raw JSON value of [substatus]. + * + * Unlike [substatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("substatus") + @ExcludeMissing + fun _substatus(): JsonField = substatus + + /** + * 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 + * [FinancialAccountUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .created() + * .creditConfiguration() + * .isForBenefitOf() + * .nickname() + * .status() + * .type() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FinancialAccountUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountToken: JsonField? = null + private var created: JsonField? = null + private var creditConfiguration: JsonField? = + null + private var isForBenefitOf: JsonField? = null + private var nickname: JsonField? = null + private var status: JsonField? = null + private var type: JsonField? = null + private var updated: JsonField? = null + private var accountNumber: JsonField = JsonMissing.of() + private var routingNumber: JsonField = JsonMissing.of() + private var substatus: JsonField = + JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + financialAccountUpdatedWebhookEvent: FinancialAccountUpdatedWebhookEvent + ) = apply { + token = financialAccountUpdatedWebhookEvent.token + accountToken = financialAccountUpdatedWebhookEvent.accountToken + created = financialAccountUpdatedWebhookEvent.created + creditConfiguration = financialAccountUpdatedWebhookEvent.creditConfiguration + isForBenefitOf = financialAccountUpdatedWebhookEvent.isForBenefitOf + nickname = financialAccountUpdatedWebhookEvent.nickname + status = financialAccountUpdatedWebhookEvent.status + type = financialAccountUpdatedWebhookEvent.type + updated = financialAccountUpdatedWebhookEvent.updated + accountNumber = financialAccountUpdatedWebhookEvent.accountNumber + routingNumber = financialAccountUpdatedWebhookEvent.routingNumber + substatus = financialAccountUpdatedWebhookEvent.substatus + eventType = financialAccountUpdatedWebhookEvent.eventType + additionalProperties = + financialAccountUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the account */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun accountToken(accountToken: String?) = accountToken(JsonField.ofNullable(accountToken)) + + /** Alias for calling [Builder.accountToken] with `accountToken.orElse(null)`. */ + fun accountToken(accountToken: Optional) = accountToken(accountToken.getOrNull()) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun creditConfiguration( + creditConfiguration: FinancialAccount.FinancialAccountCreditConfig? + ) = creditConfiguration(JsonField.ofNullable(creditConfiguration)) + + /** + * Alias for calling [Builder.creditConfiguration] with `creditConfiguration.orElse(null)`. + */ + fun creditConfiguration( + creditConfiguration: Optional + ) = creditConfiguration(creditConfiguration.getOrNull()) + + /** + * Sets [Builder.creditConfiguration] to an arbitrary JSON value. + * + * You should usually call [Builder.creditConfiguration] with a well-typed + * [FinancialAccount.FinancialAccountCreditConfig] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun creditConfiguration( + creditConfiguration: JsonField + ) = apply { this.creditConfiguration = creditConfiguration } + + /** Whether financial account is for the benefit of another entity */ + fun isForBenefitOf(isForBenefitOf: Boolean) = isForBenefitOf(JsonField.of(isForBenefitOf)) + + /** + * Sets [Builder.isForBenefitOf] to an arbitrary JSON value. + * + * You should usually call [Builder.isForBenefitOf] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isForBenefitOf(isForBenefitOf: JsonField) = apply { + this.isForBenefitOf = isForBenefitOf + } + + fun nickname(nickname: String?) = nickname(JsonField.ofNullable(nickname)) + + /** Alias for calling [Builder.nickname] with `nickname.orElse(null)`. */ + fun nickname(nickname: Optional) = nickname(nickname.getOrNull()) + + /** + * Sets [Builder.nickname] to an arbitrary JSON value. + * + * You should usually call [Builder.nickname] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nickname(nickname: JsonField) = apply { this.nickname = nickname } + + /** Status of the financial account */ + fun status(status: FinancialAccount.FinancialAccountStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [FinancialAccount.FinancialAccountStatus] 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 type(type: FinancialAccount.Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [FinancialAccount.Type] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun accountNumber(accountNumber: String?) = + accountNumber(JsonField.ofNullable(accountNumber)) + + /** Alias for calling [Builder.accountNumber] with `accountNumber.orElse(null)`. */ + fun accountNumber(accountNumber: Optional) = + accountNumber(accountNumber.getOrNull()) + + /** + * Sets [Builder.accountNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.accountNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } + + fun routingNumber(routingNumber: String?) = + routingNumber(JsonField.ofNullable(routingNumber)) + + /** Alias for calling [Builder.routingNumber] with `routingNumber.orElse(null)`. */ + fun routingNumber(routingNumber: Optional) = + routingNumber(routingNumber.getOrNull()) + + /** + * Sets [Builder.routingNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.routingNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } + + /** Substatus for the financial account */ + fun substatus(substatus: FinancialAccount.FinancialAccountSubstatus?) = + substatus(JsonField.ofNullable(substatus)) + + /** Alias for calling [Builder.substatus] with `substatus.orElse(null)`. */ + fun substatus(substatus: Optional) = + substatus(substatus.getOrNull()) + + /** + * Sets [Builder.substatus] to an arbitrary JSON value. + * + * You should usually call [Builder.substatus] with a well-typed + * [FinancialAccount.FinancialAccountSubstatus] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun substatus(substatus: JsonField) = apply { + this.substatus = substatus + } + + /** 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 [FinancialAccountUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountToken() + * .created() + * .creditConfiguration() + * .isForBenefitOf() + * .nickname() + * .status() + * .type() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FinancialAccountUpdatedWebhookEvent = + FinancialAccountUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountToken", accountToken), + checkRequired("created", created), + checkRequired("creditConfiguration", creditConfiguration), + checkRequired("isForBenefitOf", isForBenefitOf), + checkRequired("nickname", nickname), + checkRequired("status", status), + checkRequired("type", type), + checkRequired("updated", updated), + accountNumber, + routingNumber, + substatus, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FinancialAccountUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountToken() + created() + creditConfiguration().ifPresent { it.validate() } + isForBenefitOf() + nickname() + status().validate() + type().validate() + updated() + accountNumber() + routingNumber() + substatus().ifPresent { it.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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (creditConfiguration.asKnown().getOrNull()?.validity() ?: 0) + + (if (isForBenefitOf.asKnown().isPresent) 1 else 0) + + (if (nickname.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (accountNumber.asKnown().isPresent) 1 else 0) + + (if (routingNumber.asKnown().isPresent) 1 else 0) + + (substatus.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 FINANCIAL_ACCOUNT_UPDATED = of("financial_account.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + FINANCIAL_ACCOUNT_UPDATED + } + + /** + * 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 { + FINANCIAL_ACCOUNT_UPDATED, + /** + * 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) { + FINANCIAL_ACCOUNT_UPDATED -> Value.FINANCIAL_ACCOUNT_UPDATED + 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) { + FINANCIAL_ACCOUNT_UPDATED -> Known.FINANCIAL_ACCOUNT_UPDATED + 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 + + 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 FinancialAccountUpdatedWebhookEvent && + token == other.token && + accountToken == other.accountToken && + created == other.created && + creditConfiguration == other.creditConfiguration && + isForBenefitOf == other.isForBenefitOf && + nickname == other.nickname && + status == other.status && + type == other.type && + updated == other.updated && + accountNumber == other.accountNumber && + routingNumber == other.routingNumber && + substatus == other.substatus && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountToken, + created, + creditConfiguration, + isForBenefitOf, + nickname, + status, + type, + updated, + accountNumber, + routingNumber, + substatus, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FinancialAccountUpdatedWebhookEvent{token=$token, accountToken=$accountToken, created=$created, creditConfiguration=$creditConfiguration, isForBenefitOf=$isForBenefitOf, nickname=$nickname, status=$status, type=$type, updated=$updated, accountNumber=$accountNumber, routingNumber=$routingNumber, substatus=$substatus, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventCreatedWebhookEvent.kt new file mode 100644 index 000000000..0331c096e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FundingEventCreatedWebhookEvent.kt @@ -0,0 +1,730 @@ +// 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 kotlin.jvm.optionals.getOrNull + +class FundingEventCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val collectionResourceType: JsonField, + private val collectionTokens: JsonField>, + private val created: JsonField, + private val highWatermark: JsonField, + private val networkSettlementSummary: JsonField>, + private val previousHighWatermark: JsonField, + private val updated: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("collection_resource_type") + @ExcludeMissing + collectionResourceType: JsonField = JsonMissing.of(), + @JsonProperty("collection_tokens") + @ExcludeMissing + collectionTokens: JsonField> = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("high_watermark") + @ExcludeMissing + highWatermark: JsonField = JsonMissing.of(), + @JsonProperty("network_settlement_summary") + @ExcludeMissing + networkSettlementSummary: JsonField> = + JsonMissing.of(), + @JsonProperty("previous_high_watermark") + @ExcludeMissing + previousHighWatermark: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + collectionResourceType, + collectionTokens, + created, + highWatermark, + networkSettlementSummary, + previousHighWatermark, + updated, + eventType, + mutableMapOf(), + ) + + fun toFundingEvent(): FundingEvent = + FundingEvent.builder() + .token(token) + .collectionResourceType(collectionResourceType) + .collectionTokens(collectionTokens) + .created(created) + .highWatermark(highWatermark) + .networkSettlementSummary(networkSettlementSummary) + .previousHighWatermark(previousHighWatermark) + .updated(updated) + .build() + + /** + * Unique token ID + * + * @throws LithicInvalidDataException if 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") + + /** + * Collection resource 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 collectionResourceType(): FundingEvent.CollectionResourceType = + collectionResourceType.getRequired("collection_resource_type") + + /** + * IDs of collections, further information can be gathered from the appropriate collection API + * based on collection_resource_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 collectionTokens(): List = collectionTokens.getRequired("collection_tokens") + + /** + * Time of the creation + * + * @throws LithicInvalidDataException if 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") + + /** + * Time of the high watermark + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun highWatermark(): OffsetDateTime = highWatermark.getRequired("high_watermark") + + /** + * Network settlement summary breakdown by network settlement date + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun networkSettlementSummary(): List = + networkSettlementSummary.getRequired("network_settlement_summary") + + /** + * Time of the previous high watermark + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun previousHighWatermark(): OffsetDateTime = + previousHighWatermark.getRequired("previous_high_watermark") + + /** + * Time of the update + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * 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 [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 [collectionResourceType]. + * + * Unlike [collectionResourceType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("collection_resource_type") + @ExcludeMissing + fun _collectionResourceType(): JsonField = + collectionResourceType + + /** + * Returns the raw JSON value of [collectionTokens]. + * + * Unlike [collectionTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("collection_tokens") + @ExcludeMissing + fun _collectionTokens(): JsonField> = collectionTokens + + /** + * 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 [highWatermark]. + * + * Unlike [highWatermark], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("high_watermark") + @ExcludeMissing + fun _highWatermark(): JsonField = highWatermark + + /** + * Returns the raw JSON value of [networkSettlementSummary]. + * + * Unlike [networkSettlementSummary], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("network_settlement_summary") + @ExcludeMissing + fun _networkSettlementSummary(): JsonField> = + networkSettlementSummary + + /** + * Returns the raw JSON value of [previousHighWatermark]. + * + * Unlike [previousHighWatermark], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("previous_high_watermark") + @ExcludeMissing + fun _previousHighWatermark(): JsonField = previousHighWatermark + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [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 + * [FundingEventCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .collectionResourceType() + * .collectionTokens() + * .created() + * .highWatermark() + * .networkSettlementSummary() + * .previousHighWatermark() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FundingEventCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var collectionResourceType: JsonField? = null + private var collectionTokens: JsonField>? = null + private var created: JsonField? = null + private var highWatermark: JsonField? = null + private var networkSettlementSummary: + JsonField>? = + null + private var previousHighWatermark: JsonField? = null + private var updated: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fundingEventCreatedWebhookEvent: FundingEventCreatedWebhookEvent) = + apply { + token = fundingEventCreatedWebhookEvent.token + collectionResourceType = fundingEventCreatedWebhookEvent.collectionResourceType + collectionTokens = + fundingEventCreatedWebhookEvent.collectionTokens.map { it.toMutableList() } + created = fundingEventCreatedWebhookEvent.created + highWatermark = fundingEventCreatedWebhookEvent.highWatermark + networkSettlementSummary = + fundingEventCreatedWebhookEvent.networkSettlementSummary.map { + it.toMutableList() + } + previousHighWatermark = fundingEventCreatedWebhookEvent.previousHighWatermark + updated = fundingEventCreatedWebhookEvent.updated + eventType = fundingEventCreatedWebhookEvent.eventType + additionalProperties = + fundingEventCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique token ID */ + 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 } + + /** Collection resource type */ + fun collectionResourceType(collectionResourceType: FundingEvent.CollectionResourceType) = + collectionResourceType(JsonField.of(collectionResourceType)) + + /** + * Sets [Builder.collectionResourceType] to an arbitrary JSON value. + * + * You should usually call [Builder.collectionResourceType] with a well-typed + * [FundingEvent.CollectionResourceType] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun collectionResourceType( + collectionResourceType: JsonField + ) = apply { this.collectionResourceType = collectionResourceType } + + /** + * IDs of collections, further information can be gathered from the appropriate collection + * API based on collection_resource_type + */ + fun collectionTokens(collectionTokens: List) = + collectionTokens(JsonField.of(collectionTokens)) + + /** + * Sets [Builder.collectionTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.collectionTokens] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun collectionTokens(collectionTokens: JsonField>) = apply { + this.collectionTokens = collectionTokens.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [collectionTokens]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCollectionToken(collectionToken: String) = apply { + collectionTokens = + (collectionTokens ?: JsonField.of(mutableListOf())).also { + checkKnown("collectionTokens", it).add(collectionToken) + } + } + + /** Time of the creation */ + 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 } + + /** Time of the high watermark */ + fun highWatermark(highWatermark: OffsetDateTime) = + highWatermark(JsonField.of(highWatermark)) + + /** + * Sets [Builder.highWatermark] to an arbitrary JSON value. + * + * You should usually call [Builder.highWatermark] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun highWatermark(highWatermark: JsonField) = apply { + this.highWatermark = highWatermark + } + + /** Network settlement summary breakdown by network settlement date */ + fun networkSettlementSummary( + networkSettlementSummary: List + ) = networkSettlementSummary(JsonField.of(networkSettlementSummary)) + + /** + * Sets [Builder.networkSettlementSummary] to an arbitrary JSON value. + * + * You should usually call [Builder.networkSettlementSummary] with a well-typed + * `List` value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun networkSettlementSummary( + networkSettlementSummary: JsonField> + ) = apply { + this.networkSettlementSummary = networkSettlementSummary.map { it.toMutableList() } + } + + /** + * Adds a single [FundingEvent.FundingEventSettlement] to + * [Builder.networkSettlementSummary]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNetworkSettlementSummary( + networkSettlementSummary: FundingEvent.FundingEventSettlement + ) = apply { + this.networkSettlementSummary = + (this.networkSettlementSummary ?: JsonField.of(mutableListOf())).also { + checkKnown("networkSettlementSummary", it).add(networkSettlementSummary) + } + } + + /** Time of the previous high watermark */ + fun previousHighWatermark(previousHighWatermark: OffsetDateTime) = + previousHighWatermark(JsonField.of(previousHighWatermark)) + + /** + * Sets [Builder.previousHighWatermark] to an arbitrary JSON value. + * + * You should usually call [Builder.previousHighWatermark] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun previousHighWatermark(previousHighWatermark: JsonField) = apply { + this.previousHighWatermark = previousHighWatermark + } + + /** Time of the update */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** 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 [FundingEventCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .collectionResourceType() + * .collectionTokens() + * .created() + * .highWatermark() + * .networkSettlementSummary() + * .previousHighWatermark() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FundingEventCreatedWebhookEvent = + FundingEventCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("collectionResourceType", collectionResourceType), + checkRequired("collectionTokens", collectionTokens).map { it.toImmutable() }, + checkRequired("created", created), + checkRequired("highWatermark", highWatermark), + checkRequired("networkSettlementSummary", networkSettlementSummary).map { + it.toImmutable() + }, + checkRequired("previousHighWatermark", previousHighWatermark), + checkRequired("updated", updated), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FundingEventCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + collectionResourceType().validate() + collectionTokens() + created() + highWatermark() + networkSettlementSummary().forEach { it.validate() } + previousHighWatermark() + updated() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (collectionResourceType.asKnown().getOrNull()?.validity() ?: 0) + + (collectionTokens.asKnown().getOrNull()?.size ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (highWatermark.asKnown().isPresent) 1 else 0) + + (networkSettlementSummary.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (previousHighWatermark.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 FUNDING_EVENT_CREATED = of("funding_event.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + FUNDING_EVENT_CREATED + } + + /** + * 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 { + FUNDING_EVENT_CREATED, + /** + * 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) { + FUNDING_EVENT_CREATED -> Value.FUNDING_EVENT_CREATED + 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) { + FUNDING_EVENT_CREATED -> Known.FUNDING_EVENT_CREATED + 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 + + 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 FundingEventCreatedWebhookEvent && + token == other.token && + collectionResourceType == other.collectionResourceType && + collectionTokens == other.collectionTokens && + created == other.created && + highWatermark == other.highWatermark && + networkSettlementSummary == other.networkSettlementSummary && + previousHighWatermark == other.previousHighWatermark && + updated == other.updated && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + collectionResourceType, + collectionTokens, + created, + highWatermark, + networkSettlementSummary, + previousHighWatermark, + updated, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FundingEventCreatedWebhookEvent{token=$token, collectionResourceType=$collectionResourceType, collectionTokens=$collectionTokens, created=$created, highWatermark=$highWatermark, networkSettlementSummary=$networkSettlementSummary, previousHighWatermark=$previousHighWatermark, updated=$updated, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransactionCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransactionCreatedWebhookEvent.kt new file mode 100644 index 000000000..cac7d5a25 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransactionCreatedWebhookEvent.kt @@ -0,0 +1,782 @@ +// 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 kotlin.jvm.optionals.getOrNull + +class InternalTransactionCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val descriptor: JsonField, + private val events: JsonField>, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + descriptor, + events, + pendingAmount, + result, + settledAmount, + status, + updated, + eventType, + mutableMapOf(), + ) + + fun toInternalTransaction(): InternalTransaction = + InternalTransaction.builder() + .token(token) + .category(category) + .created(created) + .currency(currency) + .descriptor(descriptor) + .events(events) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .status(status) + .updated(updated) + .build() + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): InternalTransaction.Category = category.getRequired("category") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun 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 currency(): String = currency.getRequired("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 descriptor(): String = descriptor.getRequired("descriptor") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): InternalTransaction.TransactionResult = result.getRequired("result") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settledAmount(): Long = settledAmount.getRequired("settled_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 status(): InternalTransaction.TransactionStatus = status.getRequired("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * 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 + * [InternalTransactionCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalTransactionCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var events: JsonField>? = + null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + internalTransactionCreatedWebhookEvent: InternalTransactionCreatedWebhookEvent + ) = apply { + token = internalTransactionCreatedWebhookEvent.token + category = internalTransactionCreatedWebhookEvent.category + created = internalTransactionCreatedWebhookEvent.created + currency = internalTransactionCreatedWebhookEvent.currency + descriptor = internalTransactionCreatedWebhookEvent.descriptor + events = internalTransactionCreatedWebhookEvent.events.map { it.toMutableList() } + pendingAmount = internalTransactionCreatedWebhookEvent.pendingAmount + result = internalTransactionCreatedWebhookEvent.result + settledAmount = internalTransactionCreatedWebhookEvent.settledAmount + status = internalTransactionCreatedWebhookEvent.status + updated = internalTransactionCreatedWebhookEvent.updated + eventType = internalTransactionCreatedWebhookEvent.eventType + additionalProperties = + internalTransactionCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun category(category: InternalTransaction.Category) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [InternalTransaction.Category] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun category(category: JsonField) = apply { + this.category = category + } + + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun 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 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 } + + fun events(events: List) = + events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [InternalTransaction.InternalAdjustmentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: InternalTransaction.InternalAdjustmentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: InternalTransaction.TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [InternalTransaction.TransactionResult] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + fun status(status: InternalTransaction.TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [InternalTransaction.TransactionStatus] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** 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 [InternalTransactionCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalTransactionCreatedWebhookEvent = + InternalTransactionCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("descriptor", descriptor), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("updated", updated), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InternalTransactionCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + descriptor() + events().forEach { it.validate() } + pendingAmount() + result().validate() + settledAmount() + status().validate() + updated() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 INTERNAL_TRANSACTION_CREATED = of("internal_transaction.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + INTERNAL_TRANSACTION_CREATED + } + + /** + * 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 { + INTERNAL_TRANSACTION_CREATED, + /** + * 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) { + INTERNAL_TRANSACTION_CREATED -> Value.INTERNAL_TRANSACTION_CREATED + 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) { + INTERNAL_TRANSACTION_CREATED -> Known.INTERNAL_TRANSACTION_CREATED + 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 + + 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 InternalTransactionCreatedWebhookEvent && + token == other.token && + category == other.category && + created == other.created && + currency == other.currency && + descriptor == other.descriptor && + events == other.events && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + status == other.status && + updated == other.updated && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + currency, + descriptor, + events, + pendingAmount, + result, + settledAmount, + status, + updated, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InternalTransactionCreatedWebhookEvent{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, events=$events, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, updated=$updated, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransactionUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransactionUpdatedWebhookEvent.kt new file mode 100644 index 000000000..157addcf1 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/InternalTransactionUpdatedWebhookEvent.kt @@ -0,0 +1,782 @@ +// 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 kotlin.jvm.optionals.getOrNull + +class InternalTransactionUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val descriptor: JsonField, + private val events: JsonField>, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + currency, + descriptor, + events, + pendingAmount, + result, + settledAmount, + status, + updated, + eventType, + mutableMapOf(), + ) + + fun toInternalTransaction(): InternalTransaction = + InternalTransaction.builder() + .token(token) + .category(category) + .created(created) + .currency(currency) + .descriptor(descriptor) + .events(events) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .status(status) + .updated(updated) + .build() + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): InternalTransaction.Category = category.getRequired("category") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun 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 currency(): String = currency.getRequired("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 descriptor(): String = descriptor.getRequired("descriptor") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): InternalTransaction.TransactionResult = result.getRequired("result") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settledAmount(): Long = settledAmount.getRequired("settled_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 status(): InternalTransaction.TransactionStatus = status.getRequired("status") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * 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 + * [InternalTransactionUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalTransactionUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var descriptor: JsonField? = null + private var events: JsonField>? = + null + private var pendingAmount: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + internalTransactionUpdatedWebhookEvent: InternalTransactionUpdatedWebhookEvent + ) = apply { + token = internalTransactionUpdatedWebhookEvent.token + category = internalTransactionUpdatedWebhookEvent.category + created = internalTransactionUpdatedWebhookEvent.created + currency = internalTransactionUpdatedWebhookEvent.currency + descriptor = internalTransactionUpdatedWebhookEvent.descriptor + events = internalTransactionUpdatedWebhookEvent.events.map { it.toMutableList() } + pendingAmount = internalTransactionUpdatedWebhookEvent.pendingAmount + result = internalTransactionUpdatedWebhookEvent.result + settledAmount = internalTransactionUpdatedWebhookEvent.settledAmount + status = internalTransactionUpdatedWebhookEvent.status + updated = internalTransactionUpdatedWebhookEvent.updated + eventType = internalTransactionUpdatedWebhookEvent.eventType + additionalProperties = + internalTransactionUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun category(category: InternalTransaction.Category) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [InternalTransaction.Category] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun category(category: JsonField) = apply { + this.category = category + } + + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun 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 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 } + + fun events(events: List) = + events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [InternalTransaction.InternalAdjustmentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: InternalTransaction.InternalAdjustmentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: InternalTransaction.TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [InternalTransaction.TransactionResult] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + fun status(status: InternalTransaction.TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [InternalTransaction.TransactionStatus] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** 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 [InternalTransactionUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .currency() + * .descriptor() + * .events() + * .pendingAmount() + * .result() + * .settledAmount() + * .status() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalTransactionUpdatedWebhookEvent = + InternalTransactionUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("descriptor", descriptor), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("pendingAmount", pendingAmount), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("status", status), + checkRequired("updated", updated), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InternalTransactionUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + currency() + descriptor() + events().forEach { it.validate() } + pendingAmount() + result().validate() + settledAmount() + status().validate() + updated() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 INTERNAL_TRANSACTION_UPDATED = of("internal_transaction.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + INTERNAL_TRANSACTION_UPDATED + } + + /** + * 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 { + INTERNAL_TRANSACTION_UPDATED, + /** + * 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) { + INTERNAL_TRANSACTION_UPDATED -> Value.INTERNAL_TRANSACTION_UPDATED + 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) { + INTERNAL_TRANSACTION_UPDATED -> Known.INTERNAL_TRANSACTION_UPDATED + 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 + + 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 InternalTransactionUpdatedWebhookEvent && + token == other.token && + category == other.category && + created == other.created && + currency == other.currency && + descriptor == other.descriptor && + events == other.events && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + status == other.status && + updated == other.updated && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + currency, + descriptor, + events, + pendingAmount, + result, + settledAmount, + status, + updated, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InternalTransactionUpdatedWebhookEvent{token=$token, category=$category, created=$created, currency=$currency, descriptor=$descriptor, events=$events, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, status=$status, updated=$updated, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/LoanTapeCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/LoanTapeCreatedWebhookEvent.kt new file mode 100644 index 000000000..935f2ef48 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/LoanTapeCreatedWebhookEvent.kt @@ -0,0 +1,1290 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LoanTapeCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountStanding: JsonField, + private val availableCredit: JsonField, + private val balances: JsonField, + private val created: JsonField, + private val creditLimit: JsonField, + private val creditProductToken: JsonField, + private val date: JsonField, + private val dayTotals: JsonField, + private val endingBalance: JsonField, + private val excessCredits: JsonField, + private val financialAccountToken: JsonField, + private val interestDetails: JsonField, + private val minimumPaymentBalance: JsonField, + private val paymentAllocation: JsonField, + private val periodTotals: JsonField, + private val previousStatementBalance: JsonField, + private val startingBalance: JsonField, + private val updated: JsonField, + private val version: JsonField, + private val ytdTotals: JsonField, + private val tier: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_standing") + @ExcludeMissing + accountStanding: JsonField = JsonMissing.of(), + @JsonProperty("available_credit") + @ExcludeMissing + availableCredit: JsonField = JsonMissing.of(), + @JsonProperty("balances") + @ExcludeMissing + balances: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("credit_limit") + @ExcludeMissing + creditLimit: JsonField = JsonMissing.of(), + @JsonProperty("credit_product_token") + @ExcludeMissing + creditProductToken: JsonField = JsonMissing.of(), + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("day_totals") + @ExcludeMissing + dayTotals: JsonField = JsonMissing.of(), + @JsonProperty("ending_balance") + @ExcludeMissing + endingBalance: JsonField = JsonMissing.of(), + @JsonProperty("excess_credits") + @ExcludeMissing + excessCredits: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("interest_details") + @ExcludeMissing + interestDetails: JsonField = JsonMissing.of(), + @JsonProperty("minimum_payment_balance") + @ExcludeMissing + minimumPaymentBalance: JsonField = JsonMissing.of(), + @JsonProperty("payment_allocation") + @ExcludeMissing + paymentAllocation: JsonField = JsonMissing.of(), + @JsonProperty("period_totals") + @ExcludeMissing + periodTotals: JsonField = JsonMissing.of(), + @JsonProperty("previous_statement_balance") + @ExcludeMissing + previousStatementBalance: JsonField = JsonMissing.of(), + @JsonProperty("starting_balance") + @ExcludeMissing + startingBalance: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("ytd_totals") + @ExcludeMissing + ytdTotals: JsonField = JsonMissing.of(), + @JsonProperty("tier") @ExcludeMissing tier: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountStanding, + availableCredit, + balances, + created, + creditLimit, + creditProductToken, + date, + dayTotals, + endingBalance, + excessCredits, + financialAccountToken, + interestDetails, + minimumPaymentBalance, + paymentAllocation, + periodTotals, + previousStatementBalance, + startingBalance, + updated, + version, + ytdTotals, + tier, + eventType, + mutableMapOf(), + ) + + fun toLoanTape(): LoanTape = + LoanTape.builder() + .token(token) + .accountStanding(accountStanding) + .availableCredit(availableCredit) + .balances(balances) + .created(created) + .creditLimit(creditLimit) + .creditProductToken(creditProductToken) + .date(date) + .dayTotals(dayTotals) + .endingBalance(endingBalance) + .excessCredits(excessCredits) + .financialAccountToken(financialAccountToken) + .interestDetails(interestDetails) + .minimumPaymentBalance(minimumPaymentBalance) + .paymentAllocation(paymentAllocation) + .periodTotals(periodTotals) + .previousStatementBalance(previousStatementBalance) + .startingBalance(startingBalance) + .updated(updated) + .version(version) + .ytdTotals(ytdTotals) + .tier(tier) + .build() + + /** + * Globally unique identifier for a loan tape + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountStanding(): LoanTape.AccountStanding = + accountStanding.getRequired("account_standing") + + /** + * Amount of credit available to spend in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun availableCredit(): Long = availableCredit.getRequired("available_credit") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun balances(): LoanTape.Balances = balances.getRequired("balances") + + /** + * Timestamp of when the loan tape was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * For prepay accounts, this is the minimum prepay balance that must be maintained. For charge + * card accounts, this is the maximum credit balance extended by a lender + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditLimit(): Long = creditLimit.getRequired("credit_limit") + + /** + * Globally unique identifier for a credit product + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditProductToken(): String = creditProductToken.getRequired("credit_product_token") + + /** + * Date of transactions that this loan tape covers + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun date(): LocalDate = date.getRequired("date") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dayTotals(): StatementTotals = dayTotals.getRequired("day_totals") + + /** + * Balance at the end of the day + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endingBalance(): Long = endingBalance.getRequired("ending_balance") + + /** + * Excess credits in the form of provisional credits, payments, or purchase refunds. If + * positive, the account is in net credit state with no outstanding balances. An overpayment + * could land an account in this 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 excessCredits(): Long = excessCredits.getRequired("excess_credits") + + /** + * Globally unique identifier for a financial account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun interestDetails(): Optional = + interestDetails.getOptional("interest_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 minimumPaymentBalance(): LoanTape.BalanceDetails = + minimumPaymentBalance.getRequired("minimum_payment_balance") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paymentAllocation(): CategoryBalances = paymentAllocation.getRequired("payment_allocation") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun periodTotals(): StatementTotals = periodTotals.getRequired("period_totals") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun previousStatementBalance(): LoanTape.BalanceDetails = + previousStatementBalance.getRequired("previous_statement_balance") + + /** + * Balance at the start of the day + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingBalance(): Long = startingBalance.getRequired("starting_balance") + + /** + * Timestamp of when the loan tape was updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Version number of the loan tape. This starts at 1 + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun ytdTotals(): StatementTotals = ytdTotals.getRequired("ytd_totals") + + /** + * Interest tier to which this account belongs to + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tier(): Optional = tier.getOptional("tier") + + /** + * 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 [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 [accountStanding]. + * + * Unlike [accountStanding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_standing") + @ExcludeMissing + fun _accountStanding(): JsonField = accountStanding + + /** + * Returns the raw JSON value of [availableCredit]. + * + * Unlike [availableCredit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("available_credit") + @ExcludeMissing + fun _availableCredit(): JsonField = availableCredit + + /** + * Returns the raw JSON value of [balances]. + * + * Unlike [balances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("balances") + @ExcludeMissing + fun _balances(): JsonField = balances + + /** + * 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 [creditLimit]. + * + * Unlike [creditLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit(): JsonField = creditLimit + + /** + * Returns the raw JSON value of [creditProductToken]. + * + * Unlike [creditProductToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_product_token") + @ExcludeMissing + fun _creditProductToken(): JsonField = creditProductToken + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * Returns the raw JSON value of [dayTotals]. + * + * Unlike [dayTotals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("day_totals") + @ExcludeMissing + fun _dayTotals(): JsonField = dayTotals + + /** + * Returns the raw JSON value of [endingBalance]. + * + * Unlike [endingBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance + + /** + * Returns the raw JSON value of [excessCredits]. + * + * Unlike [excessCredits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("excess_credits") + @ExcludeMissing + fun _excessCredits(): JsonField = excessCredits + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [interestDetails]. + * + * Unlike [interestDetails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("interest_details") + @ExcludeMissing + fun _interestDetails(): JsonField = interestDetails + + /** + * Returns the raw JSON value of [minimumPaymentBalance]. + * + * Unlike [minimumPaymentBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_payment_balance") + @ExcludeMissing + fun _minimumPaymentBalance(): JsonField = minimumPaymentBalance + + /** + * Returns the raw JSON value of [paymentAllocation]. + * + * Unlike [paymentAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_allocation") + @ExcludeMissing + fun _paymentAllocation(): JsonField = paymentAllocation + + /** + * Returns the raw JSON value of [periodTotals]. + * + * Unlike [periodTotals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("period_totals") + @ExcludeMissing + fun _periodTotals(): JsonField = periodTotals + + /** + * Returns the raw JSON value of [previousStatementBalance]. + * + * Unlike [previousStatementBalance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previous_statement_balance") + @ExcludeMissing + fun _previousStatementBalance(): JsonField = previousStatementBalance + + /** + * Returns the raw JSON value of [startingBalance]. + * + * Unlike [startingBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [ytdTotals]. + * + * Unlike [ytdTotals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ytd_totals") + @ExcludeMissing + fun _ytdTotals(): JsonField = ytdTotals + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier + + /** + * 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 [LoanTapeCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountStanding() + * .availableCredit() + * .balances() + * .created() + * .creditLimit() + * .creditProductToken() + * .date() + * .dayTotals() + * .endingBalance() + * .excessCredits() + * .financialAccountToken() + * .interestDetails() + * .minimumPaymentBalance() + * .paymentAllocation() + * .periodTotals() + * .previousStatementBalance() + * .startingBalance() + * .updated() + * .version() + * .ytdTotals() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LoanTapeCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountStanding: JsonField? = null + private var availableCredit: JsonField? = null + private var balances: JsonField? = null + private var created: JsonField? = null + private var creditLimit: JsonField? = null + private var creditProductToken: JsonField? = null + private var date: JsonField? = null + private var dayTotals: JsonField? = null + private var endingBalance: JsonField? = null + private var excessCredits: JsonField? = null + private var financialAccountToken: JsonField? = null + private var interestDetails: JsonField? = null + private var minimumPaymentBalance: JsonField? = null + private var paymentAllocation: JsonField? = null + private var periodTotals: JsonField? = null + private var previousStatementBalance: JsonField? = null + private var startingBalance: JsonField? = null + private var updated: JsonField? = null + private var version: JsonField? = null + private var ytdTotals: JsonField? = null + private var tier: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(loanTapeCreatedWebhookEvent: LoanTapeCreatedWebhookEvent) = apply { + token = loanTapeCreatedWebhookEvent.token + accountStanding = loanTapeCreatedWebhookEvent.accountStanding + availableCredit = loanTapeCreatedWebhookEvent.availableCredit + balances = loanTapeCreatedWebhookEvent.balances + created = loanTapeCreatedWebhookEvent.created + creditLimit = loanTapeCreatedWebhookEvent.creditLimit + creditProductToken = loanTapeCreatedWebhookEvent.creditProductToken + date = loanTapeCreatedWebhookEvent.date + dayTotals = loanTapeCreatedWebhookEvent.dayTotals + endingBalance = loanTapeCreatedWebhookEvent.endingBalance + excessCredits = loanTapeCreatedWebhookEvent.excessCredits + financialAccountToken = loanTapeCreatedWebhookEvent.financialAccountToken + interestDetails = loanTapeCreatedWebhookEvent.interestDetails + minimumPaymentBalance = loanTapeCreatedWebhookEvent.minimumPaymentBalance + paymentAllocation = loanTapeCreatedWebhookEvent.paymentAllocation + periodTotals = loanTapeCreatedWebhookEvent.periodTotals + previousStatementBalance = loanTapeCreatedWebhookEvent.previousStatementBalance + startingBalance = loanTapeCreatedWebhookEvent.startingBalance + updated = loanTapeCreatedWebhookEvent.updated + version = loanTapeCreatedWebhookEvent.version + ytdTotals = loanTapeCreatedWebhookEvent.ytdTotals + tier = loanTapeCreatedWebhookEvent.tier + eventType = loanTapeCreatedWebhookEvent.eventType + additionalProperties = loanTapeCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for a loan tape */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun accountStanding(accountStanding: LoanTape.AccountStanding) = + accountStanding(JsonField.of(accountStanding)) + + /** + * Sets [Builder.accountStanding] to an arbitrary JSON value. + * + * You should usually call [Builder.accountStanding] with a well-typed + * [LoanTape.AccountStanding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun accountStanding(accountStanding: JsonField) = apply { + this.accountStanding = accountStanding + } + + /** Amount of credit available to spend in cents */ + fun availableCredit(availableCredit: Long) = availableCredit(JsonField.of(availableCredit)) + + /** + * Sets [Builder.availableCredit] to an arbitrary JSON value. + * + * You should usually call [Builder.availableCredit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun availableCredit(availableCredit: JsonField) = apply { + this.availableCredit = availableCredit + } + + fun balances(balances: LoanTape.Balances) = balances(JsonField.of(balances)) + + /** + * Sets [Builder.balances] to an arbitrary JSON value. + * + * You should usually call [Builder.balances] with a well-typed [LoanTape.Balances] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun balances(balances: JsonField) = apply { this.balances = balances } + + /** Timestamp of when the loan tape was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** + * For prepay accounts, this is the minimum prepay balance that must be maintained. For + * charge card accounts, this is the maximum credit balance extended by a lender + */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** + * Sets [Builder.creditLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.creditLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** Globally unique identifier for a credit product */ + fun creditProductToken(creditProductToken: String) = + creditProductToken(JsonField.of(creditProductToken)) + + /** + * Sets [Builder.creditProductToken] to an arbitrary JSON value. + * + * You should usually call [Builder.creditProductToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditProductToken(creditProductToken: JsonField) = apply { + this.creditProductToken = creditProductToken + } + + /** Date of transactions that this loan tape covers */ + fun date(date: LocalDate) = date(JsonField.of(date)) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [LocalDate] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun date(date: JsonField) = apply { this.date = date } + + fun dayTotals(dayTotals: StatementTotals) = dayTotals(JsonField.of(dayTotals)) + + /** + * Sets [Builder.dayTotals] to an arbitrary JSON value. + * + * You should usually call [Builder.dayTotals] with a well-typed [StatementTotals] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dayTotals(dayTotals: JsonField) = apply { this.dayTotals = dayTotals } + + /** Balance at the end of the day */ + fun endingBalance(endingBalance: Long) = endingBalance(JsonField.of(endingBalance)) + + /** + * Sets [Builder.endingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endingBalance(endingBalance: JsonField) = apply { + this.endingBalance = endingBalance + } + + /** + * Excess credits in the form of provisional credits, payments, or purchase refunds. If + * positive, the account is in net credit state with no outstanding balances. An overpayment + * could land an account in this state + */ + fun excessCredits(excessCredits: Long) = excessCredits(JsonField.of(excessCredits)) + + /** + * Sets [Builder.excessCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.excessCredits] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun excessCredits(excessCredits: JsonField) = apply { + this.excessCredits = excessCredits + } + + /** Globally unique identifier for a financial account */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + fun interestDetails(interestDetails: LoanTape.InterestDetails?) = + interestDetails(JsonField.ofNullable(interestDetails)) + + /** Alias for calling [Builder.interestDetails] with `interestDetails.orElse(null)`. */ + fun interestDetails(interestDetails: Optional) = + interestDetails(interestDetails.getOrNull()) + + /** + * Sets [Builder.interestDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.interestDetails] with a well-typed + * [LoanTape.InterestDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun interestDetails(interestDetails: JsonField) = apply { + this.interestDetails = interestDetails + } + + fun minimumPaymentBalance(minimumPaymentBalance: LoanTape.BalanceDetails) = + minimumPaymentBalance(JsonField.of(minimumPaymentBalance)) + + /** + * Sets [Builder.minimumPaymentBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumPaymentBalance] with a well-typed + * [LoanTape.BalanceDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumPaymentBalance(minimumPaymentBalance: JsonField) = + apply { + this.minimumPaymentBalance = minimumPaymentBalance + } + + fun paymentAllocation(paymentAllocation: CategoryBalances) = + paymentAllocation(JsonField.of(paymentAllocation)) + + /** + * Sets [Builder.paymentAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAllocation] with a well-typed [CategoryBalances] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun paymentAllocation(paymentAllocation: JsonField) = apply { + this.paymentAllocation = paymentAllocation + } + + fun periodTotals(periodTotals: StatementTotals) = periodTotals(JsonField.of(periodTotals)) + + /** + * Sets [Builder.periodTotals] to an arbitrary JSON value. + * + * You should usually call [Builder.periodTotals] with a well-typed [StatementTotals] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun periodTotals(periodTotals: JsonField) = apply { + this.periodTotals = periodTotals + } + + fun previousStatementBalance(previousStatementBalance: LoanTape.BalanceDetails) = + previousStatementBalance(JsonField.of(previousStatementBalance)) + + /** + * Sets [Builder.previousStatementBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.previousStatementBalance] with a well-typed + * [LoanTape.BalanceDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun previousStatementBalance(previousStatementBalance: JsonField) = + apply { + this.previousStatementBalance = previousStatementBalance + } + + /** Balance at the start of the day */ + fun startingBalance(startingBalance: Long) = startingBalance(JsonField.of(startingBalance)) + + /** + * Sets [Builder.startingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.startingBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } + + /** Timestamp of when the loan tape was updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** Version number of the loan tape. This starts at 1 */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun ytdTotals(ytdTotals: StatementTotals) = ytdTotals(JsonField.of(ytdTotals)) + + /** + * Sets [Builder.ytdTotals] to an arbitrary JSON value. + * + * You should usually call [Builder.ytdTotals] with a well-typed [StatementTotals] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ytdTotals(ytdTotals: JsonField) = apply { this.ytdTotals = ytdTotals } + + /** Interest tier to which this account belongs to */ + fun tier(tier: String?) = tier(JsonField.ofNullable(tier)) + + /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ + fun tier(tier: Optional) = tier(tier.getOrNull()) + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tier(tier: JsonField) = apply { this.tier = tier } + + /** 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 [LoanTapeCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountStanding() + * .availableCredit() + * .balances() + * .created() + * .creditLimit() + * .creditProductToken() + * .date() + * .dayTotals() + * .endingBalance() + * .excessCredits() + * .financialAccountToken() + * .interestDetails() + * .minimumPaymentBalance() + * .paymentAllocation() + * .periodTotals() + * .previousStatementBalance() + * .startingBalance() + * .updated() + * .version() + * .ytdTotals() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LoanTapeCreatedWebhookEvent = + LoanTapeCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountStanding", accountStanding), + checkRequired("availableCredit", availableCredit), + checkRequired("balances", balances), + checkRequired("created", created), + checkRequired("creditLimit", creditLimit), + checkRequired("creditProductToken", creditProductToken), + checkRequired("date", date), + checkRequired("dayTotals", dayTotals), + checkRequired("endingBalance", endingBalance), + checkRequired("excessCredits", excessCredits), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("interestDetails", interestDetails), + checkRequired("minimumPaymentBalance", minimumPaymentBalance), + checkRequired("paymentAllocation", paymentAllocation), + checkRequired("periodTotals", periodTotals), + checkRequired("previousStatementBalance", previousStatementBalance), + checkRequired("startingBalance", startingBalance), + checkRequired("updated", updated), + checkRequired("version", version), + checkRequired("ytdTotals", ytdTotals), + tier, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LoanTapeCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountStanding().validate() + availableCredit() + balances().validate() + created() + creditLimit() + creditProductToken() + date() + dayTotals().validate() + endingBalance() + excessCredits() + financialAccountToken() + interestDetails().ifPresent { it.validate() } + minimumPaymentBalance().validate() + paymentAllocation().validate() + periodTotals().validate() + previousStatementBalance().validate() + startingBalance() + updated() + version() + ytdTotals().validate() + tier() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (accountStanding.asKnown().getOrNull()?.validity() ?: 0) + + (if (availableCredit.asKnown().isPresent) 1 else 0) + + (balances.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (creditLimit.asKnown().isPresent) 1 else 0) + + (if (creditProductToken.asKnown().isPresent) 1 else 0) + + (if (date.asKnown().isPresent) 1 else 0) + + (dayTotals.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (if (excessCredits.asKnown().isPresent) 1 else 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (interestDetails.asKnown().getOrNull()?.validity() ?: 0) + + (minimumPaymentBalance.asKnown().getOrNull()?.validity() ?: 0) + + (paymentAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (periodTotals.asKnown().getOrNull()?.validity() ?: 0) + + (previousStatementBalance.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (ytdTotals.asKnown().getOrNull()?.validity() ?: 0) + + (if (tier.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 LOAN_TAPE_CREATED = of("loan_tape.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + LOAN_TAPE_CREATED + } + + /** + * 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 { + LOAN_TAPE_CREATED, + /** + * 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) { + LOAN_TAPE_CREATED -> Value.LOAN_TAPE_CREATED + 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) { + LOAN_TAPE_CREATED -> Known.LOAN_TAPE_CREATED + 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 + + 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 LoanTapeCreatedWebhookEvent && + token == other.token && + accountStanding == other.accountStanding && + availableCredit == other.availableCredit && + balances == other.balances && + created == other.created && + creditLimit == other.creditLimit && + creditProductToken == other.creditProductToken && + date == other.date && + dayTotals == other.dayTotals && + endingBalance == other.endingBalance && + excessCredits == other.excessCredits && + financialAccountToken == other.financialAccountToken && + interestDetails == other.interestDetails && + minimumPaymentBalance == other.minimumPaymentBalance && + paymentAllocation == other.paymentAllocation && + periodTotals == other.periodTotals && + previousStatementBalance == other.previousStatementBalance && + startingBalance == other.startingBalance && + updated == other.updated && + version == other.version && + ytdTotals == other.ytdTotals && + tier == other.tier && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountStanding, + availableCredit, + balances, + created, + creditLimit, + creditProductToken, + date, + dayTotals, + endingBalance, + excessCredits, + financialAccountToken, + interestDetails, + minimumPaymentBalance, + paymentAllocation, + periodTotals, + previousStatementBalance, + startingBalance, + updated, + version, + ytdTotals, + tier, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LoanTapeCreatedWebhookEvent{token=$token, accountStanding=$accountStanding, availableCredit=$availableCredit, balances=$balances, created=$created, creditLimit=$creditLimit, creditProductToken=$creditProductToken, date=$date, dayTotals=$dayTotals, endingBalance=$endingBalance, excessCredits=$excessCredits, financialAccountToken=$financialAccountToken, interestDetails=$interestDetails, minimumPaymentBalance=$minimumPaymentBalance, paymentAllocation=$paymentAllocation, periodTotals=$periodTotals, previousStatementBalance=$previousStatementBalance, startingBalance=$startingBalance, updated=$updated, version=$version, ytdTotals=$ytdTotals, tier=$tier, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/LoanTapeUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/LoanTapeUpdatedWebhookEvent.kt new file mode 100644 index 000000000..ba7ac888c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/LoanTapeUpdatedWebhookEvent.kt @@ -0,0 +1,1290 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LoanTapeUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountStanding: JsonField, + private val availableCredit: JsonField, + private val balances: JsonField, + private val created: JsonField, + private val creditLimit: JsonField, + private val creditProductToken: JsonField, + private val date: JsonField, + private val dayTotals: JsonField, + private val endingBalance: JsonField, + private val excessCredits: JsonField, + private val financialAccountToken: JsonField, + private val interestDetails: JsonField, + private val minimumPaymentBalance: JsonField, + private val paymentAllocation: JsonField, + private val periodTotals: JsonField, + private val previousStatementBalance: JsonField, + private val startingBalance: JsonField, + private val updated: JsonField, + private val version: JsonField, + private val ytdTotals: JsonField, + private val tier: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_standing") + @ExcludeMissing + accountStanding: JsonField = JsonMissing.of(), + @JsonProperty("available_credit") + @ExcludeMissing + availableCredit: JsonField = JsonMissing.of(), + @JsonProperty("balances") + @ExcludeMissing + balances: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("credit_limit") + @ExcludeMissing + creditLimit: JsonField = JsonMissing.of(), + @JsonProperty("credit_product_token") + @ExcludeMissing + creditProductToken: JsonField = JsonMissing.of(), + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("day_totals") + @ExcludeMissing + dayTotals: JsonField = JsonMissing.of(), + @JsonProperty("ending_balance") + @ExcludeMissing + endingBalance: JsonField = JsonMissing.of(), + @JsonProperty("excess_credits") + @ExcludeMissing + excessCredits: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("interest_details") + @ExcludeMissing + interestDetails: JsonField = JsonMissing.of(), + @JsonProperty("minimum_payment_balance") + @ExcludeMissing + minimumPaymentBalance: JsonField = JsonMissing.of(), + @JsonProperty("payment_allocation") + @ExcludeMissing + paymentAllocation: JsonField = JsonMissing.of(), + @JsonProperty("period_totals") + @ExcludeMissing + periodTotals: JsonField = JsonMissing.of(), + @JsonProperty("previous_statement_balance") + @ExcludeMissing + previousStatementBalance: JsonField = JsonMissing.of(), + @JsonProperty("starting_balance") + @ExcludeMissing + startingBalance: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("ytd_totals") + @ExcludeMissing + ytdTotals: JsonField = JsonMissing.of(), + @JsonProperty("tier") @ExcludeMissing tier: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountStanding, + availableCredit, + balances, + created, + creditLimit, + creditProductToken, + date, + dayTotals, + endingBalance, + excessCredits, + financialAccountToken, + interestDetails, + minimumPaymentBalance, + paymentAllocation, + periodTotals, + previousStatementBalance, + startingBalance, + updated, + version, + ytdTotals, + tier, + eventType, + mutableMapOf(), + ) + + fun toLoanTape(): LoanTape = + LoanTape.builder() + .token(token) + .accountStanding(accountStanding) + .availableCredit(availableCredit) + .balances(balances) + .created(created) + .creditLimit(creditLimit) + .creditProductToken(creditProductToken) + .date(date) + .dayTotals(dayTotals) + .endingBalance(endingBalance) + .excessCredits(excessCredits) + .financialAccountToken(financialAccountToken) + .interestDetails(interestDetails) + .minimumPaymentBalance(minimumPaymentBalance) + .paymentAllocation(paymentAllocation) + .periodTotals(periodTotals) + .previousStatementBalance(previousStatementBalance) + .startingBalance(startingBalance) + .updated(updated) + .version(version) + .ytdTotals(ytdTotals) + .tier(tier) + .build() + + /** + * Globally unique identifier for a loan tape + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountStanding(): LoanTape.AccountStanding = + accountStanding.getRequired("account_standing") + + /** + * Amount of credit available to spend in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun availableCredit(): Long = availableCredit.getRequired("available_credit") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun balances(): LoanTape.Balances = balances.getRequired("balances") + + /** + * Timestamp of when the loan tape was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * For prepay accounts, this is the minimum prepay balance that must be maintained. For charge + * card accounts, this is the maximum credit balance extended by a lender + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditLimit(): Long = creditLimit.getRequired("credit_limit") + + /** + * Globally unique identifier for a credit product + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditProductToken(): String = creditProductToken.getRequired("credit_product_token") + + /** + * Date of transactions that this loan tape covers + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun date(): LocalDate = date.getRequired("date") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dayTotals(): StatementTotals = dayTotals.getRequired("day_totals") + + /** + * Balance at the end of the day + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endingBalance(): Long = endingBalance.getRequired("ending_balance") + + /** + * Excess credits in the form of provisional credits, payments, or purchase refunds. If + * positive, the account is in net credit state with no outstanding balances. An overpayment + * could land an account in this 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 excessCredits(): Long = excessCredits.getRequired("excess_credits") + + /** + * Globally unique identifier for a financial account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun interestDetails(): Optional = + interestDetails.getOptional("interest_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 minimumPaymentBalance(): LoanTape.BalanceDetails = + minimumPaymentBalance.getRequired("minimum_payment_balance") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paymentAllocation(): CategoryBalances = paymentAllocation.getRequired("payment_allocation") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun periodTotals(): StatementTotals = periodTotals.getRequired("period_totals") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun previousStatementBalance(): LoanTape.BalanceDetails = + previousStatementBalance.getRequired("previous_statement_balance") + + /** + * Balance at the start of the day + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingBalance(): Long = startingBalance.getRequired("starting_balance") + + /** + * Timestamp of when the loan tape was updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Version number of the loan tape. This starts at 1 + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): Long = version.getRequired("version") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun ytdTotals(): StatementTotals = ytdTotals.getRequired("ytd_totals") + + /** + * Interest tier to which this account belongs to + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tier(): Optional = tier.getOptional("tier") + + /** + * 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 [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 [accountStanding]. + * + * Unlike [accountStanding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_standing") + @ExcludeMissing + fun _accountStanding(): JsonField = accountStanding + + /** + * Returns the raw JSON value of [availableCredit]. + * + * Unlike [availableCredit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("available_credit") + @ExcludeMissing + fun _availableCredit(): JsonField = availableCredit + + /** + * Returns the raw JSON value of [balances]. + * + * Unlike [balances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("balances") + @ExcludeMissing + fun _balances(): JsonField = balances + + /** + * 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 [creditLimit]. + * + * Unlike [creditLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit(): JsonField = creditLimit + + /** + * Returns the raw JSON value of [creditProductToken]. + * + * Unlike [creditProductToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_product_token") + @ExcludeMissing + fun _creditProductToken(): JsonField = creditProductToken + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * Returns the raw JSON value of [dayTotals]. + * + * Unlike [dayTotals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("day_totals") + @ExcludeMissing + fun _dayTotals(): JsonField = dayTotals + + /** + * Returns the raw JSON value of [endingBalance]. + * + * Unlike [endingBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance + + /** + * Returns the raw JSON value of [excessCredits]. + * + * Unlike [excessCredits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("excess_credits") + @ExcludeMissing + fun _excessCredits(): JsonField = excessCredits + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [interestDetails]. + * + * Unlike [interestDetails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("interest_details") + @ExcludeMissing + fun _interestDetails(): JsonField = interestDetails + + /** + * Returns the raw JSON value of [minimumPaymentBalance]. + * + * Unlike [minimumPaymentBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("minimum_payment_balance") + @ExcludeMissing + fun _minimumPaymentBalance(): JsonField = minimumPaymentBalance + + /** + * Returns the raw JSON value of [paymentAllocation]. + * + * Unlike [paymentAllocation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_allocation") + @ExcludeMissing + fun _paymentAllocation(): JsonField = paymentAllocation + + /** + * Returns the raw JSON value of [periodTotals]. + * + * Unlike [periodTotals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("period_totals") + @ExcludeMissing + fun _periodTotals(): JsonField = periodTotals + + /** + * Returns the raw JSON value of [previousStatementBalance]. + * + * Unlike [previousStatementBalance], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("previous_statement_balance") + @ExcludeMissing + fun _previousStatementBalance(): JsonField = previousStatementBalance + + /** + * Returns the raw JSON value of [startingBalance]. + * + * Unlike [startingBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [ytdTotals]. + * + * Unlike [ytdTotals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ytd_totals") + @ExcludeMissing + fun _ytdTotals(): JsonField = ytdTotals + + /** + * Returns the raw JSON value of [tier]. + * + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier + + /** + * 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 [LoanTapeUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountStanding() + * .availableCredit() + * .balances() + * .created() + * .creditLimit() + * .creditProductToken() + * .date() + * .dayTotals() + * .endingBalance() + * .excessCredits() + * .financialAccountToken() + * .interestDetails() + * .minimumPaymentBalance() + * .paymentAllocation() + * .periodTotals() + * .previousStatementBalance() + * .startingBalance() + * .updated() + * .version() + * .ytdTotals() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LoanTapeUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountStanding: JsonField? = null + private var availableCredit: JsonField? = null + private var balances: JsonField? = null + private var created: JsonField? = null + private var creditLimit: JsonField? = null + private var creditProductToken: JsonField? = null + private var date: JsonField? = null + private var dayTotals: JsonField? = null + private var endingBalance: JsonField? = null + private var excessCredits: JsonField? = null + private var financialAccountToken: JsonField? = null + private var interestDetails: JsonField? = null + private var minimumPaymentBalance: JsonField? = null + private var paymentAllocation: JsonField? = null + private var periodTotals: JsonField? = null + private var previousStatementBalance: JsonField? = null + private var startingBalance: JsonField? = null + private var updated: JsonField? = null + private var version: JsonField? = null + private var ytdTotals: JsonField? = null + private var tier: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(loanTapeUpdatedWebhookEvent: LoanTapeUpdatedWebhookEvent) = apply { + token = loanTapeUpdatedWebhookEvent.token + accountStanding = loanTapeUpdatedWebhookEvent.accountStanding + availableCredit = loanTapeUpdatedWebhookEvent.availableCredit + balances = loanTapeUpdatedWebhookEvent.balances + created = loanTapeUpdatedWebhookEvent.created + creditLimit = loanTapeUpdatedWebhookEvent.creditLimit + creditProductToken = loanTapeUpdatedWebhookEvent.creditProductToken + date = loanTapeUpdatedWebhookEvent.date + dayTotals = loanTapeUpdatedWebhookEvent.dayTotals + endingBalance = loanTapeUpdatedWebhookEvent.endingBalance + excessCredits = loanTapeUpdatedWebhookEvent.excessCredits + financialAccountToken = loanTapeUpdatedWebhookEvent.financialAccountToken + interestDetails = loanTapeUpdatedWebhookEvent.interestDetails + minimumPaymentBalance = loanTapeUpdatedWebhookEvent.minimumPaymentBalance + paymentAllocation = loanTapeUpdatedWebhookEvent.paymentAllocation + periodTotals = loanTapeUpdatedWebhookEvent.periodTotals + previousStatementBalance = loanTapeUpdatedWebhookEvent.previousStatementBalance + startingBalance = loanTapeUpdatedWebhookEvent.startingBalance + updated = loanTapeUpdatedWebhookEvent.updated + version = loanTapeUpdatedWebhookEvent.version + ytdTotals = loanTapeUpdatedWebhookEvent.ytdTotals + tier = loanTapeUpdatedWebhookEvent.tier + eventType = loanTapeUpdatedWebhookEvent.eventType + additionalProperties = loanTapeUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for a loan tape */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun accountStanding(accountStanding: LoanTape.AccountStanding) = + accountStanding(JsonField.of(accountStanding)) + + /** + * Sets [Builder.accountStanding] to an arbitrary JSON value. + * + * You should usually call [Builder.accountStanding] with a well-typed + * [LoanTape.AccountStanding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun accountStanding(accountStanding: JsonField) = apply { + this.accountStanding = accountStanding + } + + /** Amount of credit available to spend in cents */ + fun availableCredit(availableCredit: Long) = availableCredit(JsonField.of(availableCredit)) + + /** + * Sets [Builder.availableCredit] to an arbitrary JSON value. + * + * You should usually call [Builder.availableCredit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun availableCredit(availableCredit: JsonField) = apply { + this.availableCredit = availableCredit + } + + fun balances(balances: LoanTape.Balances) = balances(JsonField.of(balances)) + + /** + * Sets [Builder.balances] to an arbitrary JSON value. + * + * You should usually call [Builder.balances] with a well-typed [LoanTape.Balances] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun balances(balances: JsonField) = apply { this.balances = balances } + + /** Timestamp of when the loan tape was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** + * For prepay accounts, this is the minimum prepay balance that must be maintained. For + * charge card accounts, this is the maximum credit balance extended by a lender + */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** + * Sets [Builder.creditLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.creditLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** Globally unique identifier for a credit product */ + fun creditProductToken(creditProductToken: String) = + creditProductToken(JsonField.of(creditProductToken)) + + /** + * Sets [Builder.creditProductToken] to an arbitrary JSON value. + * + * You should usually call [Builder.creditProductToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditProductToken(creditProductToken: JsonField) = apply { + this.creditProductToken = creditProductToken + } + + /** Date of transactions that this loan tape covers */ + fun date(date: LocalDate) = date(JsonField.of(date)) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [LocalDate] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun date(date: JsonField) = apply { this.date = date } + + fun dayTotals(dayTotals: StatementTotals) = dayTotals(JsonField.of(dayTotals)) + + /** + * Sets [Builder.dayTotals] to an arbitrary JSON value. + * + * You should usually call [Builder.dayTotals] with a well-typed [StatementTotals] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun dayTotals(dayTotals: JsonField) = apply { this.dayTotals = dayTotals } + + /** Balance at the end of the day */ + fun endingBalance(endingBalance: Long) = endingBalance(JsonField.of(endingBalance)) + + /** + * Sets [Builder.endingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endingBalance(endingBalance: JsonField) = apply { + this.endingBalance = endingBalance + } + + /** + * Excess credits in the form of provisional credits, payments, or purchase refunds. If + * positive, the account is in net credit state with no outstanding balances. An overpayment + * could land an account in this state + */ + fun excessCredits(excessCredits: Long) = excessCredits(JsonField.of(excessCredits)) + + /** + * Sets [Builder.excessCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.excessCredits] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun excessCredits(excessCredits: JsonField) = apply { + this.excessCredits = excessCredits + } + + /** Globally unique identifier for a financial account */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + fun interestDetails(interestDetails: LoanTape.InterestDetails?) = + interestDetails(JsonField.ofNullable(interestDetails)) + + /** Alias for calling [Builder.interestDetails] with `interestDetails.orElse(null)`. */ + fun interestDetails(interestDetails: Optional) = + interestDetails(interestDetails.getOrNull()) + + /** + * Sets [Builder.interestDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.interestDetails] with a well-typed + * [LoanTape.InterestDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun interestDetails(interestDetails: JsonField) = apply { + this.interestDetails = interestDetails + } + + fun minimumPaymentBalance(minimumPaymentBalance: LoanTape.BalanceDetails) = + minimumPaymentBalance(JsonField.of(minimumPaymentBalance)) + + /** + * Sets [Builder.minimumPaymentBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.minimumPaymentBalance] with a well-typed + * [LoanTape.BalanceDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun minimumPaymentBalance(minimumPaymentBalance: JsonField) = + apply { + this.minimumPaymentBalance = minimumPaymentBalance + } + + fun paymentAllocation(paymentAllocation: CategoryBalances) = + paymentAllocation(JsonField.of(paymentAllocation)) + + /** + * Sets [Builder.paymentAllocation] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentAllocation] with a well-typed [CategoryBalances] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun paymentAllocation(paymentAllocation: JsonField) = apply { + this.paymentAllocation = paymentAllocation + } + + fun periodTotals(periodTotals: StatementTotals) = periodTotals(JsonField.of(periodTotals)) + + /** + * Sets [Builder.periodTotals] to an arbitrary JSON value. + * + * You should usually call [Builder.periodTotals] with a well-typed [StatementTotals] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun periodTotals(periodTotals: JsonField) = apply { + this.periodTotals = periodTotals + } + + fun previousStatementBalance(previousStatementBalance: LoanTape.BalanceDetails) = + previousStatementBalance(JsonField.of(previousStatementBalance)) + + /** + * Sets [Builder.previousStatementBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.previousStatementBalance] with a well-typed + * [LoanTape.BalanceDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun previousStatementBalance(previousStatementBalance: JsonField) = + apply { + this.previousStatementBalance = previousStatementBalance + } + + /** Balance at the start of the day */ + fun startingBalance(startingBalance: Long) = startingBalance(JsonField.of(startingBalance)) + + /** + * Sets [Builder.startingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.startingBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } + + /** Timestamp of when the loan tape was updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** Version number of the loan tape. This starts at 1 */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun ytdTotals(ytdTotals: StatementTotals) = ytdTotals(JsonField.of(ytdTotals)) + + /** + * Sets [Builder.ytdTotals] to an arbitrary JSON value. + * + * You should usually call [Builder.ytdTotals] with a well-typed [StatementTotals] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ytdTotals(ytdTotals: JsonField) = apply { this.ytdTotals = ytdTotals } + + /** Interest tier to which this account belongs to */ + fun tier(tier: String?) = tier(JsonField.ofNullable(tier)) + + /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ + fun tier(tier: Optional) = tier(tier.getOrNull()) + + /** + * Sets [Builder.tier] to an arbitrary JSON value. + * + * You should usually call [Builder.tier] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tier(tier: JsonField) = apply { this.tier = tier } + + /** 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 [LoanTapeUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountStanding() + * .availableCredit() + * .balances() + * .created() + * .creditLimit() + * .creditProductToken() + * .date() + * .dayTotals() + * .endingBalance() + * .excessCredits() + * .financialAccountToken() + * .interestDetails() + * .minimumPaymentBalance() + * .paymentAllocation() + * .periodTotals() + * .previousStatementBalance() + * .startingBalance() + * .updated() + * .version() + * .ytdTotals() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LoanTapeUpdatedWebhookEvent = + LoanTapeUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountStanding", accountStanding), + checkRequired("availableCredit", availableCredit), + checkRequired("balances", balances), + checkRequired("created", created), + checkRequired("creditLimit", creditLimit), + checkRequired("creditProductToken", creditProductToken), + checkRequired("date", date), + checkRequired("dayTotals", dayTotals), + checkRequired("endingBalance", endingBalance), + checkRequired("excessCredits", excessCredits), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("interestDetails", interestDetails), + checkRequired("minimumPaymentBalance", minimumPaymentBalance), + checkRequired("paymentAllocation", paymentAllocation), + checkRequired("periodTotals", periodTotals), + checkRequired("previousStatementBalance", previousStatementBalance), + checkRequired("startingBalance", startingBalance), + checkRequired("updated", updated), + checkRequired("version", version), + checkRequired("ytdTotals", ytdTotals), + tier, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LoanTapeUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountStanding().validate() + availableCredit() + balances().validate() + created() + creditLimit() + creditProductToken() + date() + dayTotals().validate() + endingBalance() + excessCredits() + financialAccountToken() + interestDetails().ifPresent { it.validate() } + minimumPaymentBalance().validate() + paymentAllocation().validate() + periodTotals().validate() + previousStatementBalance().validate() + startingBalance() + updated() + version() + ytdTotals().validate() + tier() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (accountStanding.asKnown().getOrNull()?.validity() ?: 0) + + (if (availableCredit.asKnown().isPresent) 1 else 0) + + (balances.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (creditLimit.asKnown().isPresent) 1 else 0) + + (if (creditProductToken.asKnown().isPresent) 1 else 0) + + (if (date.asKnown().isPresent) 1 else 0) + + (dayTotals.asKnown().getOrNull()?.validity() ?: 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (if (excessCredits.asKnown().isPresent) 1 else 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (interestDetails.asKnown().getOrNull()?.validity() ?: 0) + + (minimumPaymentBalance.asKnown().getOrNull()?.validity() ?: 0) + + (paymentAllocation.asKnown().getOrNull()?.validity() ?: 0) + + (periodTotals.asKnown().getOrNull()?.validity() ?: 0) + + (previousStatementBalance.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (ytdTotals.asKnown().getOrNull()?.validity() ?: 0) + + (if (tier.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 LOAN_TAPE_UPDATED = of("loan_tape.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + LOAN_TAPE_UPDATED + } + + /** + * 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 { + LOAN_TAPE_UPDATED, + /** + * 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) { + LOAN_TAPE_UPDATED -> Value.LOAN_TAPE_UPDATED + 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) { + LOAN_TAPE_UPDATED -> Known.LOAN_TAPE_UPDATED + 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 + + 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 LoanTapeUpdatedWebhookEvent && + token == other.token && + accountStanding == other.accountStanding && + availableCredit == other.availableCredit && + balances == other.balances && + created == other.created && + creditLimit == other.creditLimit && + creditProductToken == other.creditProductToken && + date == other.date && + dayTotals == other.dayTotals && + endingBalance == other.endingBalance && + excessCredits == other.excessCredits && + financialAccountToken == other.financialAccountToken && + interestDetails == other.interestDetails && + minimumPaymentBalance == other.minimumPaymentBalance && + paymentAllocation == other.paymentAllocation && + periodTotals == other.periodTotals && + previousStatementBalance == other.previousStatementBalance && + startingBalance == other.startingBalance && + updated == other.updated && + version == other.version && + ytdTotals == other.ytdTotals && + tier == other.tier && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountStanding, + availableCredit, + balances, + created, + creditLimit, + creditProductToken, + date, + dayTotals, + endingBalance, + excessCredits, + financialAccountToken, + interestDetails, + minimumPaymentBalance, + paymentAllocation, + periodTotals, + previousStatementBalance, + startingBalance, + updated, + version, + ytdTotals, + tier, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LoanTapeUpdatedWebhookEvent{token=$token, accountStanding=$accountStanding, availableCredit=$availableCredit, balances=$balances, created=$created, creditLimit=$creditLimit, creditProductToken=$creditProductToken, date=$date, dayTotals=$dayTotals, endingBalance=$endingBalance, excessCredits=$excessCredits, financialAccountToken=$financialAccountToken, interestDetails=$interestDetails, minimumPaymentBalance=$minimumPaymentBalance, paymentAllocation=$paymentAllocation, periodTotals=$periodTotals, previousStatementBalance=$previousStatementBalance, startingBalance=$startingBalance, updated=$updated, version=$version, ytdTotals=$ytdTotals, tier=$tier, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreatedWebhookEvent.kt new file mode 100644 index 000000000..37406a7bb --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationCreatedWebhookEvent.kt @@ -0,0 +1,1042 @@ +// 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 + +class ManagementOperationCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val created: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val category: JsonField, + private val currency: JsonField, + private val direction: JsonField, + private val events: JsonField>, + private val externalResource: JsonField, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val transactionSeries: JsonField, + private val userDefinedId: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = + JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = + JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = + JsonMissing.of(), + @JsonProperty("external_resource") + @ExcludeMissing + externalResource: JsonField = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = + JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + created, + status, + updated, + category, + currency, + direction, + events, + externalResource, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + transactionSeries, + userDefinedId, + eventType, + mutableMapOf(), + ) + + fun toManagementOperationTransaction(): ManagementOperationTransaction = + ManagementOperationTransaction.builder() + .token(token) + .created(created) + .status(status) + .updated(updated) + .category(category) + .currency(currency) + .direction(direction) + .events(events) + .externalResource(externalResource) + .family(family) + .financialAccountToken(financialAccountToken) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .transactionSeries(transactionSeries) + .userDefinedId(userDefinedId) + .build() + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): ManagementOperationTransaction.TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun category(): Optional = + category.getOptional("category") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun direction(): Optional = + direction.getOptional("direction") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun events(): Optional> = + events.getOptional("events") + + /** + * External resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResource(): Optional = + externalResource.getOptional("external_resource") + + /** + * MANAGEMENT_OPERATION - Management Operation Transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun family(): Optional = family.getOptional("family") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun financialAccountToken(): Optional = + financialAccountToken.getOptional("financial_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pendingAmount(): Optional = pendingAmount.getOptional("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = + result.getOptional("result") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun settledAmount(): Optional = settledAmount.getOptional("settled_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * 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 [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 [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 [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = + category + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = + direction + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [externalResource]. + * + * Unlike [externalResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource") + @ExcludeMissing + fun _externalResource(): JsonField = externalResource + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = + transactionSeries + + /** + * Returns the raw JSON value of [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + /** + * 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 + * [ManagementOperationCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .status() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ManagementOperationCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var created: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var category: + JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var direction: + JsonField = + JsonMissing.of() + private var events: + JsonField>? = + null + private var externalResource: JsonField = JsonMissing.of() + private var family: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var pendingAmount: JsonField = JsonMissing.of() + private var result: JsonField = + JsonMissing.of() + private var settledAmount: JsonField = JsonMissing.of() + private var transactionSeries: JsonField = + JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + managementOperationCreatedWebhookEvent: ManagementOperationCreatedWebhookEvent + ) = apply { + token = managementOperationCreatedWebhookEvent.token + created = managementOperationCreatedWebhookEvent.created + status = managementOperationCreatedWebhookEvent.status + updated = managementOperationCreatedWebhookEvent.updated + category = managementOperationCreatedWebhookEvent.category + currency = managementOperationCreatedWebhookEvent.currency + direction = managementOperationCreatedWebhookEvent.direction + events = managementOperationCreatedWebhookEvent.events.map { it.toMutableList() } + externalResource = managementOperationCreatedWebhookEvent.externalResource + family = managementOperationCreatedWebhookEvent.family + financialAccountToken = managementOperationCreatedWebhookEvent.financialAccountToken + pendingAmount = managementOperationCreatedWebhookEvent.pendingAmount + result = managementOperationCreatedWebhookEvent.result + settledAmount = managementOperationCreatedWebhookEvent.settledAmount + transactionSeries = managementOperationCreatedWebhookEvent.transactionSeries + userDefinedId = managementOperationCreatedWebhookEvent.userDefinedId + eventType = managementOperationCreatedWebhookEvent.eventType + additionalProperties = + managementOperationCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** The status of the transaction */ + fun status(status: ManagementOperationTransaction.TransactionStatus) = + status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [ManagementOperationTransaction.TransactionStatus] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun category(category: ManagementOperationTransaction.ManagementOperationCategory) = + category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [ManagementOperationTransaction.ManagementOperationCategory] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun category( + category: JsonField + ) = apply { this.category = category } + + fun 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 direction(direction: ManagementOperationTransaction.ManagementOperationDirection) = + direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed + * [ManagementOperationTransaction.ManagementOperationDirection] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun direction( + direction: JsonField + ) = apply { this.direction = direction } + + fun events(events: List) = + events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun events( + events: JsonField> + ) = apply { this.events = events.map { it.toMutableList() } } + + /** + * Adds a single [ManagementOperationTransaction.ManagementOperationEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: ManagementOperationTransaction.ManagementOperationEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) + + /** Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) + + /** + * Sets [Builder.externalResource] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResource] with a well-typed [ExternalResource] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalResource(externalResource: JsonField) = apply { + this.externalResource = externalResource + } + + /** MANAGEMENT_OPERATION - Management Operation Transaction */ + fun family(family: ManagementOperationTransaction.Family) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed + * [ManagementOperationTransaction.Family] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun family(family: JsonField) = apply { + this.family = family + } + + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: ManagementOperationTransaction.TransactionResult) = + result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [ManagementOperationTransaction.TransactionResult] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + fun transactionSeries( + transactionSeries: ManagementOperationTransaction.TransactionSeries? + ) = transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. */ + fun transactionSeries( + transactionSeries: Optional + ) = transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed + * [ManagementOperationTransaction.TransactionSeries] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun transactionSeries( + transactionSeries: JsonField + ) = apply { this.transactionSeries = transactionSeries } + + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** 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 [ManagementOperationCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .status() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ManagementOperationCreatedWebhookEvent = + ManagementOperationCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("created", created), + checkRequired("status", status), + checkRequired("updated", updated), + category, + currency, + direction, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + externalResource, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + transactionSeries, + userDefinedId, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ManagementOperationCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + created() + status().validate() + updated() + category().ifPresent { it.validate() } + currency() + direction().ifPresent { it.validate() } + events().ifPresent { it.forEach { it.validate() } } + externalResource().ifPresent { it.validate() } + family().ifPresent { it.validate() } + financialAccountToken() + pendingAmount() + result().ifPresent { it.validate() } + settledAmount() + transactionSeries().ifPresent { it.validate() } + userDefinedId() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (direction.asKnown().getOrNull()?.validity() ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (externalResource.asKnown().getOrNull()?.validity() ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 MANAGEMENT_OPERATION_CREATED = of("management_operation.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + MANAGEMENT_OPERATION_CREATED + } + + /** + * 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 { + MANAGEMENT_OPERATION_CREATED, + /** + * 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) { + MANAGEMENT_OPERATION_CREATED -> Value.MANAGEMENT_OPERATION_CREATED + 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) { + MANAGEMENT_OPERATION_CREATED -> Known.MANAGEMENT_OPERATION_CREATED + 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 + + 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 ManagementOperationCreatedWebhookEvent && + token == other.token && + created == other.created && + status == other.status && + updated == other.updated && + category == other.category && + currency == other.currency && + direction == other.direction && + events == other.events && + externalResource == other.externalResource && + family == other.family && + financialAccountToken == other.financialAccountToken && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + transactionSeries == other.transactionSeries && + userDefinedId == other.userDefinedId && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + created, + status, + updated, + category, + currency, + direction, + events, + externalResource, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + transactionSeries, + userDefinedId, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ManagementOperationCreatedWebhookEvent{token=$token, created=$created, status=$status, updated=$updated, category=$category, currency=$currency, direction=$direction, events=$events, externalResource=$externalResource, family=$family, financialAccountToken=$financialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, transactionSeries=$transactionSeries, userDefinedId=$userDefinedId, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationUpdatedWebhookEvent.kt new file mode 100644 index 000000000..42b2140e1 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ManagementOperationUpdatedWebhookEvent.kt @@ -0,0 +1,1042 @@ +// 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 + +class ManagementOperationUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val created: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val category: JsonField, + private val currency: JsonField, + private val direction: JsonField, + private val events: JsonField>, + private val externalResource: JsonField, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val pendingAmount: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val transactionSeries: JsonField, + private val userDefinedId: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = + JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = + JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = + JsonMissing.of(), + @JsonProperty("external_resource") + @ExcludeMissing + externalResource: JsonField = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("transaction_series") + @ExcludeMissing + transactionSeries: JsonField = + JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + created, + status, + updated, + category, + currency, + direction, + events, + externalResource, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + transactionSeries, + userDefinedId, + eventType, + mutableMapOf(), + ) + + fun toManagementOperationTransaction(): ManagementOperationTransaction = + ManagementOperationTransaction.builder() + .token(token) + .created(created) + .status(status) + .updated(updated) + .category(category) + .currency(currency) + .direction(direction) + .events(events) + .externalResource(externalResource) + .family(family) + .financialAccountToken(financialAccountToken) + .pendingAmount(pendingAmount) + .result(result) + .settledAmount(settledAmount) + .transactionSeries(transactionSeries) + .userDefinedId(userDefinedId) + .build() + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): ManagementOperationTransaction.TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun category(): Optional = + category.getOptional("category") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun direction(): Optional = + direction.getOptional("direction") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun events(): Optional> = + events.getOptional("events") + + /** + * External resource associated with the management operation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalResource(): Optional = + externalResource.getOptional("external_resource") + + /** + * MANAGEMENT_OPERATION - Management Operation Transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun family(): Optional = family.getOptional("family") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun financialAccountToken(): Optional = + financialAccountToken.getOptional("financial_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pendingAmount(): Optional = pendingAmount.getOptional("pending_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = + result.getOptional("result") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun settledAmount(): Optional = settledAmount.getOptional("settled_amount") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionSeries(): Optional = + transactionSeries.getOptional("transaction_series") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * 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 [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 [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 [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = + category + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = + direction + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [externalResource]. + * + * Unlike [externalResource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("external_resource") + @ExcludeMissing + fun _externalResource(): JsonField = externalResource + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") + @ExcludeMissing + fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [transactionSeries]. + * + * Unlike [transactionSeries], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_series") + @ExcludeMissing + fun _transactionSeries(): JsonField = + transactionSeries + + /** + * Returns the raw JSON value of [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + /** + * 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 + * [ManagementOperationUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .status() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ManagementOperationUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var created: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var category: + JsonField = + JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var direction: + JsonField = + JsonMissing.of() + private var events: + JsonField>? = + null + private var externalResource: JsonField = JsonMissing.of() + private var family: JsonField = JsonMissing.of() + private var financialAccountToken: JsonField = JsonMissing.of() + private var pendingAmount: JsonField = JsonMissing.of() + private var result: JsonField = + JsonMissing.of() + private var settledAmount: JsonField = JsonMissing.of() + private var transactionSeries: JsonField = + JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + managementOperationUpdatedWebhookEvent: ManagementOperationUpdatedWebhookEvent + ) = apply { + token = managementOperationUpdatedWebhookEvent.token + created = managementOperationUpdatedWebhookEvent.created + status = managementOperationUpdatedWebhookEvent.status + updated = managementOperationUpdatedWebhookEvent.updated + category = managementOperationUpdatedWebhookEvent.category + currency = managementOperationUpdatedWebhookEvent.currency + direction = managementOperationUpdatedWebhookEvent.direction + events = managementOperationUpdatedWebhookEvent.events.map { it.toMutableList() } + externalResource = managementOperationUpdatedWebhookEvent.externalResource + family = managementOperationUpdatedWebhookEvent.family + financialAccountToken = managementOperationUpdatedWebhookEvent.financialAccountToken + pendingAmount = managementOperationUpdatedWebhookEvent.pendingAmount + result = managementOperationUpdatedWebhookEvent.result + settledAmount = managementOperationUpdatedWebhookEvent.settledAmount + transactionSeries = managementOperationUpdatedWebhookEvent.transactionSeries + userDefinedId = managementOperationUpdatedWebhookEvent.userDefinedId + eventType = managementOperationUpdatedWebhookEvent.eventType + additionalProperties = + managementOperationUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** The status of the transaction */ + fun status(status: ManagementOperationTransaction.TransactionStatus) = + status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [ManagementOperationTransaction.TransactionStatus] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun category(category: ManagementOperationTransaction.ManagementOperationCategory) = + category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [ManagementOperationTransaction.ManagementOperationCategory] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun category( + category: JsonField + ) = apply { this.category = category } + + fun 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 direction(direction: ManagementOperationTransaction.ManagementOperationDirection) = + direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed + * [ManagementOperationTransaction.ManagementOperationDirection] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun direction( + direction: JsonField + ) = apply { this.direction = direction } + + fun events(events: List) = + events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed + * `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun events( + events: JsonField> + ) = apply { this.events = events.map { it.toMutableList() } } + + /** + * Adds a single [ManagementOperationTransaction.ManagementOperationEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: ManagementOperationTransaction.ManagementOperationEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** External resource associated with the management operation */ + fun externalResource(externalResource: ExternalResource?) = + externalResource(JsonField.ofNullable(externalResource)) + + /** Alias for calling [Builder.externalResource] with `externalResource.orElse(null)`. */ + fun externalResource(externalResource: Optional) = + externalResource(externalResource.getOrNull()) + + /** + * Sets [Builder.externalResource] to an arbitrary JSON value. + * + * You should usually call [Builder.externalResource] with a well-typed [ExternalResource] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalResource(externalResource: JsonField) = apply { + this.externalResource = externalResource + } + + /** MANAGEMENT_OPERATION - Management Operation Transaction */ + fun family(family: ManagementOperationTransaction.Family) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed + * [ManagementOperationTransaction.Family] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun family(family: JsonField) = apply { + this.family = family + } + + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + fun result(result: ManagementOperationTransaction.TransactionResult) = + result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed + * [ManagementOperationTransaction.TransactionResult] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun result(result: JsonField) = apply { + this.result = result + } + + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + fun transactionSeries( + transactionSeries: ManagementOperationTransaction.TransactionSeries? + ) = transactionSeries(JsonField.ofNullable(transactionSeries)) + + /** Alias for calling [Builder.transactionSeries] with `transactionSeries.orElse(null)`. */ + fun transactionSeries( + transactionSeries: Optional + ) = transactionSeries(transactionSeries.getOrNull()) + + /** + * Sets [Builder.transactionSeries] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionSeries] with a well-typed + * [ManagementOperationTransaction.TransactionSeries] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun transactionSeries( + transactionSeries: JsonField + ) = apply { this.transactionSeries = transactionSeries } + + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** 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 [ManagementOperationUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .created() + * .status() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ManagementOperationUpdatedWebhookEvent = + ManagementOperationUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("created", created), + checkRequired("status", status), + checkRequired("updated", updated), + category, + currency, + direction, + (events ?: JsonMissing.of()).map { it.toImmutable() }, + externalResource, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + transactionSeries, + userDefinedId, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ManagementOperationUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + created() + status().validate() + updated() + category().ifPresent { it.validate() } + currency() + direction().ifPresent { it.validate() } + events().ifPresent { it.forEach { it.validate() } } + externalResource().ifPresent { it.validate() } + family().ifPresent { it.validate() } + financialAccountToken() + pendingAmount() + result().ifPresent { it.validate() } + settledAmount() + transactionSeries().ifPresent { it.validate() } + userDefinedId() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (direction.asKnown().getOrNull()?.validity() ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (externalResource.asKnown().getOrNull()?.validity() ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (transactionSeries.asKnown().getOrNull()?.validity() ?: 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 MANAGEMENT_OPERATION_UPDATED = of("management_operation.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + MANAGEMENT_OPERATION_UPDATED + } + + /** + * 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 { + MANAGEMENT_OPERATION_UPDATED, + /** + * 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) { + MANAGEMENT_OPERATION_UPDATED -> Value.MANAGEMENT_OPERATION_UPDATED + 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) { + MANAGEMENT_OPERATION_UPDATED -> Known.MANAGEMENT_OPERATION_UPDATED + 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 + + 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 ManagementOperationUpdatedWebhookEvent && + token == other.token && + created == other.created && + status == other.status && + updated == other.updated && + category == other.category && + currency == other.currency && + direction == other.direction && + events == other.events && + externalResource == other.externalResource && + family == other.family && + financialAccountToken == other.financialAccountToken && + pendingAmount == other.pendingAmount && + result == other.result && + settledAmount == other.settledAmount && + transactionSeries == other.transactionSeries && + userDefinedId == other.userDefinedId && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + created, + status, + updated, + category, + currency, + direction, + events, + externalResource, + family, + financialAccountToken, + pendingAmount, + result, + settledAmount, + transactionSeries, + userDefinedId, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ManagementOperationUpdatedWebhookEvent{token=$token, created=$created, status=$status, updated=$updated, category=$category, currency=$currency, direction=$direction, events=$events, externalResource=$externalResource, family=$family, financialAccountToken=$financialAccountToken, pendingAmount=$pendingAmount, result=$result, settledAmount=$settledAmount, transactionSeries=$transactionSeries, userDefinedId=$userDefinedId, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalCreatedWebhookEvent.kt new file mode 100644 index 000000000..0ac4b43d6 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalCreatedWebhookEvent.kt @@ -0,0 +1,849 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NetworkTotalCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val amounts: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val institutionId: JsonField, + private val isComplete: JsonField, + private val network: JsonField, + private val reportDate: JsonField, + private val settlementInstitutionId: JsonField, + private val settlementService: JsonField, + private val updated: JsonField, + private val cycle: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amounts") + @ExcludeMissing + amounts: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("institution_id") + @ExcludeMissing + institutionId: JsonField = JsonMissing.of(), + @JsonProperty("is_complete") + @ExcludeMissing + isComplete: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), + @JsonProperty("report_date") + @ExcludeMissing + reportDate: JsonField = JsonMissing.of(), + @JsonProperty("settlement_institution_id") + @ExcludeMissing + settlementInstitutionId: JsonField = JsonMissing.of(), + @JsonProperty("settlement_service") + @ExcludeMissing + settlementService: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("cycle") @ExcludeMissing cycle: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + amounts, + created, + currency, + institutionId, + isComplete, + network, + reportDate, + settlementInstitutionId, + settlementService, + updated, + cycle, + eventType, + mutableMapOf(), + ) + + fun toNetworkTotal(): NetworkTotal = + NetworkTotal.builder() + .token(token) + .amounts(amounts) + .created(created) + .currency(currency) + .institutionId(institutionId) + .isComplete(isComplete) + .network(network) + .reportDate(reportDate) + .settlementInstitutionId(settlementInstitutionId) + .settlementService(settlementService) + .updated(updated) + .cycle(cycle) + .build() + + /** + * Globally unique identifier. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if 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(): NetworkTotal.Amounts = amounts.getRequired("amounts") + + /** + * RFC 3339 timestamp for when the record was created. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") + + /** + * The institution that activity occurred on. For Mastercard: ICA (Interbank Card Association). + * For Maestro: institution ID. For Visa: lowest level SRE (Settlement Reporting Entity). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun institutionId(): String = institutionId.getRequired("institution_id") + + /** + * Indicates that all settlement records related to this Network Total are available in the + * details 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 isComplete(): Boolean = isComplete.getRequired("is_complete") + + /** + * Card network where the transaction took place. AMEX, VISA, MASTERCARD, MAESTRO, or INTERLINK. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): NetworkTotal.Network = network.getRequired("network") + + /** + * Date that the network total record applies to. YYYY-MM-DD format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun reportDate(): LocalDate = reportDate.getRequired("report_date") + + /** + * The institution responsible for settlement. For Mastercard: same as `institution_id`. For + * Maestro: billing ICA. For Visa: Funds Transfer SRE (FTSRE). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settlementInstitutionId(): String = + settlementInstitutionId.getRequired("settlement_institution_id") + + /** + * Settlement service. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settlementService(): String = settlementService.getRequired("settlement_service") + + /** + * RFC 3339 timestamp for when the record was last updated. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * The clearing cycle that the network total record applies to. Mastercard only. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cycle(): Optional = cycle.getOptional("cycle") + + /** + * 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 [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 [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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [institutionId]. + * + * Unlike [institutionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("institution_id") + @ExcludeMissing + fun _institutionId(): JsonField = institutionId + + /** + * Returns the raw JSON value of [isComplete]. + * + * Unlike [isComplete], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_complete") @ExcludeMissing fun _isComplete(): JsonField = isComplete + + /** + * 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 [reportDate]. + * + * Unlike [reportDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("report_date") + @ExcludeMissing + fun _reportDate(): JsonField = reportDate + + /** + * Returns the raw JSON value of [settlementInstitutionId]. + * + * Unlike [settlementInstitutionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("settlement_institution_id") + @ExcludeMissing + fun _settlementInstitutionId(): JsonField = settlementInstitutionId + + /** + * Returns the raw JSON value of [settlementService]. + * + * Unlike [settlementService], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("settlement_service") + @ExcludeMissing + fun _settlementService(): JsonField = settlementService + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [cycle]. + * + * Unlike [cycle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cycle") @ExcludeMissing fun _cycle(): JsonField = cycle + + /** + * 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 + * [NetworkTotalCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .amounts() + * .created() + * .currency() + * .institutionId() + * .isComplete() + * .network() + * .reportDate() + * .settlementInstitutionId() + * .settlementService() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkTotalCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var amounts: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var institutionId: JsonField? = null + private var isComplete: JsonField? = null + private var network: JsonField? = null + private var reportDate: JsonField? = null + private var settlementInstitutionId: JsonField? = null + private var settlementService: JsonField? = null + private var updated: JsonField? = null + private var cycle: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(networkTotalCreatedWebhookEvent: NetworkTotalCreatedWebhookEvent) = + apply { + token = networkTotalCreatedWebhookEvent.token + amounts = networkTotalCreatedWebhookEvent.amounts + created = networkTotalCreatedWebhookEvent.created + currency = networkTotalCreatedWebhookEvent.currency + institutionId = networkTotalCreatedWebhookEvent.institutionId + isComplete = networkTotalCreatedWebhookEvent.isComplete + network = networkTotalCreatedWebhookEvent.network + reportDate = networkTotalCreatedWebhookEvent.reportDate + settlementInstitutionId = networkTotalCreatedWebhookEvent.settlementInstitutionId + settlementService = networkTotalCreatedWebhookEvent.settlementService + updated = networkTotalCreatedWebhookEvent.updated + cycle = networkTotalCreatedWebhookEvent.cycle + eventType = networkTotalCreatedWebhookEvent.eventType + additionalProperties = + networkTotalCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun amounts(amounts: NetworkTotal.Amounts) = amounts(JsonField.of(amounts)) + + /** + * Sets [Builder.amounts] to an arbitrary JSON value. + * + * You should usually call [Builder.amounts] with a well-typed [NetworkTotal.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 } + + /** RFC 3339 timestamp for when the record was created. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** 3-character alphabetic ISO 4217 code. */ + 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 } + + /** + * The institution that activity occurred on. For Mastercard: ICA (Interbank Card + * Association). For Maestro: institution ID. For Visa: lowest level SRE (Settlement + * Reporting Entity). + */ + fun institutionId(institutionId: String) = institutionId(JsonField.of(institutionId)) + + /** + * Sets [Builder.institutionId] to an arbitrary JSON value. + * + * You should usually call [Builder.institutionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun institutionId(institutionId: JsonField) = apply { + this.institutionId = institutionId + } + + /** + * Indicates that all settlement records related to this Network Total are available in the + * details endpoint. + */ + fun isComplete(isComplete: Boolean) = isComplete(JsonField.of(isComplete)) + + /** + * Sets [Builder.isComplete] to an arbitrary JSON value. + * + * You should usually call [Builder.isComplete] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isComplete(isComplete: JsonField) = apply { this.isComplete = isComplete } + + /** + * Card network where the transaction took place. AMEX, VISA, MASTERCARD, MAESTRO, or + * INTERLINK. + */ + fun network(network: NetworkTotal.Network) = network(JsonField.of(network)) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [NetworkTotal.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 } + + /** Date that the network total record applies to. YYYY-MM-DD format. */ + fun reportDate(reportDate: LocalDate) = reportDate(JsonField.of(reportDate)) + + /** + * Sets [Builder.reportDate] to an arbitrary JSON value. + * + * You should usually call [Builder.reportDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reportDate(reportDate: JsonField) = apply { this.reportDate = reportDate } + + /** + * The institution responsible for settlement. For Mastercard: same as `institution_id`. For + * Maestro: billing ICA. For Visa: Funds Transfer SRE (FTSRE). + */ + fun settlementInstitutionId(settlementInstitutionId: String) = + settlementInstitutionId(JsonField.of(settlementInstitutionId)) + + /** + * Sets [Builder.settlementInstitutionId] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementInstitutionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun settlementInstitutionId(settlementInstitutionId: JsonField) = apply { + this.settlementInstitutionId = settlementInstitutionId + } + + /** Settlement service. */ + fun settlementService(settlementService: String) = + settlementService(JsonField.of(settlementService)) + + /** + * Sets [Builder.settlementService] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementService] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settlementService(settlementService: JsonField) = apply { + this.settlementService = settlementService + } + + /** RFC 3339 timestamp for when the record was last updated. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** The clearing cycle that the network total record applies to. Mastercard only. */ + fun cycle(cycle: Long) = cycle(JsonField.of(cycle)) + + /** + * Sets [Builder.cycle] to an arbitrary JSON value. + * + * You should usually call [Builder.cycle] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cycle(cycle: JsonField) = apply { this.cycle = cycle } + + /** 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 [NetworkTotalCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .amounts() + * .created() + * .currency() + * .institutionId() + * .isComplete() + * .network() + * .reportDate() + * .settlementInstitutionId() + * .settlementService() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkTotalCreatedWebhookEvent = + NetworkTotalCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("amounts", amounts), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("institutionId", institutionId), + checkRequired("isComplete", isComplete), + checkRequired("network", network), + checkRequired("reportDate", reportDate), + checkRequired("settlementInstitutionId", settlementInstitutionId), + checkRequired("settlementService", settlementService), + checkRequired("updated", updated), + cycle, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NetworkTotalCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + amounts().validate() + created() + currency() + institutionId() + isComplete() + network().validate() + reportDate() + settlementInstitutionId() + settlementService() + updated() + cycle() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (amounts.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (institutionId.asKnown().isPresent) 1 else 0) + + (if (isComplete.asKnown().isPresent) 1 else 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (if (reportDate.asKnown().isPresent) 1 else 0) + + (if (settlementInstitutionId.asKnown().isPresent) 1 else 0) + + (if (settlementService.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (cycle.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 NETWORK_TOTAL_CREATED = of("network_total.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + NETWORK_TOTAL_CREATED + } + + /** + * 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 { + NETWORK_TOTAL_CREATED, + /** + * 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) { + NETWORK_TOTAL_CREATED -> Value.NETWORK_TOTAL_CREATED + 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) { + NETWORK_TOTAL_CREATED -> Known.NETWORK_TOTAL_CREATED + 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 + + 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 NetworkTotalCreatedWebhookEvent && + token == other.token && + amounts == other.amounts && + created == other.created && + currency == other.currency && + institutionId == other.institutionId && + isComplete == other.isComplete && + network == other.network && + reportDate == other.reportDate && + settlementInstitutionId == other.settlementInstitutionId && + settlementService == other.settlementService && + updated == other.updated && + cycle == other.cycle && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + amounts, + created, + currency, + institutionId, + isComplete, + network, + reportDate, + settlementInstitutionId, + settlementService, + updated, + cycle, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NetworkTotalCreatedWebhookEvent{token=$token, amounts=$amounts, created=$created, currency=$currency, institutionId=$institutionId, isComplete=$isComplete, network=$network, reportDate=$reportDate, settlementInstitutionId=$settlementInstitutionId, settlementService=$settlementService, updated=$updated, cycle=$cycle, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalUpdatedWebhookEvent.kt new file mode 100644 index 000000000..014bc0206 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/NetworkTotalUpdatedWebhookEvent.kt @@ -0,0 +1,849 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NetworkTotalUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val amounts: JsonField, + private val created: JsonField, + private val currency: JsonField, + private val institutionId: JsonField, + private val isComplete: JsonField, + private val network: JsonField, + private val reportDate: JsonField, + private val settlementInstitutionId: JsonField, + private val settlementService: JsonField, + private val updated: JsonField, + private val cycle: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("amounts") + @ExcludeMissing + amounts: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("institution_id") + @ExcludeMissing + institutionId: JsonField = JsonMissing.of(), + @JsonProperty("is_complete") + @ExcludeMissing + isComplete: JsonField = JsonMissing.of(), + @JsonProperty("network") + @ExcludeMissing + network: JsonField = JsonMissing.of(), + @JsonProperty("report_date") + @ExcludeMissing + reportDate: JsonField = JsonMissing.of(), + @JsonProperty("settlement_institution_id") + @ExcludeMissing + settlementInstitutionId: JsonField = JsonMissing.of(), + @JsonProperty("settlement_service") + @ExcludeMissing + settlementService: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("cycle") @ExcludeMissing cycle: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + amounts, + created, + currency, + institutionId, + isComplete, + network, + reportDate, + settlementInstitutionId, + settlementService, + updated, + cycle, + eventType, + mutableMapOf(), + ) + + fun toNetworkTotal(): NetworkTotal = + NetworkTotal.builder() + .token(token) + .amounts(amounts) + .created(created) + .currency(currency) + .institutionId(institutionId) + .isComplete(isComplete) + .network(network) + .reportDate(reportDate) + .settlementInstitutionId(settlementInstitutionId) + .settlementService(settlementService) + .updated(updated) + .cycle(cycle) + .build() + + /** + * Globally unique identifier. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if 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(): NetworkTotal.Amounts = amounts.getRequired("amounts") + + /** + * RFC 3339 timestamp for when the record was created. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * 3-character alphabetic ISO 4217 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 currency(): String = currency.getRequired("currency") + + /** + * The institution that activity occurred on. For Mastercard: ICA (Interbank Card Association). + * For Maestro: institution ID. For Visa: lowest level SRE (Settlement Reporting Entity). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun institutionId(): String = institutionId.getRequired("institution_id") + + /** + * Indicates that all settlement records related to this Network Total are available in the + * details 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 isComplete(): Boolean = isComplete.getRequired("is_complete") + + /** + * Card network where the transaction took place. AMEX, VISA, MASTERCARD, MAESTRO, or INTERLINK. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): NetworkTotal.Network = network.getRequired("network") + + /** + * Date that the network total record applies to. YYYY-MM-DD format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun reportDate(): LocalDate = reportDate.getRequired("report_date") + + /** + * The institution responsible for settlement. For Mastercard: same as `institution_id`. For + * Maestro: billing ICA. For Visa: Funds Transfer SRE (FTSRE). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settlementInstitutionId(): String = + settlementInstitutionId.getRequired("settlement_institution_id") + + /** + * Settlement service. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settlementService(): String = settlementService.getRequired("settlement_service") + + /** + * RFC 3339 timestamp for when the record was last updated. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * The clearing cycle that the network total record applies to. Mastercard only. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cycle(): Optional = cycle.getOptional("cycle") + + /** + * 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 [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 [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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [institutionId]. + * + * Unlike [institutionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("institution_id") + @ExcludeMissing + fun _institutionId(): JsonField = institutionId + + /** + * Returns the raw JSON value of [isComplete]. + * + * Unlike [isComplete], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_complete") @ExcludeMissing fun _isComplete(): JsonField = isComplete + + /** + * 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 [reportDate]. + * + * Unlike [reportDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("report_date") + @ExcludeMissing + fun _reportDate(): JsonField = reportDate + + /** + * Returns the raw JSON value of [settlementInstitutionId]. + * + * Unlike [settlementInstitutionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("settlement_institution_id") + @ExcludeMissing + fun _settlementInstitutionId(): JsonField = settlementInstitutionId + + /** + * Returns the raw JSON value of [settlementService]. + * + * Unlike [settlementService], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("settlement_service") + @ExcludeMissing + fun _settlementService(): JsonField = settlementService + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [cycle]. + * + * Unlike [cycle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cycle") @ExcludeMissing fun _cycle(): JsonField = cycle + + /** + * 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 + * [NetworkTotalUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .amounts() + * .created() + * .currency() + * .institutionId() + * .isComplete() + * .network() + * .reportDate() + * .settlementInstitutionId() + * .settlementService() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkTotalUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var amounts: JsonField? = null + private var created: JsonField? = null + private var currency: JsonField? = null + private var institutionId: JsonField? = null + private var isComplete: JsonField? = null + private var network: JsonField? = null + private var reportDate: JsonField? = null + private var settlementInstitutionId: JsonField? = null + private var settlementService: JsonField? = null + private var updated: JsonField? = null + private var cycle: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(networkTotalUpdatedWebhookEvent: NetworkTotalUpdatedWebhookEvent) = + apply { + token = networkTotalUpdatedWebhookEvent.token + amounts = networkTotalUpdatedWebhookEvent.amounts + created = networkTotalUpdatedWebhookEvent.created + currency = networkTotalUpdatedWebhookEvent.currency + institutionId = networkTotalUpdatedWebhookEvent.institutionId + isComplete = networkTotalUpdatedWebhookEvent.isComplete + network = networkTotalUpdatedWebhookEvent.network + reportDate = networkTotalUpdatedWebhookEvent.reportDate + settlementInstitutionId = networkTotalUpdatedWebhookEvent.settlementInstitutionId + settlementService = networkTotalUpdatedWebhookEvent.settlementService + updated = networkTotalUpdatedWebhookEvent.updated + cycle = networkTotalUpdatedWebhookEvent.cycle + eventType = networkTotalUpdatedWebhookEvent.eventType + additionalProperties = + networkTotalUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun amounts(amounts: NetworkTotal.Amounts) = amounts(JsonField.of(amounts)) + + /** + * Sets [Builder.amounts] to an arbitrary JSON value. + * + * You should usually call [Builder.amounts] with a well-typed [NetworkTotal.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 } + + /** RFC 3339 timestamp for when the record was created. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** 3-character alphabetic ISO 4217 code. */ + 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 } + + /** + * The institution that activity occurred on. For Mastercard: ICA (Interbank Card + * Association). For Maestro: institution ID. For Visa: lowest level SRE (Settlement + * Reporting Entity). + */ + fun institutionId(institutionId: String) = institutionId(JsonField.of(institutionId)) + + /** + * Sets [Builder.institutionId] to an arbitrary JSON value. + * + * You should usually call [Builder.institutionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun institutionId(institutionId: JsonField) = apply { + this.institutionId = institutionId + } + + /** + * Indicates that all settlement records related to this Network Total are available in the + * details endpoint. + */ + fun isComplete(isComplete: Boolean) = isComplete(JsonField.of(isComplete)) + + /** + * Sets [Builder.isComplete] to an arbitrary JSON value. + * + * You should usually call [Builder.isComplete] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isComplete(isComplete: JsonField) = apply { this.isComplete = isComplete } + + /** + * Card network where the transaction took place. AMEX, VISA, MASTERCARD, MAESTRO, or + * INTERLINK. + */ + fun network(network: NetworkTotal.Network) = network(JsonField.of(network)) + + /** + * Sets [Builder.network] to an arbitrary JSON value. + * + * You should usually call [Builder.network] with a well-typed [NetworkTotal.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 } + + /** Date that the network total record applies to. YYYY-MM-DD format. */ + fun reportDate(reportDate: LocalDate) = reportDate(JsonField.of(reportDate)) + + /** + * Sets [Builder.reportDate] to an arbitrary JSON value. + * + * You should usually call [Builder.reportDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reportDate(reportDate: JsonField) = apply { this.reportDate = reportDate } + + /** + * The institution responsible for settlement. For Mastercard: same as `institution_id`. For + * Maestro: billing ICA. For Visa: Funds Transfer SRE (FTSRE). + */ + fun settlementInstitutionId(settlementInstitutionId: String) = + settlementInstitutionId(JsonField.of(settlementInstitutionId)) + + /** + * Sets [Builder.settlementInstitutionId] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementInstitutionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun settlementInstitutionId(settlementInstitutionId: JsonField) = apply { + this.settlementInstitutionId = settlementInstitutionId + } + + /** Settlement service. */ + fun settlementService(settlementService: String) = + settlementService(JsonField.of(settlementService)) + + /** + * Sets [Builder.settlementService] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementService] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settlementService(settlementService: JsonField) = apply { + this.settlementService = settlementService + } + + /** RFC 3339 timestamp for when the record was last updated. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** The clearing cycle that the network total record applies to. Mastercard only. */ + fun cycle(cycle: Long) = cycle(JsonField.of(cycle)) + + /** + * Sets [Builder.cycle] to an arbitrary JSON value. + * + * You should usually call [Builder.cycle] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cycle(cycle: JsonField) = apply { this.cycle = cycle } + + /** 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 [NetworkTotalUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .amounts() + * .created() + * .currency() + * .institutionId() + * .isComplete() + * .network() + * .reportDate() + * .settlementInstitutionId() + * .settlementService() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkTotalUpdatedWebhookEvent = + NetworkTotalUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("amounts", amounts), + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("institutionId", institutionId), + checkRequired("isComplete", isComplete), + checkRequired("network", network), + checkRequired("reportDate", reportDate), + checkRequired("settlementInstitutionId", settlementInstitutionId), + checkRequired("settlementService", settlementService), + checkRequired("updated", updated), + cycle, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NetworkTotalUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + amounts().validate() + created() + currency() + institutionId() + isComplete() + network().validate() + reportDate() + settlementInstitutionId() + settlementService() + updated() + cycle() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (amounts.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (institutionId.asKnown().isPresent) 1 else 0) + + (if (isComplete.asKnown().isPresent) 1 else 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (if (reportDate.asKnown().isPresent) 1 else 0) + + (if (settlementInstitutionId.asKnown().isPresent) 1 else 0) + + (if (settlementService.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (cycle.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 NETWORK_TOTAL_UPDATED = of("network_total.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + NETWORK_TOTAL_UPDATED + } + + /** + * 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 { + NETWORK_TOTAL_UPDATED, + /** + * 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) { + NETWORK_TOTAL_UPDATED -> Value.NETWORK_TOTAL_UPDATED + 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) { + NETWORK_TOTAL_UPDATED -> Known.NETWORK_TOTAL_UPDATED + 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 + + 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 NetworkTotalUpdatedWebhookEvent && + token == other.token && + amounts == other.amounts && + created == other.created && + currency == other.currency && + institutionId == other.institutionId && + isComplete == other.isComplete && + network == other.network && + reportDate == other.reportDate && + settlementInstitutionId == other.settlementInstitutionId && + settlementService == other.settlementService && + updated == other.updated && + cycle == other.cycle && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + amounts, + created, + currency, + institutionId, + isComplete, + network, + reportDate, + settlementInstitutionId, + settlementService, + updated, + cycle, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NetworkTotalUpdatedWebhookEvent{token=$token, amounts=$amounts, created=$created, currency=$currency, institutionId=$institutionId, isComplete=$isComplete, network=$network, reportDate=$reportDate, settlementInstitutionId=$settlementInstitutionId, settlementService=$settlementService, updated=$updated, cycle=$cycle, eventType=$eventType, additionalProperties=$additionalProperties}" +} 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 new file mode 100644 index 000000000..1c42792eb --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ParsedWebhookEvent.kt @@ -0,0 +1,6407 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.allMaxBy +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.getOrThrow +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** KYB payload for an updated account holder. */ +@JsonDeserialize(using = ParsedWebhookEvent.Deserializer::class) +@JsonSerialize(using = ParsedWebhookEvent.Serializer::class) +class ParsedWebhookEvent +private constructor( + private val accountHolderCreated: AccountHolderCreatedWebhookEvent? = null, + private val kybPayload: KybPayload? = null, + private val kycPayload: KycPayload? = null, + private val legacyPayload: LegacyPayload? = null, + private val accountHolderVerification: AccountHolderVerificationWebhookEvent? = null, + private val accountHolderDocumentUpdated: AccountHolderDocumentUpdatedWebhookEvent? = null, + private val asaRequest: AsaRequestWebhookEvent? = null, + private val tokenizationDecisioningRequest: TokenizationDecisioningRequestWebhookEvent? = null, + private val authRulesBacktestReportCreated: AuthRulesBacktestReportCreatedWebhookEvent? = null, + private val balanceUpdated: BalanceUpdatedWebhookEvent? = null, + private val bookTransferTransactionCreated: BookTransferTransactionCreatedWebhookEvent? = null, + private val bookTransferTransactionUpdated: BookTransferTransactionUpdatedWebhookEvent? = null, + private val cardCreated: CardCreatedWebhookEvent? = null, + private val cardConverted: CardConvertedWebhookEvent? = null, + private val cardRenewed: CardRenewedWebhookEvent? = null, + private val cardReissued: CardReissuedWebhookEvent? = null, + private val cardShipped: CardShippedWebhookEvent? = null, + private val cardTransactionUpdated: CardTransactionUpdatedWebhookEvent? = null, + private val cardTransactionEnhancedDataCreated: + CardTransactionEnhancedDataCreatedWebhookEvent? = + null, + private val cardTransactionEnhancedDataUpdated: + CardTransactionEnhancedDataUpdatedWebhookEvent? = + null, + private val digitalWalletTokenizationApprovalRequest: + DigitalWalletTokenizationApprovalRequestWebhookEvent? = + null, + private val digitalWalletTokenizationResult: DigitalWalletTokenizationResultWebhookEvent? = + null, + private val digitalWalletTokenizationTwoFactorAuthenticationCode: + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent? = + null, + private val digitalWalletTokenizationTwoFactorAuthenticationCodeSent: + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent? = + null, + private val digitalWalletTokenizationUpdated: DigitalWalletTokenizationUpdatedWebhookEvent? = + null, + private val disputeUpdated: DisputeUpdatedWebhookEvent? = null, + private val disputeEvidenceUploadFailed: DisputeEvidenceUploadFailedWebhookEvent? = null, + private val externalBankAccountCreated: ExternalBankAccountCreatedWebhookEvent? = null, + private val externalBankAccountUpdated: ExternalBankAccountUpdatedWebhookEvent? = null, + private val externalPaymentCreated: ExternalPaymentCreatedWebhookEvent? = null, + private val externalPaymentUpdated: ExternalPaymentUpdatedWebhookEvent? = null, + private val financialAccountCreated: FinancialAccountCreatedWebhookEvent? = null, + private val financialAccountUpdated: FinancialAccountUpdatedWebhookEvent? = null, + private val fundingEventCreated: FundingEventCreatedWebhookEvent? = null, + private val loanTapeCreated: LoanTapeCreatedWebhookEvent? = null, + private val loanTapeUpdated: LoanTapeUpdatedWebhookEvent? = null, + private val managementOperationCreated: ManagementOperationCreatedWebhookEvent? = null, + private val managementOperationUpdated: ManagementOperationUpdatedWebhookEvent? = null, + private val internalTransactionCreated: InternalTransactionCreatedWebhookEvent? = null, + private val internalTransactionUpdated: InternalTransactionUpdatedWebhookEvent? = null, + private val networkTotalCreated: NetworkTotalCreatedWebhookEvent? = null, + private val networkTotalUpdated: NetworkTotalUpdatedWebhookEvent? = null, + private val paymentTransactionCreated: PaymentTransactionCreatedWebhookEvent? = null, + private val paymentTransactionUpdated: PaymentTransactionUpdatedWebhookEvent? = null, + private val settlementReportUpdated: SettlementReportUpdatedWebhookEvent? = null, + private val statementsCreated: StatementsCreatedWebhookEvent? = null, + private val threeDSAuthenticationCreated: ThreeDSAuthenticationCreatedWebhookEvent? = null, + private val threeDSAuthenticationUpdated: ThreeDSAuthenticationUpdatedWebhookEvent? = null, + private val threeDSAuthenticationChallenge: ThreeDSAuthenticationChallengeWebhookEvent? = null, + private val tokenizationApprovalRequest: TokenizationApprovalRequestWebhookEvent? = null, + private val tokenizationResult: TokenizationResultWebhookEvent? = null, + private val tokenizationTwoFactorAuthenticationCode: + TokenizationTwoFactorAuthenticationCodeWebhookEvent? = + null, + private val tokenizationTwoFactorAuthenticationCodeSent: + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent? = + null, + private val tokenizationUpdated: TokenizationUpdatedWebhookEvent? = null, + private val threeDSAuthentication: ThreeDSAuthentication? = null, + private val disputeTransactionCreated: DisputeTransactionCreatedWebhookEvent? = null, + private val disputeTransactionUpdated: DisputeTransactionUpdatedWebhookEvent? = null, + private val _json: JsonValue? = null, +) { + + fun accountHolderCreated(): Optional = + Optional.ofNullable(accountHolderCreated) + + /** KYB payload for an updated account holder. */ + fun kybPayload(): Optional = Optional.ofNullable(kybPayload) + + /** KYC payload for an updated account holder. */ + fun kycPayload(): Optional = Optional.ofNullable(kycPayload) + + /** Legacy payload for an updated account holder. */ + fun legacyPayload(): Optional = Optional.ofNullable(legacyPayload) + + fun accountHolderVerification(): Optional = + Optional.ofNullable(accountHolderVerification) + + fun accountHolderDocumentUpdated(): Optional = + Optional.ofNullable(accountHolderDocumentUpdated) + + /** The Auth Stream Access request payload that was sent to the ASA responder. */ + fun asaRequest(): Optional = Optional.ofNullable(asaRequest) + + /** A webhook for tokenization decisioning sent to the customer's responder endpoint */ + fun tokenizationDecisioningRequest(): Optional = + Optional.ofNullable(tokenizationDecisioningRequest) + + fun authRulesBacktestReportCreated(): Optional = + Optional.ofNullable(authRulesBacktestReportCreated) + + fun balanceUpdated(): Optional = Optional.ofNullable(balanceUpdated) + + /** Book transfer transaction */ + fun bookTransferTransactionCreated(): Optional = + Optional.ofNullable(bookTransferTransactionCreated) + + /** Book transfer transaction */ + fun bookTransferTransactionUpdated(): Optional = + Optional.ofNullable(bookTransferTransactionUpdated) + + fun cardCreated(): Optional = Optional.ofNullable(cardCreated) + + fun cardConverted(): Optional = Optional.ofNullable(cardConverted) + + fun cardRenewed(): Optional = Optional.ofNullable(cardRenewed) + + fun cardReissued(): Optional = Optional.ofNullable(cardReissued) + + fun cardShipped(): Optional = Optional.ofNullable(cardShipped) + + fun cardTransactionUpdated(): Optional = + Optional.ofNullable(cardTransactionUpdated) + + fun cardTransactionEnhancedDataCreated(): + Optional = + Optional.ofNullable(cardTransactionEnhancedDataCreated) + + fun cardTransactionEnhancedDataUpdated(): + Optional = + Optional.ofNullable(cardTransactionEnhancedDataUpdated) + + fun digitalWalletTokenizationApprovalRequest(): + Optional = + Optional.ofNullable(digitalWalletTokenizationApprovalRequest) + + fun digitalWalletTokenizationResult(): Optional = + Optional.ofNullable(digitalWalletTokenizationResult) + + fun digitalWalletTokenizationTwoFactorAuthenticationCode(): + Optional = + Optional.ofNullable(digitalWalletTokenizationTwoFactorAuthenticationCode) + + fun digitalWalletTokenizationTwoFactorAuthenticationCodeSent(): + Optional = + Optional.ofNullable(digitalWalletTokenizationTwoFactorAuthenticationCodeSent) + + fun digitalWalletTokenizationUpdated(): Optional = + Optional.ofNullable(digitalWalletTokenizationUpdated) + + /** Dispute. */ + fun disputeUpdated(): Optional = Optional.ofNullable(disputeUpdated) + + /** Dispute evidence. */ + fun disputeEvidenceUploadFailed(): Optional = + Optional.ofNullable(disputeEvidenceUploadFailed) + + fun externalBankAccountCreated(): Optional = + Optional.ofNullable(externalBankAccountCreated) + + fun externalBankAccountUpdated(): Optional = + Optional.ofNullable(externalBankAccountUpdated) + + fun externalPaymentCreated(): Optional = + Optional.ofNullable(externalPaymentCreated) + + fun externalPaymentUpdated(): Optional = + Optional.ofNullable(externalPaymentUpdated) + + fun financialAccountCreated(): Optional = + Optional.ofNullable(financialAccountCreated) + + fun financialAccountUpdated(): Optional = + Optional.ofNullable(financialAccountUpdated) + + fun fundingEventCreated(): Optional = + Optional.ofNullable(fundingEventCreated) + + fun loanTapeCreated(): Optional = + Optional.ofNullable(loanTapeCreated) + + fun loanTapeUpdated(): Optional = + Optional.ofNullable(loanTapeUpdated) + + fun managementOperationCreated(): Optional = + Optional.ofNullable(managementOperationCreated) + + fun managementOperationUpdated(): Optional = + Optional.ofNullable(managementOperationUpdated) + + fun internalTransactionCreated(): Optional = + Optional.ofNullable(internalTransactionCreated) + + fun internalTransactionUpdated(): Optional = + Optional.ofNullable(internalTransactionUpdated) + + fun networkTotalCreated(): Optional = + Optional.ofNullable(networkTotalCreated) + + fun networkTotalUpdated(): Optional = + Optional.ofNullable(networkTotalUpdated) + + /** Payment transaction */ + fun paymentTransactionCreated(): Optional = + Optional.ofNullable(paymentTransactionCreated) + + /** Payment transaction */ + fun paymentTransactionUpdated(): Optional = + Optional.ofNullable(paymentTransactionUpdated) + + fun settlementReportUpdated(): Optional = + Optional.ofNullable(settlementReportUpdated) + + fun statementsCreated(): Optional = + Optional.ofNullable(statementsCreated) + + /** Represents a 3DS authentication */ + fun threeDSAuthenticationCreated(): Optional = + Optional.ofNullable(threeDSAuthenticationCreated) + + /** Represents a 3DS authentication */ + fun threeDSAuthenticationUpdated(): Optional = + Optional.ofNullable(threeDSAuthenticationUpdated) + + fun threeDSAuthenticationChallenge(): Optional = + Optional.ofNullable(threeDSAuthenticationChallenge) + + fun tokenizationApprovalRequest(): Optional = + Optional.ofNullable(tokenizationApprovalRequest) + + fun tokenizationResult(): Optional = + Optional.ofNullable(tokenizationResult) + + fun tokenizationTwoFactorAuthenticationCode(): + Optional = + Optional.ofNullable(tokenizationTwoFactorAuthenticationCode) + + fun tokenizationTwoFactorAuthenticationCodeSent(): + Optional = + Optional.ofNullable(tokenizationTwoFactorAuthenticationCodeSent) + + fun tokenizationUpdated(): Optional = + Optional.ofNullable(tokenizationUpdated) + + /** Represents a 3DS authentication */ + fun threeDSAuthentication(): Optional = + Optional.ofNullable(threeDSAuthentication) + + /** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ + fun disputeTransactionCreated(): Optional = + Optional.ofNullable(disputeTransactionCreated) + + /** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ + fun disputeTransactionUpdated(): Optional = + Optional.ofNullable(disputeTransactionUpdated) + + fun isAccountHolderCreated(): Boolean = accountHolderCreated != null + + fun isKybPayload(): Boolean = kybPayload != null + + fun isKycPayload(): Boolean = kycPayload != null + + fun isLegacyPayload(): Boolean = legacyPayload != null + + fun isAccountHolderVerification(): Boolean = accountHolderVerification != null + + fun isAccountHolderDocumentUpdated(): Boolean = accountHolderDocumentUpdated != null + + fun isAsaRequest(): Boolean = asaRequest != null + + fun isTokenizationDecisioningRequest(): Boolean = tokenizationDecisioningRequest != null + + fun isAuthRulesBacktestReportCreated(): Boolean = authRulesBacktestReportCreated != null + + fun isBalanceUpdated(): Boolean = balanceUpdated != null + + fun isBookTransferTransactionCreated(): Boolean = bookTransferTransactionCreated != null + + fun isBookTransferTransactionUpdated(): Boolean = bookTransferTransactionUpdated != null + + fun isCardCreated(): Boolean = cardCreated != null + + fun isCardConverted(): Boolean = cardConverted != null + + fun isCardRenewed(): Boolean = cardRenewed != null + + fun isCardReissued(): Boolean = cardReissued != null + + fun isCardShipped(): Boolean = cardShipped != null + + fun isCardTransactionUpdated(): Boolean = cardTransactionUpdated != null + + fun isCardTransactionEnhancedDataCreated(): Boolean = cardTransactionEnhancedDataCreated != null + + fun isCardTransactionEnhancedDataUpdated(): Boolean = cardTransactionEnhancedDataUpdated != null + + fun isDigitalWalletTokenizationApprovalRequest(): Boolean = + digitalWalletTokenizationApprovalRequest != null + + fun isDigitalWalletTokenizationResult(): Boolean = digitalWalletTokenizationResult != null + + fun isDigitalWalletTokenizationTwoFactorAuthenticationCode(): Boolean = + digitalWalletTokenizationTwoFactorAuthenticationCode != null + + fun isDigitalWalletTokenizationTwoFactorAuthenticationCodeSent(): Boolean = + digitalWalletTokenizationTwoFactorAuthenticationCodeSent != null + + fun isDigitalWalletTokenizationUpdated(): Boolean = digitalWalletTokenizationUpdated != null + + fun isDisputeUpdated(): Boolean = disputeUpdated != null + + fun isDisputeEvidenceUploadFailed(): Boolean = disputeEvidenceUploadFailed != null + + fun isExternalBankAccountCreated(): Boolean = externalBankAccountCreated != null + + fun isExternalBankAccountUpdated(): Boolean = externalBankAccountUpdated != null + + fun isExternalPaymentCreated(): Boolean = externalPaymentCreated != null + + fun isExternalPaymentUpdated(): Boolean = externalPaymentUpdated != null + + fun isFinancialAccountCreated(): Boolean = financialAccountCreated != null + + fun isFinancialAccountUpdated(): Boolean = financialAccountUpdated != null + + fun isFundingEventCreated(): Boolean = fundingEventCreated != null + + fun isLoanTapeCreated(): Boolean = loanTapeCreated != null + + fun isLoanTapeUpdated(): Boolean = loanTapeUpdated != null + + fun isManagementOperationCreated(): Boolean = managementOperationCreated != null + + fun isManagementOperationUpdated(): Boolean = managementOperationUpdated != null + + fun isInternalTransactionCreated(): Boolean = internalTransactionCreated != null + + fun isInternalTransactionUpdated(): Boolean = internalTransactionUpdated != null + + fun isNetworkTotalCreated(): Boolean = networkTotalCreated != null + + fun isNetworkTotalUpdated(): Boolean = networkTotalUpdated != null + + fun isPaymentTransactionCreated(): Boolean = paymentTransactionCreated != null + + fun isPaymentTransactionUpdated(): Boolean = paymentTransactionUpdated != null + + fun isSettlementReportUpdated(): Boolean = settlementReportUpdated != null + + fun isStatementsCreated(): Boolean = statementsCreated != null + + fun isThreeDSAuthenticationCreated(): Boolean = threeDSAuthenticationCreated != null + + fun isThreeDSAuthenticationUpdated(): Boolean = threeDSAuthenticationUpdated != null + + fun isThreeDSAuthenticationChallenge(): Boolean = threeDSAuthenticationChallenge != null + + fun isTokenizationApprovalRequest(): Boolean = tokenizationApprovalRequest != null + + fun isTokenizationResult(): Boolean = tokenizationResult != null + + fun isTokenizationTwoFactorAuthenticationCode(): Boolean = + tokenizationTwoFactorAuthenticationCode != null + + fun isTokenizationTwoFactorAuthenticationCodeSent(): Boolean = + tokenizationTwoFactorAuthenticationCodeSent != null + + fun isTokenizationUpdated(): Boolean = tokenizationUpdated != null + + fun isThreeDSAuthentication(): Boolean = threeDSAuthentication != null + + fun isDisputeTransactionCreated(): Boolean = disputeTransactionCreated != null + + fun isDisputeTransactionUpdated(): Boolean = disputeTransactionUpdated != null + + fun asAccountHolderCreated(): AccountHolderCreatedWebhookEvent = + accountHolderCreated.getOrThrow("accountHolderCreated") + + /** KYB payload for an updated account holder. */ + fun asKybPayload(): KybPayload = kybPayload.getOrThrow("kybPayload") + + /** KYC payload for an updated account holder. */ + fun asKycPayload(): KycPayload = kycPayload.getOrThrow("kycPayload") + + /** Legacy payload for an updated account holder. */ + fun asLegacyPayload(): LegacyPayload = legacyPayload.getOrThrow("legacyPayload") + + fun asAccountHolderVerification(): AccountHolderVerificationWebhookEvent = + accountHolderVerification.getOrThrow("accountHolderVerification") + + fun asAccountHolderDocumentUpdated(): AccountHolderDocumentUpdatedWebhookEvent = + accountHolderDocumentUpdated.getOrThrow("accountHolderDocumentUpdated") + + /** The Auth Stream Access request payload that was sent to the ASA responder. */ + fun asAsaRequest(): AsaRequestWebhookEvent = asaRequest.getOrThrow("asaRequest") + + /** A webhook for tokenization decisioning sent to the customer's responder endpoint */ + fun asTokenizationDecisioningRequest(): TokenizationDecisioningRequestWebhookEvent = + tokenizationDecisioningRequest.getOrThrow("tokenizationDecisioningRequest") + + fun asAuthRulesBacktestReportCreated(): AuthRulesBacktestReportCreatedWebhookEvent = + authRulesBacktestReportCreated.getOrThrow("authRulesBacktestReportCreated") + + fun asBalanceUpdated(): BalanceUpdatedWebhookEvent = balanceUpdated.getOrThrow("balanceUpdated") + + /** Book transfer transaction */ + fun asBookTransferTransactionCreated(): BookTransferTransactionCreatedWebhookEvent = + bookTransferTransactionCreated.getOrThrow("bookTransferTransactionCreated") + + /** Book transfer transaction */ + fun asBookTransferTransactionUpdated(): BookTransferTransactionUpdatedWebhookEvent = + bookTransferTransactionUpdated.getOrThrow("bookTransferTransactionUpdated") + + fun asCardCreated(): CardCreatedWebhookEvent = cardCreated.getOrThrow("cardCreated") + + fun asCardConverted(): CardConvertedWebhookEvent = cardConverted.getOrThrow("cardConverted") + + fun asCardRenewed(): CardRenewedWebhookEvent = cardRenewed.getOrThrow("cardRenewed") + + fun asCardReissued(): CardReissuedWebhookEvent = cardReissued.getOrThrow("cardReissued") + + fun asCardShipped(): CardShippedWebhookEvent = cardShipped.getOrThrow("cardShipped") + + fun asCardTransactionUpdated(): CardTransactionUpdatedWebhookEvent = + cardTransactionUpdated.getOrThrow("cardTransactionUpdated") + + fun asCardTransactionEnhancedDataCreated(): CardTransactionEnhancedDataCreatedWebhookEvent = + cardTransactionEnhancedDataCreated.getOrThrow("cardTransactionEnhancedDataCreated") + + fun asCardTransactionEnhancedDataUpdated(): CardTransactionEnhancedDataUpdatedWebhookEvent = + cardTransactionEnhancedDataUpdated.getOrThrow("cardTransactionEnhancedDataUpdated") + + fun asDigitalWalletTokenizationApprovalRequest(): + DigitalWalletTokenizationApprovalRequestWebhookEvent = + digitalWalletTokenizationApprovalRequest.getOrThrow( + "digitalWalletTokenizationApprovalRequest" + ) + + fun asDigitalWalletTokenizationResult(): DigitalWalletTokenizationResultWebhookEvent = + digitalWalletTokenizationResult.getOrThrow("digitalWalletTokenizationResult") + + fun asDigitalWalletTokenizationTwoFactorAuthenticationCode(): + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent = + digitalWalletTokenizationTwoFactorAuthenticationCode.getOrThrow( + "digitalWalletTokenizationTwoFactorAuthenticationCode" + ) + + fun asDigitalWalletTokenizationTwoFactorAuthenticationCodeSent(): + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + digitalWalletTokenizationTwoFactorAuthenticationCodeSent.getOrThrow( + "digitalWalletTokenizationTwoFactorAuthenticationCodeSent" + ) + + fun asDigitalWalletTokenizationUpdated(): DigitalWalletTokenizationUpdatedWebhookEvent = + digitalWalletTokenizationUpdated.getOrThrow("digitalWalletTokenizationUpdated") + + /** Dispute. */ + fun asDisputeUpdated(): DisputeUpdatedWebhookEvent = disputeUpdated.getOrThrow("disputeUpdated") + + /** Dispute evidence. */ + fun asDisputeEvidenceUploadFailed(): DisputeEvidenceUploadFailedWebhookEvent = + disputeEvidenceUploadFailed.getOrThrow("disputeEvidenceUploadFailed") + + fun asExternalBankAccountCreated(): ExternalBankAccountCreatedWebhookEvent = + externalBankAccountCreated.getOrThrow("externalBankAccountCreated") + + fun asExternalBankAccountUpdated(): ExternalBankAccountUpdatedWebhookEvent = + externalBankAccountUpdated.getOrThrow("externalBankAccountUpdated") + + fun asExternalPaymentCreated(): ExternalPaymentCreatedWebhookEvent = + externalPaymentCreated.getOrThrow("externalPaymentCreated") + + fun asExternalPaymentUpdated(): ExternalPaymentUpdatedWebhookEvent = + externalPaymentUpdated.getOrThrow("externalPaymentUpdated") + + fun asFinancialAccountCreated(): FinancialAccountCreatedWebhookEvent = + financialAccountCreated.getOrThrow("financialAccountCreated") + + fun asFinancialAccountUpdated(): FinancialAccountUpdatedWebhookEvent = + financialAccountUpdated.getOrThrow("financialAccountUpdated") + + fun asFundingEventCreated(): FundingEventCreatedWebhookEvent = + fundingEventCreated.getOrThrow("fundingEventCreated") + + fun asLoanTapeCreated(): LoanTapeCreatedWebhookEvent = + loanTapeCreated.getOrThrow("loanTapeCreated") + + fun asLoanTapeUpdated(): LoanTapeUpdatedWebhookEvent = + loanTapeUpdated.getOrThrow("loanTapeUpdated") + + fun asManagementOperationCreated(): ManagementOperationCreatedWebhookEvent = + managementOperationCreated.getOrThrow("managementOperationCreated") + + fun asManagementOperationUpdated(): ManagementOperationUpdatedWebhookEvent = + managementOperationUpdated.getOrThrow("managementOperationUpdated") + + fun asInternalTransactionCreated(): InternalTransactionCreatedWebhookEvent = + internalTransactionCreated.getOrThrow("internalTransactionCreated") + + fun asInternalTransactionUpdated(): InternalTransactionUpdatedWebhookEvent = + internalTransactionUpdated.getOrThrow("internalTransactionUpdated") + + fun asNetworkTotalCreated(): NetworkTotalCreatedWebhookEvent = + networkTotalCreated.getOrThrow("networkTotalCreated") + + fun asNetworkTotalUpdated(): NetworkTotalUpdatedWebhookEvent = + networkTotalUpdated.getOrThrow("networkTotalUpdated") + + /** Payment transaction */ + fun asPaymentTransactionCreated(): PaymentTransactionCreatedWebhookEvent = + paymentTransactionCreated.getOrThrow("paymentTransactionCreated") + + /** Payment transaction */ + fun asPaymentTransactionUpdated(): PaymentTransactionUpdatedWebhookEvent = + paymentTransactionUpdated.getOrThrow("paymentTransactionUpdated") + + fun asSettlementReportUpdated(): SettlementReportUpdatedWebhookEvent = + settlementReportUpdated.getOrThrow("settlementReportUpdated") + + fun asStatementsCreated(): StatementsCreatedWebhookEvent = + statementsCreated.getOrThrow("statementsCreated") + + /** Represents a 3DS authentication */ + fun asThreeDSAuthenticationCreated(): ThreeDSAuthenticationCreatedWebhookEvent = + threeDSAuthenticationCreated.getOrThrow("threeDSAuthenticationCreated") + + /** Represents a 3DS authentication */ + fun asThreeDSAuthenticationUpdated(): ThreeDSAuthenticationUpdatedWebhookEvent = + threeDSAuthenticationUpdated.getOrThrow("threeDSAuthenticationUpdated") + + fun asThreeDSAuthenticationChallenge(): ThreeDSAuthenticationChallengeWebhookEvent = + threeDSAuthenticationChallenge.getOrThrow("threeDSAuthenticationChallenge") + + fun asTokenizationApprovalRequest(): TokenizationApprovalRequestWebhookEvent = + tokenizationApprovalRequest.getOrThrow("tokenizationApprovalRequest") + + fun asTokenizationResult(): TokenizationResultWebhookEvent = + tokenizationResult.getOrThrow("tokenizationResult") + + fun asTokenizationTwoFactorAuthenticationCode(): + TokenizationTwoFactorAuthenticationCodeWebhookEvent = + tokenizationTwoFactorAuthenticationCode.getOrThrow( + "tokenizationTwoFactorAuthenticationCode" + ) + + fun asTokenizationTwoFactorAuthenticationCodeSent(): + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + tokenizationTwoFactorAuthenticationCodeSent.getOrThrow( + "tokenizationTwoFactorAuthenticationCodeSent" + ) + + fun asTokenizationUpdated(): TokenizationUpdatedWebhookEvent = + tokenizationUpdated.getOrThrow("tokenizationUpdated") + + /** Represents a 3DS authentication */ + fun asThreeDSAuthentication(): ThreeDSAuthentication = + threeDSAuthentication.getOrThrow("threeDSAuthentication") + + /** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ + fun asDisputeTransactionCreated(): DisputeTransactionCreatedWebhookEvent = + disputeTransactionCreated.getOrThrow("disputeTransactionCreated") + + /** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ + fun asDisputeTransactionUpdated(): DisputeTransactionUpdatedWebhookEvent = + disputeTransactionUpdated.getOrThrow("disputeTransactionUpdated") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + accountHolderCreated != null -> visitor.visitAccountHolderCreated(accountHolderCreated) + kybPayload != null -> visitor.visitKybPayload(kybPayload) + kycPayload != null -> visitor.visitKycPayload(kycPayload) + legacyPayload != null -> visitor.visitLegacyPayload(legacyPayload) + accountHolderVerification != null -> + visitor.visitAccountHolderVerification(accountHolderVerification) + accountHolderDocumentUpdated != null -> + visitor.visitAccountHolderDocumentUpdated(accountHolderDocumentUpdated) + asaRequest != null -> visitor.visitAsaRequest(asaRequest) + tokenizationDecisioningRequest != null -> + visitor.visitTokenizationDecisioningRequest(tokenizationDecisioningRequest) + authRulesBacktestReportCreated != null -> + visitor.visitAuthRulesBacktestReportCreated(authRulesBacktestReportCreated) + balanceUpdated != null -> visitor.visitBalanceUpdated(balanceUpdated) + bookTransferTransactionCreated != null -> + visitor.visitBookTransferTransactionCreated(bookTransferTransactionCreated) + bookTransferTransactionUpdated != null -> + visitor.visitBookTransferTransactionUpdated(bookTransferTransactionUpdated) + cardCreated != null -> visitor.visitCardCreated(cardCreated) + cardConverted != null -> visitor.visitCardConverted(cardConverted) + cardRenewed != null -> visitor.visitCardRenewed(cardRenewed) + cardReissued != null -> visitor.visitCardReissued(cardReissued) + cardShipped != null -> visitor.visitCardShipped(cardShipped) + cardTransactionUpdated != null -> + visitor.visitCardTransactionUpdated(cardTransactionUpdated) + cardTransactionEnhancedDataCreated != null -> + visitor.visitCardTransactionEnhancedDataCreated(cardTransactionEnhancedDataCreated) + cardTransactionEnhancedDataUpdated != null -> + visitor.visitCardTransactionEnhancedDataUpdated(cardTransactionEnhancedDataUpdated) + digitalWalletTokenizationApprovalRequest != null -> + visitor.visitDigitalWalletTokenizationApprovalRequest( + digitalWalletTokenizationApprovalRequest + ) + digitalWalletTokenizationResult != null -> + visitor.visitDigitalWalletTokenizationResult(digitalWalletTokenizationResult) + digitalWalletTokenizationTwoFactorAuthenticationCode != null -> + visitor.visitDigitalWalletTokenizationTwoFactorAuthenticationCode( + digitalWalletTokenizationTwoFactorAuthenticationCode + ) + digitalWalletTokenizationTwoFactorAuthenticationCodeSent != null -> + visitor.visitDigitalWalletTokenizationTwoFactorAuthenticationCodeSent( + digitalWalletTokenizationTwoFactorAuthenticationCodeSent + ) + digitalWalletTokenizationUpdated != null -> + visitor.visitDigitalWalletTokenizationUpdated(digitalWalletTokenizationUpdated) + disputeUpdated != null -> visitor.visitDisputeUpdated(disputeUpdated) + disputeEvidenceUploadFailed != null -> + visitor.visitDisputeEvidenceUploadFailed(disputeEvidenceUploadFailed) + externalBankAccountCreated != null -> + visitor.visitExternalBankAccountCreated(externalBankAccountCreated) + externalBankAccountUpdated != null -> + visitor.visitExternalBankAccountUpdated(externalBankAccountUpdated) + externalPaymentCreated != null -> + visitor.visitExternalPaymentCreated(externalPaymentCreated) + externalPaymentUpdated != null -> + visitor.visitExternalPaymentUpdated(externalPaymentUpdated) + financialAccountCreated != null -> + visitor.visitFinancialAccountCreated(financialAccountCreated) + financialAccountUpdated != null -> + visitor.visitFinancialAccountUpdated(financialAccountUpdated) + fundingEventCreated != null -> visitor.visitFundingEventCreated(fundingEventCreated) + loanTapeCreated != null -> visitor.visitLoanTapeCreated(loanTapeCreated) + loanTapeUpdated != null -> visitor.visitLoanTapeUpdated(loanTapeUpdated) + managementOperationCreated != null -> + visitor.visitManagementOperationCreated(managementOperationCreated) + managementOperationUpdated != null -> + visitor.visitManagementOperationUpdated(managementOperationUpdated) + internalTransactionCreated != null -> + visitor.visitInternalTransactionCreated(internalTransactionCreated) + internalTransactionUpdated != null -> + visitor.visitInternalTransactionUpdated(internalTransactionUpdated) + networkTotalCreated != null -> visitor.visitNetworkTotalCreated(networkTotalCreated) + networkTotalUpdated != null -> visitor.visitNetworkTotalUpdated(networkTotalUpdated) + paymentTransactionCreated != null -> + visitor.visitPaymentTransactionCreated(paymentTransactionCreated) + paymentTransactionUpdated != null -> + visitor.visitPaymentTransactionUpdated(paymentTransactionUpdated) + settlementReportUpdated != null -> + visitor.visitSettlementReportUpdated(settlementReportUpdated) + statementsCreated != null -> visitor.visitStatementsCreated(statementsCreated) + threeDSAuthenticationCreated != null -> + visitor.visitThreeDSAuthenticationCreated(threeDSAuthenticationCreated) + threeDSAuthenticationUpdated != null -> + visitor.visitThreeDSAuthenticationUpdated(threeDSAuthenticationUpdated) + threeDSAuthenticationChallenge != null -> + visitor.visitThreeDSAuthenticationChallenge(threeDSAuthenticationChallenge) + tokenizationApprovalRequest != null -> + visitor.visitTokenizationApprovalRequest(tokenizationApprovalRequest) + tokenizationResult != null -> visitor.visitTokenizationResult(tokenizationResult) + tokenizationTwoFactorAuthenticationCode != null -> + visitor.visitTokenizationTwoFactorAuthenticationCode( + tokenizationTwoFactorAuthenticationCode + ) + tokenizationTwoFactorAuthenticationCodeSent != null -> + visitor.visitTokenizationTwoFactorAuthenticationCodeSent( + tokenizationTwoFactorAuthenticationCodeSent + ) + tokenizationUpdated != null -> visitor.visitTokenizationUpdated(tokenizationUpdated) + threeDSAuthentication != null -> + visitor.visitThreeDSAuthentication(threeDSAuthentication) + disputeTransactionCreated != null -> + visitor.visitDisputeTransactionCreated(disputeTransactionCreated) + disputeTransactionUpdated != null -> + visitor.visitDisputeTransactionUpdated(disputeTransactionUpdated) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ParsedWebhookEvent = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAccountHolderCreated( + accountHolderCreated: AccountHolderCreatedWebhookEvent + ) { + accountHolderCreated.validate() + } + + override fun visitKybPayload(kybPayload: KybPayload) { + kybPayload.validate() + } + + override fun visitKycPayload(kycPayload: KycPayload) { + kycPayload.validate() + } + + override fun visitLegacyPayload(legacyPayload: LegacyPayload) { + legacyPayload.validate() + } + + override fun visitAccountHolderVerification( + accountHolderVerification: AccountHolderVerificationWebhookEvent + ) { + accountHolderVerification.validate() + } + + override fun visitAccountHolderDocumentUpdated( + accountHolderDocumentUpdated: AccountHolderDocumentUpdatedWebhookEvent + ) { + accountHolderDocumentUpdated.validate() + } + + override fun visitAsaRequest(asaRequest: AsaRequestWebhookEvent) { + asaRequest.validate() + } + + override fun visitTokenizationDecisioningRequest( + tokenizationDecisioningRequest: TokenizationDecisioningRequestWebhookEvent + ) { + tokenizationDecisioningRequest.validate() + } + + override fun visitAuthRulesBacktestReportCreated( + authRulesBacktestReportCreated: AuthRulesBacktestReportCreatedWebhookEvent + ) { + authRulesBacktestReportCreated.validate() + } + + override fun visitBalanceUpdated(balanceUpdated: BalanceUpdatedWebhookEvent) { + balanceUpdated.validate() + } + + override fun visitBookTransferTransactionCreated( + bookTransferTransactionCreated: BookTransferTransactionCreatedWebhookEvent + ) { + bookTransferTransactionCreated.validate() + } + + override fun visitBookTransferTransactionUpdated( + bookTransferTransactionUpdated: BookTransferTransactionUpdatedWebhookEvent + ) { + bookTransferTransactionUpdated.validate() + } + + override fun visitCardCreated(cardCreated: CardCreatedWebhookEvent) { + cardCreated.validate() + } + + override fun visitCardConverted(cardConverted: CardConvertedWebhookEvent) { + cardConverted.validate() + } + + override fun visitCardRenewed(cardRenewed: CardRenewedWebhookEvent) { + cardRenewed.validate() + } + + override fun visitCardReissued(cardReissued: CardReissuedWebhookEvent) { + cardReissued.validate() + } + + override fun visitCardShipped(cardShipped: CardShippedWebhookEvent) { + cardShipped.validate() + } + + override fun visitCardTransactionUpdated( + cardTransactionUpdated: CardTransactionUpdatedWebhookEvent + ) { + cardTransactionUpdated.validate() + } + + override fun visitCardTransactionEnhancedDataCreated( + cardTransactionEnhancedDataCreated: + CardTransactionEnhancedDataCreatedWebhookEvent + ) { + cardTransactionEnhancedDataCreated.validate() + } + + override fun visitCardTransactionEnhancedDataUpdated( + cardTransactionEnhancedDataUpdated: + CardTransactionEnhancedDataUpdatedWebhookEvent + ) { + cardTransactionEnhancedDataUpdated.validate() + } + + override fun visitDigitalWalletTokenizationApprovalRequest( + digitalWalletTokenizationApprovalRequest: + DigitalWalletTokenizationApprovalRequestWebhookEvent + ) { + digitalWalletTokenizationApprovalRequest.validate() + } + + override fun visitDigitalWalletTokenizationResult( + digitalWalletTokenizationResult: DigitalWalletTokenizationResultWebhookEvent + ) { + digitalWalletTokenizationResult.validate() + } + + override fun visitDigitalWalletTokenizationTwoFactorAuthenticationCode( + digitalWalletTokenizationTwoFactorAuthenticationCode: + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + ) { + digitalWalletTokenizationTwoFactorAuthenticationCode.validate() + } + + override fun visitDigitalWalletTokenizationTwoFactorAuthenticationCodeSent( + digitalWalletTokenizationTwoFactorAuthenticationCodeSent: + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ) { + digitalWalletTokenizationTwoFactorAuthenticationCodeSent.validate() + } + + override fun visitDigitalWalletTokenizationUpdated( + digitalWalletTokenizationUpdated: DigitalWalletTokenizationUpdatedWebhookEvent + ) { + digitalWalletTokenizationUpdated.validate() + } + + override fun visitDisputeUpdated(disputeUpdated: DisputeUpdatedWebhookEvent) { + disputeUpdated.validate() + } + + override fun visitDisputeEvidenceUploadFailed( + disputeEvidenceUploadFailed: DisputeEvidenceUploadFailedWebhookEvent + ) { + disputeEvidenceUploadFailed.validate() + } + + override fun visitExternalBankAccountCreated( + externalBankAccountCreated: ExternalBankAccountCreatedWebhookEvent + ) { + externalBankAccountCreated.validate() + } + + override fun visitExternalBankAccountUpdated( + externalBankAccountUpdated: ExternalBankAccountUpdatedWebhookEvent + ) { + externalBankAccountUpdated.validate() + } + + override fun visitExternalPaymentCreated( + externalPaymentCreated: ExternalPaymentCreatedWebhookEvent + ) { + externalPaymentCreated.validate() + } + + override fun visitExternalPaymentUpdated( + externalPaymentUpdated: ExternalPaymentUpdatedWebhookEvent + ) { + externalPaymentUpdated.validate() + } + + override fun visitFinancialAccountCreated( + financialAccountCreated: FinancialAccountCreatedWebhookEvent + ) { + financialAccountCreated.validate() + } + + override fun visitFinancialAccountUpdated( + financialAccountUpdated: FinancialAccountUpdatedWebhookEvent + ) { + financialAccountUpdated.validate() + } + + override fun visitFundingEventCreated( + fundingEventCreated: FundingEventCreatedWebhookEvent + ) { + fundingEventCreated.validate() + } + + override fun visitLoanTapeCreated(loanTapeCreated: LoanTapeCreatedWebhookEvent) { + loanTapeCreated.validate() + } + + override fun visitLoanTapeUpdated(loanTapeUpdated: LoanTapeUpdatedWebhookEvent) { + loanTapeUpdated.validate() + } + + override fun visitManagementOperationCreated( + managementOperationCreated: ManagementOperationCreatedWebhookEvent + ) { + managementOperationCreated.validate() + } + + override fun visitManagementOperationUpdated( + managementOperationUpdated: ManagementOperationUpdatedWebhookEvent + ) { + managementOperationUpdated.validate() + } + + override fun visitInternalTransactionCreated( + internalTransactionCreated: InternalTransactionCreatedWebhookEvent + ) { + internalTransactionCreated.validate() + } + + override fun visitInternalTransactionUpdated( + internalTransactionUpdated: InternalTransactionUpdatedWebhookEvent + ) { + internalTransactionUpdated.validate() + } + + override fun visitNetworkTotalCreated( + networkTotalCreated: NetworkTotalCreatedWebhookEvent + ) { + networkTotalCreated.validate() + } + + override fun visitNetworkTotalUpdated( + networkTotalUpdated: NetworkTotalUpdatedWebhookEvent + ) { + networkTotalUpdated.validate() + } + + override fun visitPaymentTransactionCreated( + paymentTransactionCreated: PaymentTransactionCreatedWebhookEvent + ) { + paymentTransactionCreated.validate() + } + + override fun visitPaymentTransactionUpdated( + paymentTransactionUpdated: PaymentTransactionUpdatedWebhookEvent + ) { + paymentTransactionUpdated.validate() + } + + override fun visitSettlementReportUpdated( + settlementReportUpdated: SettlementReportUpdatedWebhookEvent + ) { + settlementReportUpdated.validate() + } + + override fun visitStatementsCreated( + statementsCreated: StatementsCreatedWebhookEvent + ) { + statementsCreated.validate() + } + + override fun visitThreeDSAuthenticationCreated( + threeDSAuthenticationCreated: ThreeDSAuthenticationCreatedWebhookEvent + ) { + threeDSAuthenticationCreated.validate() + } + + override fun visitThreeDSAuthenticationUpdated( + threeDSAuthenticationUpdated: ThreeDSAuthenticationUpdatedWebhookEvent + ) { + threeDSAuthenticationUpdated.validate() + } + + override fun visitThreeDSAuthenticationChallenge( + threeDSAuthenticationChallenge: ThreeDSAuthenticationChallengeWebhookEvent + ) { + threeDSAuthenticationChallenge.validate() + } + + override fun visitTokenizationApprovalRequest( + tokenizationApprovalRequest: TokenizationApprovalRequestWebhookEvent + ) { + tokenizationApprovalRequest.validate() + } + + override fun visitTokenizationResult( + tokenizationResult: TokenizationResultWebhookEvent + ) { + tokenizationResult.validate() + } + + override fun visitTokenizationTwoFactorAuthenticationCode( + tokenizationTwoFactorAuthenticationCode: + TokenizationTwoFactorAuthenticationCodeWebhookEvent + ) { + tokenizationTwoFactorAuthenticationCode.validate() + } + + override fun visitTokenizationTwoFactorAuthenticationCodeSent( + tokenizationTwoFactorAuthenticationCodeSent: + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ) { + tokenizationTwoFactorAuthenticationCodeSent.validate() + } + + override fun visitTokenizationUpdated( + tokenizationUpdated: TokenizationUpdatedWebhookEvent + ) { + tokenizationUpdated.validate() + } + + override fun visitThreeDSAuthentication( + threeDSAuthentication: ThreeDSAuthentication + ) { + threeDSAuthentication.validate() + } + + override fun visitDisputeTransactionCreated( + disputeTransactionCreated: DisputeTransactionCreatedWebhookEvent + ) { + disputeTransactionCreated.validate() + } + + override fun visitDisputeTransactionUpdated( + disputeTransactionUpdated: DisputeTransactionUpdatedWebhookEvent + ) { + disputeTransactionUpdated.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAccountHolderCreated( + accountHolderCreated: AccountHolderCreatedWebhookEvent + ) = accountHolderCreated.validity() + + override fun visitKybPayload(kybPayload: KybPayload) = kybPayload.validity() + + override fun visitKycPayload(kycPayload: KycPayload) = kycPayload.validity() + + override fun visitLegacyPayload(legacyPayload: LegacyPayload) = + legacyPayload.validity() + + override fun visitAccountHolderVerification( + accountHolderVerification: AccountHolderVerificationWebhookEvent + ) = accountHolderVerification.validity() + + override fun visitAccountHolderDocumentUpdated( + accountHolderDocumentUpdated: AccountHolderDocumentUpdatedWebhookEvent + ) = accountHolderDocumentUpdated.validity() + + override fun visitAsaRequest(asaRequest: AsaRequestWebhookEvent) = + asaRequest.validity() + + override fun visitTokenizationDecisioningRequest( + tokenizationDecisioningRequest: TokenizationDecisioningRequestWebhookEvent + ) = tokenizationDecisioningRequest.validity() + + override fun visitAuthRulesBacktestReportCreated( + authRulesBacktestReportCreated: AuthRulesBacktestReportCreatedWebhookEvent + ) = authRulesBacktestReportCreated.validity() + + override fun visitBalanceUpdated(balanceUpdated: BalanceUpdatedWebhookEvent) = + balanceUpdated.validity() + + override fun visitBookTransferTransactionCreated( + bookTransferTransactionCreated: BookTransferTransactionCreatedWebhookEvent + ) = bookTransferTransactionCreated.validity() + + override fun visitBookTransferTransactionUpdated( + bookTransferTransactionUpdated: BookTransferTransactionUpdatedWebhookEvent + ) = bookTransferTransactionUpdated.validity() + + override fun visitCardCreated(cardCreated: CardCreatedWebhookEvent) = + cardCreated.validity() + + override fun visitCardConverted(cardConverted: CardConvertedWebhookEvent) = + cardConverted.validity() + + override fun visitCardRenewed(cardRenewed: CardRenewedWebhookEvent) = + cardRenewed.validity() + + override fun visitCardReissued(cardReissued: CardReissuedWebhookEvent) = + cardReissued.validity() + + override fun visitCardShipped(cardShipped: CardShippedWebhookEvent) = + cardShipped.validity() + + override fun visitCardTransactionUpdated( + cardTransactionUpdated: CardTransactionUpdatedWebhookEvent + ) = cardTransactionUpdated.validity() + + override fun visitCardTransactionEnhancedDataCreated( + cardTransactionEnhancedDataCreated: + CardTransactionEnhancedDataCreatedWebhookEvent + ) = cardTransactionEnhancedDataCreated.validity() + + override fun visitCardTransactionEnhancedDataUpdated( + cardTransactionEnhancedDataUpdated: + CardTransactionEnhancedDataUpdatedWebhookEvent + ) = cardTransactionEnhancedDataUpdated.validity() + + override fun visitDigitalWalletTokenizationApprovalRequest( + digitalWalletTokenizationApprovalRequest: + DigitalWalletTokenizationApprovalRequestWebhookEvent + ) = digitalWalletTokenizationApprovalRequest.validity() + + override fun visitDigitalWalletTokenizationResult( + digitalWalletTokenizationResult: DigitalWalletTokenizationResultWebhookEvent + ) = digitalWalletTokenizationResult.validity() + + override fun visitDigitalWalletTokenizationTwoFactorAuthenticationCode( + digitalWalletTokenizationTwoFactorAuthenticationCode: + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + ) = digitalWalletTokenizationTwoFactorAuthenticationCode.validity() + + override fun visitDigitalWalletTokenizationTwoFactorAuthenticationCodeSent( + digitalWalletTokenizationTwoFactorAuthenticationCodeSent: + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ) = digitalWalletTokenizationTwoFactorAuthenticationCodeSent.validity() + + override fun visitDigitalWalletTokenizationUpdated( + digitalWalletTokenizationUpdated: DigitalWalletTokenizationUpdatedWebhookEvent + ) = digitalWalletTokenizationUpdated.validity() + + override fun visitDisputeUpdated(disputeUpdated: DisputeUpdatedWebhookEvent) = + disputeUpdated.validity() + + override fun visitDisputeEvidenceUploadFailed( + disputeEvidenceUploadFailed: DisputeEvidenceUploadFailedWebhookEvent + ) = disputeEvidenceUploadFailed.validity() + + override fun visitExternalBankAccountCreated( + externalBankAccountCreated: ExternalBankAccountCreatedWebhookEvent + ) = externalBankAccountCreated.validity() + + override fun visitExternalBankAccountUpdated( + externalBankAccountUpdated: ExternalBankAccountUpdatedWebhookEvent + ) = externalBankAccountUpdated.validity() + + override fun visitExternalPaymentCreated( + externalPaymentCreated: ExternalPaymentCreatedWebhookEvent + ) = externalPaymentCreated.validity() + + override fun visitExternalPaymentUpdated( + externalPaymentUpdated: ExternalPaymentUpdatedWebhookEvent + ) = externalPaymentUpdated.validity() + + override fun visitFinancialAccountCreated( + financialAccountCreated: FinancialAccountCreatedWebhookEvent + ) = financialAccountCreated.validity() + + override fun visitFinancialAccountUpdated( + financialAccountUpdated: FinancialAccountUpdatedWebhookEvent + ) = financialAccountUpdated.validity() + + override fun visitFundingEventCreated( + fundingEventCreated: FundingEventCreatedWebhookEvent + ) = fundingEventCreated.validity() + + override fun visitLoanTapeCreated(loanTapeCreated: LoanTapeCreatedWebhookEvent) = + loanTapeCreated.validity() + + override fun visitLoanTapeUpdated(loanTapeUpdated: LoanTapeUpdatedWebhookEvent) = + loanTapeUpdated.validity() + + override fun visitManagementOperationCreated( + managementOperationCreated: ManagementOperationCreatedWebhookEvent + ) = managementOperationCreated.validity() + + override fun visitManagementOperationUpdated( + managementOperationUpdated: ManagementOperationUpdatedWebhookEvent + ) = managementOperationUpdated.validity() + + override fun visitInternalTransactionCreated( + internalTransactionCreated: InternalTransactionCreatedWebhookEvent + ) = internalTransactionCreated.validity() + + override fun visitInternalTransactionUpdated( + internalTransactionUpdated: InternalTransactionUpdatedWebhookEvent + ) = internalTransactionUpdated.validity() + + override fun visitNetworkTotalCreated( + networkTotalCreated: NetworkTotalCreatedWebhookEvent + ) = networkTotalCreated.validity() + + override fun visitNetworkTotalUpdated( + networkTotalUpdated: NetworkTotalUpdatedWebhookEvent + ) = networkTotalUpdated.validity() + + override fun visitPaymentTransactionCreated( + paymentTransactionCreated: PaymentTransactionCreatedWebhookEvent + ) = paymentTransactionCreated.validity() + + override fun visitPaymentTransactionUpdated( + paymentTransactionUpdated: PaymentTransactionUpdatedWebhookEvent + ) = paymentTransactionUpdated.validity() + + override fun visitSettlementReportUpdated( + settlementReportUpdated: SettlementReportUpdatedWebhookEvent + ) = settlementReportUpdated.validity() + + override fun visitStatementsCreated( + statementsCreated: StatementsCreatedWebhookEvent + ) = statementsCreated.validity() + + override fun visitThreeDSAuthenticationCreated( + threeDSAuthenticationCreated: ThreeDSAuthenticationCreatedWebhookEvent + ) = threeDSAuthenticationCreated.validity() + + override fun visitThreeDSAuthenticationUpdated( + threeDSAuthenticationUpdated: ThreeDSAuthenticationUpdatedWebhookEvent + ) = threeDSAuthenticationUpdated.validity() + + override fun visitThreeDSAuthenticationChallenge( + threeDSAuthenticationChallenge: ThreeDSAuthenticationChallengeWebhookEvent + ) = threeDSAuthenticationChallenge.validity() + + override fun visitTokenizationApprovalRequest( + tokenizationApprovalRequest: TokenizationApprovalRequestWebhookEvent + ) = tokenizationApprovalRequest.validity() + + override fun visitTokenizationResult( + tokenizationResult: TokenizationResultWebhookEvent + ) = tokenizationResult.validity() + + override fun visitTokenizationTwoFactorAuthenticationCode( + tokenizationTwoFactorAuthenticationCode: + TokenizationTwoFactorAuthenticationCodeWebhookEvent + ) = tokenizationTwoFactorAuthenticationCode.validity() + + override fun visitTokenizationTwoFactorAuthenticationCodeSent( + tokenizationTwoFactorAuthenticationCodeSent: + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ) = tokenizationTwoFactorAuthenticationCodeSent.validity() + + override fun visitTokenizationUpdated( + tokenizationUpdated: TokenizationUpdatedWebhookEvent + ) = tokenizationUpdated.validity() + + override fun visitThreeDSAuthentication( + threeDSAuthentication: ThreeDSAuthentication + ) = threeDSAuthentication.validity() + + override fun visitDisputeTransactionCreated( + disputeTransactionCreated: DisputeTransactionCreatedWebhookEvent + ) = disputeTransactionCreated.validity() + + override fun visitDisputeTransactionUpdated( + disputeTransactionUpdated: DisputeTransactionUpdatedWebhookEvent + ) = disputeTransactionUpdated.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ParsedWebhookEvent && + accountHolderCreated == other.accountHolderCreated && + kybPayload == other.kybPayload && + kycPayload == other.kycPayload && + legacyPayload == other.legacyPayload && + accountHolderVerification == other.accountHolderVerification && + accountHolderDocumentUpdated == other.accountHolderDocumentUpdated && + asaRequest == other.asaRequest && + tokenizationDecisioningRequest == other.tokenizationDecisioningRequest && + authRulesBacktestReportCreated == other.authRulesBacktestReportCreated && + balanceUpdated == other.balanceUpdated && + bookTransferTransactionCreated == other.bookTransferTransactionCreated && + bookTransferTransactionUpdated == other.bookTransferTransactionUpdated && + cardCreated == other.cardCreated && + cardConverted == other.cardConverted && + cardRenewed == other.cardRenewed && + cardReissued == other.cardReissued && + cardShipped == other.cardShipped && + cardTransactionUpdated == other.cardTransactionUpdated && + cardTransactionEnhancedDataCreated == other.cardTransactionEnhancedDataCreated && + cardTransactionEnhancedDataUpdated == other.cardTransactionEnhancedDataUpdated && + digitalWalletTokenizationApprovalRequest == + other.digitalWalletTokenizationApprovalRequest && + digitalWalletTokenizationResult == other.digitalWalletTokenizationResult && + digitalWalletTokenizationTwoFactorAuthenticationCode == + other.digitalWalletTokenizationTwoFactorAuthenticationCode && + digitalWalletTokenizationTwoFactorAuthenticationCodeSent == + other.digitalWalletTokenizationTwoFactorAuthenticationCodeSent && + digitalWalletTokenizationUpdated == other.digitalWalletTokenizationUpdated && + disputeUpdated == other.disputeUpdated && + disputeEvidenceUploadFailed == other.disputeEvidenceUploadFailed && + externalBankAccountCreated == other.externalBankAccountCreated && + externalBankAccountUpdated == other.externalBankAccountUpdated && + externalPaymentCreated == other.externalPaymentCreated && + externalPaymentUpdated == other.externalPaymentUpdated && + financialAccountCreated == other.financialAccountCreated && + financialAccountUpdated == other.financialAccountUpdated && + fundingEventCreated == other.fundingEventCreated && + loanTapeCreated == other.loanTapeCreated && + loanTapeUpdated == other.loanTapeUpdated && + managementOperationCreated == other.managementOperationCreated && + managementOperationUpdated == other.managementOperationUpdated && + internalTransactionCreated == other.internalTransactionCreated && + internalTransactionUpdated == other.internalTransactionUpdated && + networkTotalCreated == other.networkTotalCreated && + networkTotalUpdated == other.networkTotalUpdated && + paymentTransactionCreated == other.paymentTransactionCreated && + paymentTransactionUpdated == other.paymentTransactionUpdated && + settlementReportUpdated == other.settlementReportUpdated && + statementsCreated == other.statementsCreated && + threeDSAuthenticationCreated == other.threeDSAuthenticationCreated && + threeDSAuthenticationUpdated == other.threeDSAuthenticationUpdated && + threeDSAuthenticationChallenge == other.threeDSAuthenticationChallenge && + tokenizationApprovalRequest == other.tokenizationApprovalRequest && + tokenizationResult == other.tokenizationResult && + tokenizationTwoFactorAuthenticationCode == + other.tokenizationTwoFactorAuthenticationCode && + tokenizationTwoFactorAuthenticationCodeSent == + other.tokenizationTwoFactorAuthenticationCodeSent && + tokenizationUpdated == other.tokenizationUpdated && + threeDSAuthentication == other.threeDSAuthentication && + disputeTransactionCreated == other.disputeTransactionCreated && + disputeTransactionUpdated == other.disputeTransactionUpdated + } + + override fun hashCode(): Int = + Objects.hash( + accountHolderCreated, + kybPayload, + kycPayload, + legacyPayload, + accountHolderVerification, + accountHolderDocumentUpdated, + asaRequest, + tokenizationDecisioningRequest, + authRulesBacktestReportCreated, + balanceUpdated, + bookTransferTransactionCreated, + bookTransferTransactionUpdated, + cardCreated, + cardConverted, + cardRenewed, + cardReissued, + cardShipped, + cardTransactionUpdated, + cardTransactionEnhancedDataCreated, + cardTransactionEnhancedDataUpdated, + digitalWalletTokenizationApprovalRequest, + digitalWalletTokenizationResult, + digitalWalletTokenizationTwoFactorAuthenticationCode, + digitalWalletTokenizationTwoFactorAuthenticationCodeSent, + digitalWalletTokenizationUpdated, + disputeUpdated, + disputeEvidenceUploadFailed, + externalBankAccountCreated, + externalBankAccountUpdated, + externalPaymentCreated, + externalPaymentUpdated, + financialAccountCreated, + financialAccountUpdated, + fundingEventCreated, + loanTapeCreated, + loanTapeUpdated, + managementOperationCreated, + managementOperationUpdated, + internalTransactionCreated, + internalTransactionUpdated, + networkTotalCreated, + networkTotalUpdated, + paymentTransactionCreated, + paymentTransactionUpdated, + settlementReportUpdated, + statementsCreated, + threeDSAuthenticationCreated, + threeDSAuthenticationUpdated, + threeDSAuthenticationChallenge, + tokenizationApprovalRequest, + tokenizationResult, + tokenizationTwoFactorAuthenticationCode, + tokenizationTwoFactorAuthenticationCodeSent, + tokenizationUpdated, + threeDSAuthentication, + disputeTransactionCreated, + disputeTransactionUpdated, + ) + + override fun toString(): String = + when { + accountHolderCreated != null -> + "ParsedWebhookEvent{accountHolderCreated=$accountHolderCreated}" + kybPayload != null -> "ParsedWebhookEvent{kybPayload=$kybPayload}" + kycPayload != null -> "ParsedWebhookEvent{kycPayload=$kycPayload}" + legacyPayload != null -> "ParsedWebhookEvent{legacyPayload=$legacyPayload}" + accountHolderVerification != null -> + "ParsedWebhookEvent{accountHolderVerification=$accountHolderVerification}" + accountHolderDocumentUpdated != null -> + "ParsedWebhookEvent{accountHolderDocumentUpdated=$accountHolderDocumentUpdated}" + asaRequest != null -> "ParsedWebhookEvent{asaRequest=$asaRequest}" + tokenizationDecisioningRequest != null -> + "ParsedWebhookEvent{tokenizationDecisioningRequest=$tokenizationDecisioningRequest}" + authRulesBacktestReportCreated != null -> + "ParsedWebhookEvent{authRulesBacktestReportCreated=$authRulesBacktestReportCreated}" + balanceUpdated != null -> "ParsedWebhookEvent{balanceUpdated=$balanceUpdated}" + bookTransferTransactionCreated != null -> + "ParsedWebhookEvent{bookTransferTransactionCreated=$bookTransferTransactionCreated}" + bookTransferTransactionUpdated != null -> + "ParsedWebhookEvent{bookTransferTransactionUpdated=$bookTransferTransactionUpdated}" + cardCreated != null -> "ParsedWebhookEvent{cardCreated=$cardCreated}" + cardConverted != null -> "ParsedWebhookEvent{cardConverted=$cardConverted}" + cardRenewed != null -> "ParsedWebhookEvent{cardRenewed=$cardRenewed}" + cardReissued != null -> "ParsedWebhookEvent{cardReissued=$cardReissued}" + cardShipped != null -> "ParsedWebhookEvent{cardShipped=$cardShipped}" + cardTransactionUpdated != null -> + "ParsedWebhookEvent{cardTransactionUpdated=$cardTransactionUpdated}" + cardTransactionEnhancedDataCreated != null -> + "ParsedWebhookEvent{cardTransactionEnhancedDataCreated=$cardTransactionEnhancedDataCreated}" + cardTransactionEnhancedDataUpdated != null -> + "ParsedWebhookEvent{cardTransactionEnhancedDataUpdated=$cardTransactionEnhancedDataUpdated}" + digitalWalletTokenizationApprovalRequest != null -> + "ParsedWebhookEvent{digitalWalletTokenizationApprovalRequest=$digitalWalletTokenizationApprovalRequest}" + digitalWalletTokenizationResult != null -> + "ParsedWebhookEvent{digitalWalletTokenizationResult=$digitalWalletTokenizationResult}" + digitalWalletTokenizationTwoFactorAuthenticationCode != null -> + "ParsedWebhookEvent{digitalWalletTokenizationTwoFactorAuthenticationCode=$digitalWalletTokenizationTwoFactorAuthenticationCode}" + digitalWalletTokenizationTwoFactorAuthenticationCodeSent != null -> + "ParsedWebhookEvent{digitalWalletTokenizationTwoFactorAuthenticationCodeSent=$digitalWalletTokenizationTwoFactorAuthenticationCodeSent}" + digitalWalletTokenizationUpdated != null -> + "ParsedWebhookEvent{digitalWalletTokenizationUpdated=$digitalWalletTokenizationUpdated}" + disputeUpdated != null -> "ParsedWebhookEvent{disputeUpdated=$disputeUpdated}" + disputeEvidenceUploadFailed != null -> + "ParsedWebhookEvent{disputeEvidenceUploadFailed=$disputeEvidenceUploadFailed}" + externalBankAccountCreated != null -> + "ParsedWebhookEvent{externalBankAccountCreated=$externalBankAccountCreated}" + externalBankAccountUpdated != null -> + "ParsedWebhookEvent{externalBankAccountUpdated=$externalBankAccountUpdated}" + externalPaymentCreated != null -> + "ParsedWebhookEvent{externalPaymentCreated=$externalPaymentCreated}" + externalPaymentUpdated != null -> + "ParsedWebhookEvent{externalPaymentUpdated=$externalPaymentUpdated}" + financialAccountCreated != null -> + "ParsedWebhookEvent{financialAccountCreated=$financialAccountCreated}" + financialAccountUpdated != null -> + "ParsedWebhookEvent{financialAccountUpdated=$financialAccountUpdated}" + fundingEventCreated != null -> + "ParsedWebhookEvent{fundingEventCreated=$fundingEventCreated}" + loanTapeCreated != null -> "ParsedWebhookEvent{loanTapeCreated=$loanTapeCreated}" + loanTapeUpdated != null -> "ParsedWebhookEvent{loanTapeUpdated=$loanTapeUpdated}" + managementOperationCreated != null -> + "ParsedWebhookEvent{managementOperationCreated=$managementOperationCreated}" + managementOperationUpdated != null -> + "ParsedWebhookEvent{managementOperationUpdated=$managementOperationUpdated}" + internalTransactionCreated != null -> + "ParsedWebhookEvent{internalTransactionCreated=$internalTransactionCreated}" + internalTransactionUpdated != null -> + "ParsedWebhookEvent{internalTransactionUpdated=$internalTransactionUpdated}" + networkTotalCreated != null -> + "ParsedWebhookEvent{networkTotalCreated=$networkTotalCreated}" + networkTotalUpdated != null -> + "ParsedWebhookEvent{networkTotalUpdated=$networkTotalUpdated}" + paymentTransactionCreated != null -> + "ParsedWebhookEvent{paymentTransactionCreated=$paymentTransactionCreated}" + paymentTransactionUpdated != null -> + "ParsedWebhookEvent{paymentTransactionUpdated=$paymentTransactionUpdated}" + settlementReportUpdated != null -> + "ParsedWebhookEvent{settlementReportUpdated=$settlementReportUpdated}" + statementsCreated != null -> "ParsedWebhookEvent{statementsCreated=$statementsCreated}" + threeDSAuthenticationCreated != null -> + "ParsedWebhookEvent{threeDSAuthenticationCreated=$threeDSAuthenticationCreated}" + threeDSAuthenticationUpdated != null -> + "ParsedWebhookEvent{threeDSAuthenticationUpdated=$threeDSAuthenticationUpdated}" + threeDSAuthenticationChallenge != null -> + "ParsedWebhookEvent{threeDSAuthenticationChallenge=$threeDSAuthenticationChallenge}" + tokenizationApprovalRequest != null -> + "ParsedWebhookEvent{tokenizationApprovalRequest=$tokenizationApprovalRequest}" + tokenizationResult != null -> + "ParsedWebhookEvent{tokenizationResult=$tokenizationResult}" + tokenizationTwoFactorAuthenticationCode != null -> + "ParsedWebhookEvent{tokenizationTwoFactorAuthenticationCode=$tokenizationTwoFactorAuthenticationCode}" + tokenizationTwoFactorAuthenticationCodeSent != null -> + "ParsedWebhookEvent{tokenizationTwoFactorAuthenticationCodeSent=$tokenizationTwoFactorAuthenticationCodeSent}" + tokenizationUpdated != null -> + "ParsedWebhookEvent{tokenizationUpdated=$tokenizationUpdated}" + threeDSAuthentication != null -> + "ParsedWebhookEvent{threeDSAuthentication=$threeDSAuthentication}" + disputeTransactionCreated != null -> + "ParsedWebhookEvent{disputeTransactionCreated=$disputeTransactionCreated}" + disputeTransactionUpdated != null -> + "ParsedWebhookEvent{disputeTransactionUpdated=$disputeTransactionUpdated}" + _json != null -> "ParsedWebhookEvent{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ParsedWebhookEvent") + } + + companion object { + + @JvmStatic + fun ofAccountHolderCreated(accountHolderCreated: AccountHolderCreatedWebhookEvent) = + ParsedWebhookEvent(accountHolderCreated = accountHolderCreated) + + /** KYB payload for an updated account holder. */ + @JvmStatic + fun ofKybPayload(kybPayload: KybPayload) = ParsedWebhookEvent(kybPayload = kybPayload) + + /** KYC payload for an updated account holder. */ + @JvmStatic + fun ofKycPayload(kycPayload: KycPayload) = ParsedWebhookEvent(kycPayload = kycPayload) + + /** Legacy payload for an updated account holder. */ + @JvmStatic + fun ofLegacyPayload(legacyPayload: LegacyPayload) = + ParsedWebhookEvent(legacyPayload = legacyPayload) + + @JvmStatic + fun ofAccountHolderVerification( + accountHolderVerification: AccountHolderVerificationWebhookEvent + ) = ParsedWebhookEvent(accountHolderVerification = accountHolderVerification) + + @JvmStatic + fun ofAccountHolderDocumentUpdated( + accountHolderDocumentUpdated: AccountHolderDocumentUpdatedWebhookEvent + ) = ParsedWebhookEvent(accountHolderDocumentUpdated = accountHolderDocumentUpdated) + + /** The Auth Stream Access request payload that was sent to the ASA responder. */ + @JvmStatic + fun ofAsaRequest(asaRequest: AsaRequestWebhookEvent) = + ParsedWebhookEvent(asaRequest = asaRequest) + + /** A webhook for tokenization decisioning sent to the customer's responder endpoint */ + @JvmStatic + fun ofTokenizationDecisioningRequest( + tokenizationDecisioningRequest: TokenizationDecisioningRequestWebhookEvent + ) = ParsedWebhookEvent(tokenizationDecisioningRequest = tokenizationDecisioningRequest) + + @JvmStatic + fun ofAuthRulesBacktestReportCreated( + authRulesBacktestReportCreated: AuthRulesBacktestReportCreatedWebhookEvent + ) = ParsedWebhookEvent(authRulesBacktestReportCreated = authRulesBacktestReportCreated) + + @JvmStatic + fun ofBalanceUpdated(balanceUpdated: BalanceUpdatedWebhookEvent) = + ParsedWebhookEvent(balanceUpdated = balanceUpdated) + + /** Book transfer transaction */ + @JvmStatic + fun ofBookTransferTransactionCreated( + bookTransferTransactionCreated: BookTransferTransactionCreatedWebhookEvent + ) = ParsedWebhookEvent(bookTransferTransactionCreated = bookTransferTransactionCreated) + + /** Book transfer transaction */ + @JvmStatic + fun ofBookTransferTransactionUpdated( + bookTransferTransactionUpdated: BookTransferTransactionUpdatedWebhookEvent + ) = ParsedWebhookEvent(bookTransferTransactionUpdated = bookTransferTransactionUpdated) + + @JvmStatic + fun ofCardCreated(cardCreated: CardCreatedWebhookEvent) = + ParsedWebhookEvent(cardCreated = cardCreated) + + @JvmStatic + fun ofCardConverted(cardConverted: CardConvertedWebhookEvent) = + ParsedWebhookEvent(cardConverted = cardConverted) + + @JvmStatic + fun ofCardRenewed(cardRenewed: CardRenewedWebhookEvent) = + ParsedWebhookEvent(cardRenewed = cardRenewed) + + @JvmStatic + fun ofCardReissued(cardReissued: CardReissuedWebhookEvent) = + ParsedWebhookEvent(cardReissued = cardReissued) + + @JvmStatic + fun ofCardShipped(cardShipped: CardShippedWebhookEvent) = + ParsedWebhookEvent(cardShipped = cardShipped) + + @JvmStatic + fun ofCardTransactionUpdated(cardTransactionUpdated: CardTransactionUpdatedWebhookEvent) = + ParsedWebhookEvent(cardTransactionUpdated = cardTransactionUpdated) + + @JvmStatic + fun ofCardTransactionEnhancedDataCreated( + cardTransactionEnhancedDataCreated: CardTransactionEnhancedDataCreatedWebhookEvent + ) = + ParsedWebhookEvent( + cardTransactionEnhancedDataCreated = cardTransactionEnhancedDataCreated + ) + + @JvmStatic + fun ofCardTransactionEnhancedDataUpdated( + cardTransactionEnhancedDataUpdated: CardTransactionEnhancedDataUpdatedWebhookEvent + ) = + ParsedWebhookEvent( + cardTransactionEnhancedDataUpdated = cardTransactionEnhancedDataUpdated + ) + + @JvmStatic + fun ofDigitalWalletTokenizationApprovalRequest( + digitalWalletTokenizationApprovalRequest: + DigitalWalletTokenizationApprovalRequestWebhookEvent + ) = + ParsedWebhookEvent( + digitalWalletTokenizationApprovalRequest = digitalWalletTokenizationApprovalRequest + ) + + @JvmStatic + fun ofDigitalWalletTokenizationResult( + digitalWalletTokenizationResult: DigitalWalletTokenizationResultWebhookEvent + ) = ParsedWebhookEvent(digitalWalletTokenizationResult = digitalWalletTokenizationResult) + + @JvmStatic + fun ofDigitalWalletTokenizationTwoFactorAuthenticationCode( + digitalWalletTokenizationTwoFactorAuthenticationCode: + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + ) = + ParsedWebhookEvent( + digitalWalletTokenizationTwoFactorAuthenticationCode = + digitalWalletTokenizationTwoFactorAuthenticationCode + ) + + @JvmStatic + fun ofDigitalWalletTokenizationTwoFactorAuthenticationCodeSent( + digitalWalletTokenizationTwoFactorAuthenticationCodeSent: + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ) = + ParsedWebhookEvent( + digitalWalletTokenizationTwoFactorAuthenticationCodeSent = + digitalWalletTokenizationTwoFactorAuthenticationCodeSent + ) + + @JvmStatic + fun ofDigitalWalletTokenizationUpdated( + digitalWalletTokenizationUpdated: DigitalWalletTokenizationUpdatedWebhookEvent + ) = ParsedWebhookEvent(digitalWalletTokenizationUpdated = digitalWalletTokenizationUpdated) + + /** Dispute. */ + @JvmStatic + fun ofDisputeUpdated(disputeUpdated: DisputeUpdatedWebhookEvent) = + ParsedWebhookEvent(disputeUpdated = disputeUpdated) + + /** Dispute evidence. */ + @JvmStatic + fun ofDisputeEvidenceUploadFailed( + disputeEvidenceUploadFailed: DisputeEvidenceUploadFailedWebhookEvent + ) = ParsedWebhookEvent(disputeEvidenceUploadFailed = disputeEvidenceUploadFailed) + + @JvmStatic + fun ofExternalBankAccountCreated( + externalBankAccountCreated: ExternalBankAccountCreatedWebhookEvent + ) = ParsedWebhookEvent(externalBankAccountCreated = externalBankAccountCreated) + + @JvmStatic + fun ofExternalBankAccountUpdated( + externalBankAccountUpdated: ExternalBankAccountUpdatedWebhookEvent + ) = ParsedWebhookEvent(externalBankAccountUpdated = externalBankAccountUpdated) + + @JvmStatic + fun ofExternalPaymentCreated(externalPaymentCreated: ExternalPaymentCreatedWebhookEvent) = + ParsedWebhookEvent(externalPaymentCreated = externalPaymentCreated) + + @JvmStatic + fun ofExternalPaymentUpdated(externalPaymentUpdated: ExternalPaymentUpdatedWebhookEvent) = + ParsedWebhookEvent(externalPaymentUpdated = externalPaymentUpdated) + + @JvmStatic + fun ofFinancialAccountCreated( + financialAccountCreated: FinancialAccountCreatedWebhookEvent + ) = ParsedWebhookEvent(financialAccountCreated = financialAccountCreated) + + @JvmStatic + fun ofFinancialAccountUpdated( + financialAccountUpdated: FinancialAccountUpdatedWebhookEvent + ) = ParsedWebhookEvent(financialAccountUpdated = financialAccountUpdated) + + @JvmStatic + fun ofFundingEventCreated(fundingEventCreated: FundingEventCreatedWebhookEvent) = + ParsedWebhookEvent(fundingEventCreated = fundingEventCreated) + + @JvmStatic + fun ofLoanTapeCreated(loanTapeCreated: LoanTapeCreatedWebhookEvent) = + ParsedWebhookEvent(loanTapeCreated = loanTapeCreated) + + @JvmStatic + fun ofLoanTapeUpdated(loanTapeUpdated: LoanTapeUpdatedWebhookEvent) = + ParsedWebhookEvent(loanTapeUpdated = loanTapeUpdated) + + @JvmStatic + fun ofManagementOperationCreated( + managementOperationCreated: ManagementOperationCreatedWebhookEvent + ) = ParsedWebhookEvent(managementOperationCreated = managementOperationCreated) + + @JvmStatic + fun ofManagementOperationUpdated( + managementOperationUpdated: ManagementOperationUpdatedWebhookEvent + ) = ParsedWebhookEvent(managementOperationUpdated = managementOperationUpdated) + + @JvmStatic + fun ofInternalTransactionCreated( + internalTransactionCreated: InternalTransactionCreatedWebhookEvent + ) = ParsedWebhookEvent(internalTransactionCreated = internalTransactionCreated) + + @JvmStatic + fun ofInternalTransactionUpdated( + internalTransactionUpdated: InternalTransactionUpdatedWebhookEvent + ) = ParsedWebhookEvent(internalTransactionUpdated = internalTransactionUpdated) + + @JvmStatic + fun ofNetworkTotalCreated(networkTotalCreated: NetworkTotalCreatedWebhookEvent) = + ParsedWebhookEvent(networkTotalCreated = networkTotalCreated) + + @JvmStatic + fun ofNetworkTotalUpdated(networkTotalUpdated: NetworkTotalUpdatedWebhookEvent) = + ParsedWebhookEvent(networkTotalUpdated = networkTotalUpdated) + + /** Payment transaction */ + @JvmStatic + fun ofPaymentTransactionCreated( + paymentTransactionCreated: PaymentTransactionCreatedWebhookEvent + ) = ParsedWebhookEvent(paymentTransactionCreated = paymentTransactionCreated) + + /** Payment transaction */ + @JvmStatic + fun ofPaymentTransactionUpdated( + paymentTransactionUpdated: PaymentTransactionUpdatedWebhookEvent + ) = ParsedWebhookEvent(paymentTransactionUpdated = paymentTransactionUpdated) + + @JvmStatic + fun ofSettlementReportUpdated( + settlementReportUpdated: SettlementReportUpdatedWebhookEvent + ) = ParsedWebhookEvent(settlementReportUpdated = settlementReportUpdated) + + @JvmStatic + fun ofStatementsCreated(statementsCreated: StatementsCreatedWebhookEvent) = + ParsedWebhookEvent(statementsCreated = statementsCreated) + + /** Represents a 3DS authentication */ + @JvmStatic + fun ofThreeDSAuthenticationCreated( + threeDSAuthenticationCreated: ThreeDSAuthenticationCreatedWebhookEvent + ) = ParsedWebhookEvent(threeDSAuthenticationCreated = threeDSAuthenticationCreated) + + /** Represents a 3DS authentication */ + @JvmStatic + fun ofThreeDSAuthenticationUpdated( + threeDSAuthenticationUpdated: ThreeDSAuthenticationUpdatedWebhookEvent + ) = ParsedWebhookEvent(threeDSAuthenticationUpdated = threeDSAuthenticationUpdated) + + @JvmStatic + fun ofThreeDSAuthenticationChallenge( + threeDSAuthenticationChallenge: ThreeDSAuthenticationChallengeWebhookEvent + ) = ParsedWebhookEvent(threeDSAuthenticationChallenge = threeDSAuthenticationChallenge) + + @JvmStatic + fun ofTokenizationApprovalRequest( + tokenizationApprovalRequest: TokenizationApprovalRequestWebhookEvent + ) = ParsedWebhookEvent(tokenizationApprovalRequest = tokenizationApprovalRequest) + + @JvmStatic + fun ofTokenizationResult(tokenizationResult: TokenizationResultWebhookEvent) = + ParsedWebhookEvent(tokenizationResult = tokenizationResult) + + @JvmStatic + fun ofTokenizationTwoFactorAuthenticationCode( + tokenizationTwoFactorAuthenticationCode: + TokenizationTwoFactorAuthenticationCodeWebhookEvent + ) = + ParsedWebhookEvent( + tokenizationTwoFactorAuthenticationCode = tokenizationTwoFactorAuthenticationCode + ) + + @JvmStatic + fun ofTokenizationTwoFactorAuthenticationCodeSent( + tokenizationTwoFactorAuthenticationCodeSent: + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ) = + ParsedWebhookEvent( + tokenizationTwoFactorAuthenticationCodeSent = + tokenizationTwoFactorAuthenticationCodeSent + ) + + @JvmStatic + fun ofTokenizationUpdated(tokenizationUpdated: TokenizationUpdatedWebhookEvent) = + ParsedWebhookEvent(tokenizationUpdated = tokenizationUpdated) + + /** Represents a 3DS authentication */ + @JvmStatic + fun ofThreeDSAuthentication(threeDSAuthentication: ThreeDSAuthentication) = + ParsedWebhookEvent(threeDSAuthentication = threeDSAuthentication) + + /** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ + @JvmStatic + fun ofDisputeTransactionCreated( + disputeTransactionCreated: DisputeTransactionCreatedWebhookEvent + ) = ParsedWebhookEvent(disputeTransactionCreated = disputeTransactionCreated) + + /** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ + @JvmStatic + fun ofDisputeTransactionUpdated( + disputeTransactionUpdated: DisputeTransactionUpdatedWebhookEvent + ) = ParsedWebhookEvent(disputeTransactionUpdated = disputeTransactionUpdated) + } + + /** + * An interface that defines how to map each variant of [ParsedWebhookEvent] to a value of type + * [T]. + */ + interface Visitor { + + fun visitAccountHolderCreated(accountHolderCreated: AccountHolderCreatedWebhookEvent): T + + /** KYB payload for an updated account holder. */ + fun visitKybPayload(kybPayload: KybPayload): T + + /** KYC payload for an updated account holder. */ + fun visitKycPayload(kycPayload: KycPayload): T + + /** Legacy payload for an updated account holder. */ + fun visitLegacyPayload(legacyPayload: LegacyPayload): T + + fun visitAccountHolderVerification( + accountHolderVerification: AccountHolderVerificationWebhookEvent + ): T + + fun visitAccountHolderDocumentUpdated( + accountHolderDocumentUpdated: AccountHolderDocumentUpdatedWebhookEvent + ): T + + /** The Auth Stream Access request payload that was sent to the ASA responder. */ + fun visitAsaRequest(asaRequest: AsaRequestWebhookEvent): T + + /** A webhook for tokenization decisioning sent to the customer's responder endpoint */ + fun visitTokenizationDecisioningRequest( + tokenizationDecisioningRequest: TokenizationDecisioningRequestWebhookEvent + ): T + + fun visitAuthRulesBacktestReportCreated( + authRulesBacktestReportCreated: AuthRulesBacktestReportCreatedWebhookEvent + ): T + + fun visitBalanceUpdated(balanceUpdated: BalanceUpdatedWebhookEvent): T + + /** Book transfer transaction */ + fun visitBookTransferTransactionCreated( + bookTransferTransactionCreated: BookTransferTransactionCreatedWebhookEvent + ): T + + /** Book transfer transaction */ + fun visitBookTransferTransactionUpdated( + bookTransferTransactionUpdated: BookTransferTransactionUpdatedWebhookEvent + ): T + + fun visitCardCreated(cardCreated: CardCreatedWebhookEvent): T + + fun visitCardConverted(cardConverted: CardConvertedWebhookEvent): T + + fun visitCardRenewed(cardRenewed: CardRenewedWebhookEvent): T + + fun visitCardReissued(cardReissued: CardReissuedWebhookEvent): T + + fun visitCardShipped(cardShipped: CardShippedWebhookEvent): T + + fun visitCardTransactionUpdated( + cardTransactionUpdated: CardTransactionUpdatedWebhookEvent + ): T + + fun visitCardTransactionEnhancedDataCreated( + cardTransactionEnhancedDataCreated: CardTransactionEnhancedDataCreatedWebhookEvent + ): T + + fun visitCardTransactionEnhancedDataUpdated( + cardTransactionEnhancedDataUpdated: CardTransactionEnhancedDataUpdatedWebhookEvent + ): T + + fun visitDigitalWalletTokenizationApprovalRequest( + digitalWalletTokenizationApprovalRequest: + DigitalWalletTokenizationApprovalRequestWebhookEvent + ): T + + fun visitDigitalWalletTokenizationResult( + digitalWalletTokenizationResult: DigitalWalletTokenizationResultWebhookEvent + ): T + + fun visitDigitalWalletTokenizationTwoFactorAuthenticationCode( + digitalWalletTokenizationTwoFactorAuthenticationCode: + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + ): T + + fun visitDigitalWalletTokenizationTwoFactorAuthenticationCodeSent( + digitalWalletTokenizationTwoFactorAuthenticationCodeSent: + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ): T + + fun visitDigitalWalletTokenizationUpdated( + digitalWalletTokenizationUpdated: DigitalWalletTokenizationUpdatedWebhookEvent + ): T + + /** Dispute. */ + fun visitDisputeUpdated(disputeUpdated: DisputeUpdatedWebhookEvent): T + + /** Dispute evidence. */ + fun visitDisputeEvidenceUploadFailed( + disputeEvidenceUploadFailed: DisputeEvidenceUploadFailedWebhookEvent + ): T + + fun visitExternalBankAccountCreated( + externalBankAccountCreated: ExternalBankAccountCreatedWebhookEvent + ): T + + fun visitExternalBankAccountUpdated( + externalBankAccountUpdated: ExternalBankAccountUpdatedWebhookEvent + ): T + + fun visitExternalPaymentCreated( + externalPaymentCreated: ExternalPaymentCreatedWebhookEvent + ): T + + fun visitExternalPaymentUpdated( + externalPaymentUpdated: ExternalPaymentUpdatedWebhookEvent + ): T + + fun visitFinancialAccountCreated( + financialAccountCreated: FinancialAccountCreatedWebhookEvent + ): T + + fun visitFinancialAccountUpdated( + financialAccountUpdated: FinancialAccountUpdatedWebhookEvent + ): T + + fun visitFundingEventCreated(fundingEventCreated: FundingEventCreatedWebhookEvent): T + + fun visitLoanTapeCreated(loanTapeCreated: LoanTapeCreatedWebhookEvent): T + + fun visitLoanTapeUpdated(loanTapeUpdated: LoanTapeUpdatedWebhookEvent): T + + fun visitManagementOperationCreated( + managementOperationCreated: ManagementOperationCreatedWebhookEvent + ): T + + fun visitManagementOperationUpdated( + managementOperationUpdated: ManagementOperationUpdatedWebhookEvent + ): T + + fun visitInternalTransactionCreated( + internalTransactionCreated: InternalTransactionCreatedWebhookEvent + ): T + + fun visitInternalTransactionUpdated( + internalTransactionUpdated: InternalTransactionUpdatedWebhookEvent + ): T + + fun visitNetworkTotalCreated(networkTotalCreated: NetworkTotalCreatedWebhookEvent): T + + fun visitNetworkTotalUpdated(networkTotalUpdated: NetworkTotalUpdatedWebhookEvent): T + + /** Payment transaction */ + fun visitPaymentTransactionCreated( + paymentTransactionCreated: PaymentTransactionCreatedWebhookEvent + ): T + + /** Payment transaction */ + fun visitPaymentTransactionUpdated( + paymentTransactionUpdated: PaymentTransactionUpdatedWebhookEvent + ): T + + fun visitSettlementReportUpdated( + settlementReportUpdated: SettlementReportUpdatedWebhookEvent + ): T + + fun visitStatementsCreated(statementsCreated: StatementsCreatedWebhookEvent): T + + /** Represents a 3DS authentication */ + fun visitThreeDSAuthenticationCreated( + threeDSAuthenticationCreated: ThreeDSAuthenticationCreatedWebhookEvent + ): T + + /** Represents a 3DS authentication */ + fun visitThreeDSAuthenticationUpdated( + threeDSAuthenticationUpdated: ThreeDSAuthenticationUpdatedWebhookEvent + ): T + + fun visitThreeDSAuthenticationChallenge( + threeDSAuthenticationChallenge: ThreeDSAuthenticationChallengeWebhookEvent + ): T + + fun visitTokenizationApprovalRequest( + tokenizationApprovalRequest: TokenizationApprovalRequestWebhookEvent + ): T + + fun visitTokenizationResult(tokenizationResult: TokenizationResultWebhookEvent): T + + fun visitTokenizationTwoFactorAuthenticationCode( + tokenizationTwoFactorAuthenticationCode: + TokenizationTwoFactorAuthenticationCodeWebhookEvent + ): T + + fun visitTokenizationTwoFactorAuthenticationCodeSent( + tokenizationTwoFactorAuthenticationCodeSent: + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ): T + + fun visitTokenizationUpdated(tokenizationUpdated: TokenizationUpdatedWebhookEvent): T + + /** Represents a 3DS authentication */ + fun visitThreeDSAuthentication(threeDSAuthentication: ThreeDSAuthentication): T + + /** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ + fun visitDisputeTransactionCreated( + disputeTransactionCreated: DisputeTransactionCreatedWebhookEvent + ): T + + /** The Dispute object tracks the progression of a dispute throughout its lifecycle. */ + fun visitDisputeTransactionUpdated( + disputeTransactionUpdated: DisputeTransactionUpdatedWebhookEvent + ): T + + /** + * Maps an unknown variant of [ParsedWebhookEvent] to a value of type [T]. + * + * An instance of [ParsedWebhookEvent] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is unaware + * of. + * + * @throws LithicInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw LithicInvalidDataException("Unknown ParsedWebhookEvent: $json") + } + } + + internal class Deserializer : BaseDeserializer(ParsedWebhookEvent::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ParsedWebhookEvent { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(accountHolderCreated = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(kybPayload = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(kycPayload = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(legacyPayload = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(accountHolderVerification = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(accountHolderDocumentUpdated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(asaRequest = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + tokenizationDecisioningRequest = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + authRulesBacktestReportCreated = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(balanceUpdated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + bookTransferTransactionCreated = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + bookTransferTransactionUpdated = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(cardCreated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(cardConverted = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(cardRenewed = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(cardReissued = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(cardShipped = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(cardTransactionUpdated = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + cardTransactionEnhancedDataCreated = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + cardTransactionEnhancedDataUpdated = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef< + DigitalWalletTokenizationApprovalRequestWebhookEvent + >(), + ) + ?.let { + ParsedWebhookEvent( + digitalWalletTokenizationApprovalRequest = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + digitalWalletTokenizationResult = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef< + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + >(), + ) + ?.let { + ParsedWebhookEvent( + digitalWalletTokenizationTwoFactorAuthenticationCode = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef< + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + >(), + ) + ?.let { + ParsedWebhookEvent( + digitalWalletTokenizationTwoFactorAuthenticationCodeSent = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + digitalWalletTokenizationUpdated = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(disputeUpdated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(disputeEvidenceUploadFailed = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(externalBankAccountCreated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(externalBankAccountUpdated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(externalPaymentCreated = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(externalPaymentUpdated = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + ParsedWebhookEvent(financialAccountCreated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + ParsedWebhookEvent(financialAccountUpdated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(fundingEventCreated = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(loanTapeCreated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(loanTapeUpdated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(managementOperationCreated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(managementOperationUpdated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(internalTransactionCreated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(internalTransactionUpdated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(networkTotalCreated = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(networkTotalUpdated = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(paymentTransactionCreated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(paymentTransactionUpdated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + ParsedWebhookEvent(settlementReportUpdated = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(statementsCreated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(threeDSAuthenticationCreated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(threeDSAuthenticationUpdated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent( + threeDSAuthenticationChallenge = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(tokenizationApprovalRequest = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(tokenizationResult = it, _json = json) }, + tryDeserialize( + node, + jacksonTypeRef< + TokenizationTwoFactorAuthenticationCodeWebhookEvent + >(), + ) + ?.let { + ParsedWebhookEvent( + tokenizationTwoFactorAuthenticationCode = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef< + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent + >(), + ) + ?.let { + ParsedWebhookEvent( + tokenizationTwoFactorAuthenticationCodeSent = it, + _json = json, + ) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { ParsedWebhookEvent(tokenizationUpdated = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + ParsedWebhookEvent(threeDSAuthentication = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(disputeTransactionCreated = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + ParsedWebhookEvent(disputeTransactionUpdated = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> ParsedWebhookEvent(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ParsedWebhookEvent::class) { + + override fun serialize( + value: ParsedWebhookEvent, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.accountHolderCreated != null -> + generator.writeObject(value.accountHolderCreated) + value.kybPayload != null -> generator.writeObject(value.kybPayload) + value.kycPayload != null -> generator.writeObject(value.kycPayload) + value.legacyPayload != null -> generator.writeObject(value.legacyPayload) + value.accountHolderVerification != null -> + generator.writeObject(value.accountHolderVerification) + value.accountHolderDocumentUpdated != null -> + generator.writeObject(value.accountHolderDocumentUpdated) + value.asaRequest != null -> generator.writeObject(value.asaRequest) + value.tokenizationDecisioningRequest != null -> + generator.writeObject(value.tokenizationDecisioningRequest) + value.authRulesBacktestReportCreated != null -> + generator.writeObject(value.authRulesBacktestReportCreated) + value.balanceUpdated != null -> generator.writeObject(value.balanceUpdated) + value.bookTransferTransactionCreated != null -> + generator.writeObject(value.bookTransferTransactionCreated) + value.bookTransferTransactionUpdated != null -> + generator.writeObject(value.bookTransferTransactionUpdated) + value.cardCreated != null -> generator.writeObject(value.cardCreated) + value.cardConverted != null -> generator.writeObject(value.cardConverted) + value.cardRenewed != null -> generator.writeObject(value.cardRenewed) + value.cardReissued != null -> generator.writeObject(value.cardReissued) + value.cardShipped != null -> generator.writeObject(value.cardShipped) + value.cardTransactionUpdated != null -> + generator.writeObject(value.cardTransactionUpdated) + value.cardTransactionEnhancedDataCreated != null -> + generator.writeObject(value.cardTransactionEnhancedDataCreated) + value.cardTransactionEnhancedDataUpdated != null -> + generator.writeObject(value.cardTransactionEnhancedDataUpdated) + value.digitalWalletTokenizationApprovalRequest != null -> + generator.writeObject(value.digitalWalletTokenizationApprovalRequest) + value.digitalWalletTokenizationResult != null -> + generator.writeObject(value.digitalWalletTokenizationResult) + value.digitalWalletTokenizationTwoFactorAuthenticationCode != null -> + generator.writeObject( + value.digitalWalletTokenizationTwoFactorAuthenticationCode + ) + value.digitalWalletTokenizationTwoFactorAuthenticationCodeSent != null -> + generator.writeObject( + value.digitalWalletTokenizationTwoFactorAuthenticationCodeSent + ) + value.digitalWalletTokenizationUpdated != null -> + generator.writeObject(value.digitalWalletTokenizationUpdated) + value.disputeUpdated != null -> generator.writeObject(value.disputeUpdated) + value.disputeEvidenceUploadFailed != null -> + generator.writeObject(value.disputeEvidenceUploadFailed) + value.externalBankAccountCreated != null -> + generator.writeObject(value.externalBankAccountCreated) + value.externalBankAccountUpdated != null -> + generator.writeObject(value.externalBankAccountUpdated) + value.externalPaymentCreated != null -> + generator.writeObject(value.externalPaymentCreated) + value.externalPaymentUpdated != null -> + generator.writeObject(value.externalPaymentUpdated) + value.financialAccountCreated != null -> + generator.writeObject(value.financialAccountCreated) + value.financialAccountUpdated != null -> + generator.writeObject(value.financialAccountUpdated) + value.fundingEventCreated != null -> + generator.writeObject(value.fundingEventCreated) + value.loanTapeCreated != null -> generator.writeObject(value.loanTapeCreated) + value.loanTapeUpdated != null -> generator.writeObject(value.loanTapeUpdated) + value.managementOperationCreated != null -> + generator.writeObject(value.managementOperationCreated) + value.managementOperationUpdated != null -> + generator.writeObject(value.managementOperationUpdated) + value.internalTransactionCreated != null -> + generator.writeObject(value.internalTransactionCreated) + value.internalTransactionUpdated != null -> + generator.writeObject(value.internalTransactionUpdated) + value.networkTotalCreated != null -> + generator.writeObject(value.networkTotalCreated) + value.networkTotalUpdated != null -> + generator.writeObject(value.networkTotalUpdated) + value.paymentTransactionCreated != null -> + generator.writeObject(value.paymentTransactionCreated) + value.paymentTransactionUpdated != null -> + generator.writeObject(value.paymentTransactionUpdated) + value.settlementReportUpdated != null -> + generator.writeObject(value.settlementReportUpdated) + value.statementsCreated != null -> generator.writeObject(value.statementsCreated) + value.threeDSAuthenticationCreated != null -> + generator.writeObject(value.threeDSAuthenticationCreated) + value.threeDSAuthenticationUpdated != null -> + generator.writeObject(value.threeDSAuthenticationUpdated) + value.threeDSAuthenticationChallenge != null -> + generator.writeObject(value.threeDSAuthenticationChallenge) + value.tokenizationApprovalRequest != null -> + generator.writeObject(value.tokenizationApprovalRequest) + value.tokenizationResult != null -> generator.writeObject(value.tokenizationResult) + value.tokenizationTwoFactorAuthenticationCode != null -> + generator.writeObject(value.tokenizationTwoFactorAuthenticationCode) + value.tokenizationTwoFactorAuthenticationCodeSent != null -> + generator.writeObject(value.tokenizationTwoFactorAuthenticationCodeSent) + value.tokenizationUpdated != null -> + generator.writeObject(value.tokenizationUpdated) + value.threeDSAuthentication != null -> + generator.writeObject(value.threeDSAuthentication) + value.disputeTransactionCreated != null -> + generator.writeObject(value.disputeTransactionCreated) + value.disputeTransactionUpdated != null -> + generator.writeObject(value.disputeTransactionUpdated) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ParsedWebhookEvent") + } + } + } + + /** KYB payload for an updated account holder. */ + class KybPayload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val updateRequest: JsonField, + private val eventType: JsonField, + private val externalId: JsonField, + private val natureOfBusiness: JsonField, + private val websiteUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("update_request") + @ExcludeMissing + updateRequest: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + @JsonProperty("nature_of_business") + @ExcludeMissing + natureOfBusiness: JsonField = JsonMissing.of(), + @JsonProperty("website_url") + @ExcludeMissing + websiteUrl: JsonField = JsonMissing.of(), + ) : this( + token, + updateRequest, + eventType, + externalId, + natureOfBusiness, + websiteUrl, + mutableMapOf(), + ) + + /** + * The token of the account_holder that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Original request to update the account holder. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updateRequest(): UpdateRequest = updateRequest.getRequired("update_request") + + /** + * The type of event that occurred. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventType(): Optional = eventType.getOptional("event_type") + + /** + * A user provided id that can be used to link an account holder with an external system + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * Short description of the company's line of business (i.e., what does the company do?). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun natureOfBusiness(): Optional = + natureOfBusiness.getOptional("nature_of_business") + + /** + * Company website URL. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun websiteUrl(): Optional = websiteUrl.getOptional("website_url") + + /** + * 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 [updateRequest]. + * + * Unlike [updateRequest], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("update_request") + @ExcludeMissing + fun _updateRequest(): JsonField = updateRequest + + /** + * 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 [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + + /** + * Returns the raw JSON value of [natureOfBusiness]. + * + * Unlike [natureOfBusiness], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nature_of_business") + @ExcludeMissing + fun _natureOfBusiness(): JsonField = natureOfBusiness + + /** + * Returns the raw JSON value of [websiteUrl]. + * + * Unlike [websiteUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("website_url") + @ExcludeMissing + fun _websiteUrl(): JsonField = websiteUrl + + @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 [KybPayload]. + * + * The following fields are required: + * ```java + * .token() + * .updateRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [KybPayload]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var updateRequest: JsonField? = null + private var eventType: JsonField = JsonMissing.of() + private var externalId: JsonField = JsonMissing.of() + private var natureOfBusiness: JsonField = JsonMissing.of() + private var websiteUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(kybPayload: KybPayload) = apply { + token = kybPayload.token + updateRequest = kybPayload.updateRequest + eventType = kybPayload.eventType + externalId = kybPayload.externalId + natureOfBusiness = kybPayload.natureOfBusiness + websiteUrl = kybPayload.websiteUrl + additionalProperties = kybPayload.additionalProperties.toMutableMap() + } + + /** The token of the account_holder that was created. */ + 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 } + + /** Original request to update the account holder. */ + fun updateRequest(updateRequest: UpdateRequest) = + updateRequest(JsonField.of(updateRequest)) + + /** + * Sets [Builder.updateRequest] to an arbitrary JSON value. + * + * You should usually call [Builder.updateRequest] with a well-typed [UpdateRequest] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun updateRequest(updateRequest: JsonField) = apply { + this.updateRequest = updateRequest + } + + /** 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 } + + /** + * A user provided id that can be used to link an account holder with an external system + */ + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + /** + * Short description of the company's line of business (i.e., what does the company + * do?). + */ + fun natureOfBusiness(natureOfBusiness: String) = + natureOfBusiness(JsonField.of(natureOfBusiness)) + + /** + * Sets [Builder.natureOfBusiness] to an arbitrary JSON value. + * + * You should usually call [Builder.natureOfBusiness] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun natureOfBusiness(natureOfBusiness: JsonField) = apply { + this.natureOfBusiness = natureOfBusiness + } + + /** Company website URL. */ + fun websiteUrl(websiteUrl: String) = websiteUrl(JsonField.of(websiteUrl)) + + /** + * Sets [Builder.websiteUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.websiteUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun websiteUrl(websiteUrl: JsonField) = apply { this.websiteUrl = websiteUrl } + + 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 [KybPayload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .updateRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): KybPayload = + KybPayload( + checkRequired("token", token), + checkRequired("updateRequest", updateRequest), + eventType, + externalId, + natureOfBusiness, + websiteUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): KybPayload = apply { + if (validated) { + return@apply + } + + token() + updateRequest().validate() + eventType().ifPresent { it.validate() } + externalId() + natureOfBusiness() + websiteUrl() + 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) + + (updateRequest.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (if (natureOfBusiness.asKnown().isPresent) 1 else 0) + + (if (websiteUrl.asKnown().isPresent) 1 else 0) + + /** Original request to update the account holder. */ + class UpdateRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val beneficialOwnerEntities: JsonField>, + private val beneficialOwnerIndividuals: JsonField>, + private val businessEntity: JsonField, + private val controlPerson: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("beneficial_owner_entities") + @ExcludeMissing + beneficialOwnerEntities: JsonField> = JsonMissing.of(), + @JsonProperty("beneficial_owner_individuals") + @ExcludeMissing + beneficialOwnerIndividuals: JsonField> = JsonMissing.of(), + @JsonProperty("business_entity") + @ExcludeMissing + businessEntity: JsonField = JsonMissing.of(), + @JsonProperty("control_person") + @ExcludeMissing + controlPerson: JsonField = JsonMissing.of(), + ) : this( + beneficialOwnerEntities, + beneficialOwnerIndividuals, + businessEntity, + controlPerson, + mutableMapOf(), + ) + + /** + * Deprecated. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + @Deprecated("deprecated") + fun beneficialOwnerEntities(): Optional> = + beneficialOwnerEntities.getOptional("beneficial_owner_entities") + + /** + * You must submit a list of all direct and indirect individuals with 25% or more + * ownership in the company. A maximum of 4 beneficial owners can be submitted. If no + * individual owns 25% of the company you do not need to send beneficial owner + * information. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section I) for more background on individuals that should be included. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun beneficialOwnerIndividuals(): Optional> = + beneficialOwnerIndividuals.getOptional("beneficial_owner_individuals") + + /** + * Information for business for which the account is being opened and KYB is being run. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun businessEntity(): Optional = + businessEntity.getOptional("business_entity") + + /** + * An individual with significant responsibility for managing the legal entity (e.g., a + * Chief Executive Officer, Chief Financial Officer, Chief Operating Officer, Managing + * Member, General Partner, President, Vice President, or Treasurer). This can be an + * executive, or someone who will have program-wide access to the cards that Lithic will + * provide. In some cases, this individual could also be a beneficial owner listed + * above. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section II) for more background. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun controlPerson(): Optional = controlPerson.getOptional("control_person") + + /** + * Returns the raw JSON value of [beneficialOwnerEntities]. + * + * Unlike [beneficialOwnerEntities], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("beneficial_owner_entities") + @ExcludeMissing + fun _beneficialOwnerEntities(): JsonField> = + beneficialOwnerEntities + + /** + * Returns the raw JSON value of [beneficialOwnerIndividuals]. + * + * Unlike [beneficialOwnerIndividuals], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("beneficial_owner_individuals") + @ExcludeMissing + fun _beneficialOwnerIndividuals(): JsonField> = + beneficialOwnerIndividuals + + /** + * Returns the raw JSON value of [businessEntity]. + * + * Unlike [businessEntity], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("business_entity") + @ExcludeMissing + fun _businessEntity(): JsonField = businessEntity + + /** + * Returns the raw JSON value of [controlPerson]. + * + * Unlike [controlPerson], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("control_person") + @ExcludeMissing + fun _controlPerson(): JsonField = controlPerson + + @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 [UpdateRequest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateRequest]. */ + class Builder internal constructor() { + + private var beneficialOwnerEntities: JsonField>? = + null + private var beneficialOwnerIndividuals: JsonField>? = null + private var businessEntity: JsonField = JsonMissing.of() + private var controlPerson: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateRequest: UpdateRequest) = apply { + beneficialOwnerEntities = + updateRequest.beneficialOwnerEntities.map { it.toMutableList() } + beneficialOwnerIndividuals = + updateRequest.beneficialOwnerIndividuals.map { it.toMutableList() } + businessEntity = updateRequest.businessEntity + controlPerson = updateRequest.controlPerson + additionalProperties = updateRequest.additionalProperties.toMutableMap() + } + + /** Deprecated. */ + @Deprecated("deprecated") + fun beneficialOwnerEntities(beneficialOwnerEntities: List) = + beneficialOwnerEntities(JsonField.of(beneficialOwnerEntities)) + + /** + * Sets [Builder.beneficialOwnerEntities] to an arbitrary JSON value. + * + * You should usually call [Builder.beneficialOwnerEntities] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + @Deprecated("deprecated") + fun beneficialOwnerEntities( + beneficialOwnerEntities: JsonField> + ) = apply { + this.beneficialOwnerEntities = + beneficialOwnerEntities.map { it.toMutableList() } + } + + /** + * Adds a single [KybBusinessEntity] to [beneficialOwnerEntities]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + @Deprecated("deprecated") + fun addBeneficialOwnerEntity(beneficialOwnerEntity: KybBusinessEntity) = apply { + beneficialOwnerEntities = + (beneficialOwnerEntities ?: JsonField.of(mutableListOf())).also { + checkKnown("beneficialOwnerEntities", it).add(beneficialOwnerEntity) + } + } + + /** + * You must submit a list of all direct and indirect individuals with 25% or more + * ownership in the company. A maximum of 4 beneficial owners can be submitted. If + * no individual owns 25% of the company you do not need to send beneficial owner + * information. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section I) for more background on individuals that should be included. + */ + fun beneficialOwnerIndividuals(beneficialOwnerIndividuals: List) = + beneficialOwnerIndividuals(JsonField.of(beneficialOwnerIndividuals)) + + /** + * Sets [Builder.beneficialOwnerIndividuals] to an arbitrary JSON value. + * + * You should usually call [Builder.beneficialOwnerIndividuals] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun beneficialOwnerIndividuals( + beneficialOwnerIndividuals: JsonField> + ) = apply { + this.beneficialOwnerIndividuals = + beneficialOwnerIndividuals.map { it.toMutableList() } + } + + /** + * Adds a single [Individual] to [beneficialOwnerIndividuals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeneficialOwnerIndividual(beneficialOwnerIndividual: Individual) = apply { + beneficialOwnerIndividuals = + (beneficialOwnerIndividuals ?: JsonField.of(mutableListOf())).also { + checkKnown("beneficialOwnerIndividuals", it) + .add(beneficialOwnerIndividual) + } + } + + /** + * Information for business for which the account is being opened and KYB is being + * run. + */ + fun businessEntity(businessEntity: KybBusinessEntity) = + businessEntity(JsonField.of(businessEntity)) + + /** + * Sets [Builder.businessEntity] to an arbitrary JSON value. + * + * You should usually call [Builder.businessEntity] with a well-typed + * [KybBusinessEntity] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun businessEntity(businessEntity: JsonField) = apply { + this.businessEntity = businessEntity + } + + /** + * An individual with significant responsibility for managing the legal entity + * (e.g., a Chief Executive Officer, Chief Financial Officer, Chief Operating + * Officer, Managing Member, General Partner, President, Vice President, or + * Treasurer). This can be an executive, or someone who will have program-wide + * access to the cards that Lithic will provide. In some cases, this individual + * could also be a beneficial owner listed above. See + * [FinCEN requirements](https://www.fincen.gov/sites/default/files/shared/CDD_Rev6.7_Sept_2017_Certificate.pdf) + * (Section II) for more background. + */ + fun controlPerson(controlPerson: Individual) = + controlPerson(JsonField.of(controlPerson)) + + /** + * Sets [Builder.controlPerson] to an arbitrary JSON value. + * + * You should usually call [Builder.controlPerson] with a well-typed [Individual] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun controlPerson(controlPerson: JsonField) = apply { + this.controlPerson = controlPerson + } + + 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 [UpdateRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdateRequest = + UpdateRequest( + (beneficialOwnerEntities ?: JsonMissing.of()).map { it.toImmutable() }, + (beneficialOwnerIndividuals ?: JsonMissing.of()).map { it.toImmutable() }, + businessEntity, + controlPerson, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UpdateRequest = apply { + if (validated) { + return@apply + } + + beneficialOwnerEntities().ifPresent { it.forEach { it.validate() } } + beneficialOwnerIndividuals().ifPresent { it.forEach { it.validate() } } + businessEntity().ifPresent { it.validate() } + controlPerson().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 = + (beneficialOwnerEntities.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (beneficialOwnerIndividuals.asKnown().getOrNull()?.sumOf { + it.validity().toInt() + } ?: 0) + + (businessEntity.asKnown().getOrNull()?.validity() ?: 0) + + (controlPerson.asKnown().getOrNull()?.validity() ?: 0) + + class Individual + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField
, + private val dob: JsonField, + private val email: JsonField, + private val firstName: JsonField, + private val governmentId: JsonField, + private val lastName: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") + @ExcludeMissing + address: JsonField
= JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + firstName: JsonField = JsonMissing.of(), + @JsonProperty("government_id") + @ExcludeMissing + governmentId: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + lastName: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + mutableMapOf(), + ) + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently supported. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun address(): Optional
= address.getOptional("address") + + /** + * Individual's date of birth, as an RFC 3339 date. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dob(): Optional = dob.getOptional("dob") + + /** + * Individual's email address. If utilizing Lithic for chargeback processing, this + * customer email address may be used to communicate dispute status and resolution. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Individual's first name, as it appears on government-issued identity documents. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun firstName(): Optional = firstName.getOptional("first_name") + + /** + * Government-issued identification number (required for identity verification and + * compliance with banking regulations). Social Security Numbers (SSN) and + * Individual Taxpayer Identification Numbers (ITIN) are currently supported, + * entered as full nine-digits, with or without hyphens + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun governmentId(): Optional = governmentId.getOptional("government_id") + + /** + * Individual's last name, as it appears on government-issued identity documents. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lastName(): Optional = lastName.getOptional("last_name") + + /** + * Individual's phone number, entered in E.164 format. + * + * @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") + + /** + * 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 [dob]. + * + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName + + /** + * Returns the raw JSON value of [governmentId]. + * + * Unlike [governmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId + + /** + * Returns the raw JSON value of [lastName]. + * + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName + + /** + * 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 + + @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 [Individual]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Individual]. */ + class Builder internal constructor() { + + private var address: JsonField
= JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var governmentId: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(individual: Individual) = apply { + address = individual.address + dob = individual.dob + email = individual.email + firstName = individual.firstName + governmentId = individual.governmentId + lastName = individual.lastName + phoneNumber = individual.phoneNumber + additionalProperties = individual.additionalProperties.toMutableMap() + } + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently + * supported. + */ + fun address(address: Address) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [Address] 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 } + + /** Individual's date of birth, as an RFC 3339 date. */ + fun dob(dob: String) = dob(JsonField.of(dob)) + + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** + * Individual's email address. If utilizing Lithic for chargeback processing, + * this customer email address may be used to communicate dispute status and + * resolution. + */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** + * Individual's first name, as it appears on government-issued identity + * documents. + */ + fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun firstName(firstName: JsonField) = apply { + this.firstName = firstName + } + + /** + * Government-issued identification number (required for identity verification + * and compliance with banking regulations). Social Security Numbers (SSN) and + * Individual Taxpayer Identification Numbers (ITIN) are currently supported, + * entered as full nine-digits, with or without hyphens + */ + fun governmentId(governmentId: String) = + governmentId(JsonField.of(governmentId)) + + /** + * Sets [Builder.governmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.governmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun governmentId(governmentId: JsonField) = apply { + this.governmentId = governmentId + } + + /** + * Individual's last name, as it appears on government-issued identity + * documents. + */ + fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + + /** + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + /** Individual's phone number, entered in E.164 format. */ + 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 + } + + 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 [Individual]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Individual = + Individual( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Individual = apply { + if (validated) { + return@apply + } + + address().ifPresent { it.validate() } + dob() + email() + firstName() + governmentId() + lastName() + phoneNumber() + 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 = + (address.asKnown().getOrNull()?.validity() ?: 0) + + (if (dob.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (if (governmentId.asKnown().isPresent) 1 else 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently supported. + */ + class Address + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address1: JsonField, + private val city: JsonField, + private val country: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val address2: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address1") + @ExcludeMissing + address1: JsonField = JsonMissing.of(), + @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("address2") + @ExcludeMissing + address2: JsonField = JsonMissing.of(), + ) : this(address1, city, country, postalCode, state, address2, mutableMapOf()) + + /** + * Valid deliverable address (no PO boxes). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun address1(): String = address1.getRequired("address1") + + /** + * Name of city. + * + * @throws LithicInvalidDataException if 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") + + /** + * Valid country code. Only USA is currently supported, entered in uppercase ISO + * 3166-1 alpha-3 three-character format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Valid postal code. Only USA ZIP codes are currently supported, entered as a + * five-digit ZIP or nine-digit ZIP+4. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun postalCode(): String = postalCode.getRequired("postal_code") + + /** + * Valid state code. Only USA state codes are currently supported, entered in + * uppercase ISO 3166-2 two-character format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun state(): String = state.getRequired("state") + + /** + * Unit or apartment number (if applicable). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun address2(): Optional = address2.getOptional("address2") + + /** + * Returns the raw JSON value of [address1]. + * + * Unlike [address1], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address1") + @ExcludeMissing + fun _address1(): JsonField = address1 + + /** + * 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 [address2]. + * + * Unlike [address2], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address2") + @ExcludeMissing + fun _address2(): JsonField = address2 + + @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 [Address]. + * + * The following fields are required: + * ```java + * .address1() + * .city() + * .country() + * .postalCode() + * .state() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Address]. */ + class Builder internal constructor() { + + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null + private var address2: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(address: Address) = apply { + address1 = address.address1 + city = address.city + country = address.country + postalCode = address.postalCode + state = address.state + address2 = address.address2 + additionalProperties = address.additionalProperties.toMutableMap() + } + + /** Valid deliverable address (no PO boxes). */ + fun address1(address1: String) = address1(JsonField.of(address1)) + + /** + * Sets [Builder.address1] to an arbitrary JSON value. + * + * You should usually call [Builder.address1] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun address1(address1: JsonField) = apply { + this.address1 = address1 + } + + /** Name of city. */ + 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 } + + /** + * Valid country code. Only USA is currently supported, entered in uppercase + * ISO 3166-1 alpha-3 three-character format. + */ + 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 } + + /** + * Valid postal code. Only USA ZIP codes are currently supported, entered as + * a five-digit ZIP or nine-digit ZIP+4. + */ + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun postalCode(postalCode: JsonField) = apply { + this.postalCode = postalCode + } + + /** + * Valid state code. Only USA state codes are currently supported, entered + * in uppercase ISO 3166-2 two-character format. + */ + 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 } + + /** Unit or apartment number (if applicable). */ + fun address2(address2: String) = address2(JsonField.of(address2)) + + /** + * Sets [Builder.address2] to an arbitrary JSON value. + * + * You should usually call [Builder.address2] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun address2(address2: JsonField) = apply { + this.address2 = address2 + } + + 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 [Address]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .address1() + * .city() + * .country() + * .postalCode() + * .state() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Address = + Address( + checkRequired("address1", address1), + checkRequired("city", city), + checkRequired("country", country), + checkRequired("postalCode", postalCode), + checkRequired("state", state), + address2, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Address = apply { + if (validated) { + return@apply + } + + address1() + city() + country() + postalCode() + state() + address2() + 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 (address1.asKnown().isPresent) 1 else 0) + + (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 (address2.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Address && + address1 == other.address1 && + city == other.city && + country == other.country && + postalCode == other.postalCode && + state == other.state && + address2 == other.address2 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address1, + city, + country, + postalCode, + state, + address2, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Address{address1=$address1, city=$city, country=$country, postalCode=$postalCode, state=$state, address2=$address2, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Individual && + address == other.address && + dob == other.dob && + email == other.email && + firstName == other.firstName && + governmentId == other.governmentId && + lastName == other.lastName && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Individual{address=$address, dob=$dob, email=$email, firstName=$firstName, governmentId=$governmentId, lastName=$lastName, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateRequest && + beneficialOwnerEntities == other.beneficialOwnerEntities && + beneficialOwnerIndividuals == other.beneficialOwnerIndividuals && + businessEntity == other.businessEntity && + controlPerson == other.controlPerson && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + beneficialOwnerEntities, + beneficialOwnerIndividuals, + businessEntity, + controlPerson, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateRequest{beneficialOwnerEntities=$beneficialOwnerEntities, beneficialOwnerIndividuals=$beneficialOwnerIndividuals, businessEntity=$businessEntity, controlPerson=$controlPerson, 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 ACCOUNT_HOLDER_UPDATED = of("account_holder.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_UPDATED + } + + /** + * 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 { + ACCOUNT_HOLDER_UPDATED, + /** + * 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) { + ACCOUNT_HOLDER_UPDATED -> Value.ACCOUNT_HOLDER_UPDATED + 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) { + ACCOUNT_HOLDER_UPDATED -> Known.ACCOUNT_HOLDER_UPDATED + 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 + + 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 KybPayload && + token == other.token && + updateRequest == other.updateRequest && + eventType == other.eventType && + externalId == other.externalId && + natureOfBusiness == other.natureOfBusiness && + websiteUrl == other.websiteUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + updateRequest, + eventType, + externalId, + natureOfBusiness, + websiteUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "KybPayload{token=$token, updateRequest=$updateRequest, eventType=$eventType, externalId=$externalId, natureOfBusiness=$natureOfBusiness, websiteUrl=$websiteUrl, additionalProperties=$additionalProperties}" + } + + /** KYC payload for an updated account holder. */ + class KycPayload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val updateRequest: JsonField, + private val eventType: JsonField, + private val externalId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("update_request") + @ExcludeMissing + updateRequest: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + ) : this(token, updateRequest, eventType, externalId, mutableMapOf()) + + /** + * The token of the account_holder that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Original request to update the account holder. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updateRequest(): UpdateRequest = updateRequest.getRequired("update_request") + + /** + * The type of event that occurred. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventType(): Optional = eventType.getOptional("event_type") + + /** + * A user provided id that can be used to link an account holder with an external system + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * 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 [updateRequest]. + * + * Unlike [updateRequest], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("update_request") + @ExcludeMissing + fun _updateRequest(): JsonField = updateRequest + + /** + * 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 [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + + @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 [KycPayload]. + * + * The following fields are required: + * ```java + * .token() + * .updateRequest() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [KycPayload]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var updateRequest: JsonField? = null + private var eventType: JsonField = JsonMissing.of() + private var externalId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(kycPayload: KycPayload) = apply { + token = kycPayload.token + updateRequest = kycPayload.updateRequest + eventType = kycPayload.eventType + externalId = kycPayload.externalId + additionalProperties = kycPayload.additionalProperties.toMutableMap() + } + + /** The token of the account_holder that was created. */ + 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 } + + /** Original request to update the account holder. */ + fun updateRequest(updateRequest: UpdateRequest) = + updateRequest(JsonField.of(updateRequest)) + + /** + * Sets [Builder.updateRequest] to an arbitrary JSON value. + * + * You should usually call [Builder.updateRequest] with a well-typed [UpdateRequest] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun updateRequest(updateRequest: JsonField) = apply { + this.updateRequest = updateRequest + } + + /** 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 } + + /** + * A user provided id that can be used to link an account holder with an external system + */ + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + 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 [KycPayload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .updateRequest() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): KycPayload = + KycPayload( + checkRequired("token", token), + checkRequired("updateRequest", updateRequest), + eventType, + externalId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): KycPayload = apply { + if (validated) { + return@apply + } + + token() + updateRequest().validate() + eventType().ifPresent { it.validate() } + externalId() + 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) + + (updateRequest.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + /** Original request to update the account holder. */ + class UpdateRequest + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val individual: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("individual") + @ExcludeMissing + individual: JsonField = JsonMissing.of() + ) : this(individual, mutableMapOf()) + + /** + * Information on the individual for whom the account is being opened and KYC is being + * run. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun individual(): Optional = individual.getOptional("individual") + + /** + * Returns the raw JSON value of [individual]. + * + * Unlike [individual], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("individual") + @ExcludeMissing + fun _individual(): JsonField = individual + + @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 [UpdateRequest]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UpdateRequest]. */ + class Builder internal constructor() { + + private var individual: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(updateRequest: UpdateRequest) = apply { + individual = updateRequest.individual + additionalProperties = updateRequest.additionalProperties.toMutableMap() + } + + /** + * Information on the individual for whom the account is being opened and KYC is + * being run. + */ + fun individual(individual: Individual) = individual(JsonField.of(individual)) + + /** + * Sets [Builder.individual] to an arbitrary JSON value. + * + * You should usually call [Builder.individual] with a well-typed [Individual] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun individual(individual: JsonField) = apply { + this.individual = individual + } + + 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 [UpdateRequest]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UpdateRequest = + UpdateRequest(individual, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): UpdateRequest = apply { + if (validated) { + return@apply + } + + individual().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 = (individual.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Information on the individual for whom the account is being opened and KYC is being + * run. + */ + class Individual + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField
, + private val dob: JsonField, + private val email: JsonField, + private val firstName: JsonField, + private val governmentId: JsonField, + private val lastName: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") + @ExcludeMissing + address: JsonField
= JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + firstName: JsonField = JsonMissing.of(), + @JsonProperty("government_id") + @ExcludeMissing + governmentId: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + lastName: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + mutableMapOf(), + ) + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently supported. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun address(): Optional
= address.getOptional("address") + + /** + * Individual's date of birth, as an RFC 3339 date. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun dob(): Optional = dob.getOptional("dob") + + /** + * Individual's email address. If utilizing Lithic for chargeback processing, this + * customer email address may be used to communicate dispute status and resolution. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Individual's first name, as it appears on government-issued identity documents. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun firstName(): Optional = firstName.getOptional("first_name") + + /** + * Government-issued identification number (required for identity verification and + * compliance with banking regulations). Social Security Numbers (SSN) and + * Individual Taxpayer Identification Numbers (ITIN) are currently supported, + * entered as full nine-digits, with or without hyphens + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun governmentId(): Optional = governmentId.getOptional("government_id") + + /** + * Individual's last name, as it appears on government-issued identity documents. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lastName(): Optional = lastName.getOptional("last_name") + + /** + * Individual's phone number, entered in E.164 format. + * + * @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") + + /** + * 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 [dob]. + * + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName + + /** + * Returns the raw JSON value of [governmentId]. + * + * Unlike [governmentId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("government_id") + @ExcludeMissing + fun _governmentId(): JsonField = governmentId + + /** + * Returns the raw JSON value of [lastName]. + * + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName + + /** + * 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 + + @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 [Individual]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Individual]. */ + class Builder internal constructor() { + + private var address: JsonField
= JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var governmentId: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(individual: Individual) = apply { + address = individual.address + dob = individual.dob + email = individual.email + firstName = individual.firstName + governmentId = individual.governmentId + lastName = individual.lastName + phoneNumber = individual.phoneNumber + additionalProperties = individual.additionalProperties.toMutableMap() + } + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently + * supported. + */ + fun address(address: Address) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [Address] 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 } + + /** Individual's date of birth, as an RFC 3339 date. */ + fun dob(dob: String) = dob(JsonField.of(dob)) + + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** + * Individual's email address. If utilizing Lithic for chargeback processing, + * this customer email address may be used to communicate dispute status and + * resolution. + */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** + * Individual's first name, as it appears on government-issued identity + * documents. + */ + fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun firstName(firstName: JsonField) = apply { + this.firstName = firstName + } + + /** + * Government-issued identification number (required for identity verification + * and compliance with banking regulations). Social Security Numbers (SSN) and + * Individual Taxpayer Identification Numbers (ITIN) are currently supported, + * entered as full nine-digits, with or without hyphens + */ + fun governmentId(governmentId: String) = + governmentId(JsonField.of(governmentId)) + + /** + * Sets [Builder.governmentId] to an arbitrary JSON value. + * + * You should usually call [Builder.governmentId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun governmentId(governmentId: JsonField) = apply { + this.governmentId = governmentId + } + + /** + * Individual's last name, as it appears on government-issued identity + * documents. + */ + fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + + /** + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + /** Individual's phone number, entered in E.164 format. */ + 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 + } + + 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 [Individual]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Individual = + Individual( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Individual = apply { + if (validated) { + return@apply + } + + address().ifPresent { it.validate() } + dob() + email() + firstName() + governmentId() + lastName() + phoneNumber() + 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 = + (address.asKnown().getOrNull()?.validity() ?: 0) + + (if (dob.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (if (governmentId.asKnown().isPresent) 1 else 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + /** + * Individual's current address - PO boxes, UPS drops, and FedEx drops are not + * acceptable; APO/FPO are acceptable. Only USA addresses are currently supported. + */ + class Address + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address1: JsonField, + private val city: JsonField, + private val country: JsonField, + private val postalCode: JsonField, + private val state: JsonField, + private val address2: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address1") + @ExcludeMissing + address1: JsonField = JsonMissing.of(), + @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("address2") + @ExcludeMissing + address2: JsonField = JsonMissing.of(), + ) : this(address1, city, country, postalCode, state, address2, mutableMapOf()) + + /** + * Valid deliverable address (no PO boxes). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun address1(): String = address1.getRequired("address1") + + /** + * Name of city. + * + * @throws LithicInvalidDataException if 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") + + /** + * Valid country code. Only USA is currently supported, entered in uppercase ISO + * 3166-1 alpha-3 three-character format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun country(): String = country.getRequired("country") + + /** + * Valid postal code. Only USA ZIP codes are currently supported, entered as a + * five-digit ZIP or nine-digit ZIP+4. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun postalCode(): String = postalCode.getRequired("postal_code") + + /** + * Valid state code. Only USA state codes are currently supported, entered in + * uppercase ISO 3166-2 two-character format. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun state(): String = state.getRequired("state") + + /** + * Unit or apartment number (if applicable). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun address2(): Optional = address2.getOptional("address2") + + /** + * Returns the raw JSON value of [address1]. + * + * Unlike [address1], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address1") + @ExcludeMissing + fun _address1(): JsonField = address1 + + /** + * 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 [address2]. + * + * Unlike [address2], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("address2") + @ExcludeMissing + fun _address2(): JsonField = address2 + + @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 [Address]. + * + * The following fields are required: + * ```java + * .address1() + * .city() + * .country() + * .postalCode() + * .state() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Address]. */ + class Builder internal constructor() { + + private var address1: JsonField? = null + private var city: JsonField? = null + private var country: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null + private var address2: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(address: Address) = apply { + address1 = address.address1 + city = address.city + country = address.country + postalCode = address.postalCode + state = address.state + address2 = address.address2 + additionalProperties = address.additionalProperties.toMutableMap() + } + + /** Valid deliverable address (no PO boxes). */ + fun address1(address1: String) = address1(JsonField.of(address1)) + + /** + * Sets [Builder.address1] to an arbitrary JSON value. + * + * You should usually call [Builder.address1] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun address1(address1: JsonField) = apply { + this.address1 = address1 + } + + /** Name of city. */ + 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 } + + /** + * Valid country code. Only USA is currently supported, entered in uppercase + * ISO 3166-1 alpha-3 three-character format. + */ + 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 } + + /** + * Valid postal code. Only USA ZIP codes are currently supported, entered as + * a five-digit ZIP or nine-digit ZIP+4. + */ + fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + + /** + * Sets [Builder.postalCode] to an arbitrary JSON value. + * + * You should usually call [Builder.postalCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun postalCode(postalCode: JsonField) = apply { + this.postalCode = postalCode + } + + /** + * Valid state code. Only USA state codes are currently supported, entered + * in uppercase ISO 3166-2 two-character format. + */ + 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 } + + /** Unit or apartment number (if applicable). */ + fun address2(address2: String) = address2(JsonField.of(address2)) + + /** + * Sets [Builder.address2] to an arbitrary JSON value. + * + * You should usually call [Builder.address2] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun address2(address2: JsonField) = apply { + this.address2 = address2 + } + + 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 [Address]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .address1() + * .city() + * .country() + * .postalCode() + * .state() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Address = + Address( + checkRequired("address1", address1), + checkRequired("city", city), + checkRequired("country", country), + checkRequired("postalCode", postalCode), + checkRequired("state", state), + address2, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Address = apply { + if (validated) { + return@apply + } + + address1() + city() + country() + postalCode() + state() + address2() + 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 (address1.asKnown().isPresent) 1 else 0) + + (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 (address2.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Address && + address1 == other.address1 && + city == other.city && + country == other.country && + postalCode == other.postalCode && + state == other.state && + address2 == other.address2 && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address1, + city, + country, + postalCode, + state, + address2, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Address{address1=$address1, city=$city, country=$country, postalCode=$postalCode, state=$state, address2=$address2, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Individual && + address == other.address && + dob == other.dob && + email == other.email && + firstName == other.firstName && + governmentId == other.governmentId && + lastName == other.lastName && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address, + dob, + email, + firstName, + governmentId, + lastName, + phoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Individual{address=$address, dob=$dob, email=$email, firstName=$firstName, governmentId=$governmentId, lastName=$lastName, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UpdateRequest && + individual == other.individual && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(individual, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UpdateRequest{individual=$individual, 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 ACCOUNT_HOLDER_UPDATED = of("account_holder.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_UPDATED + } + + /** + * 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 { + ACCOUNT_HOLDER_UPDATED, + /** + * 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) { + ACCOUNT_HOLDER_UPDATED -> Value.ACCOUNT_HOLDER_UPDATED + 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) { + ACCOUNT_HOLDER_UPDATED -> Known.ACCOUNT_HOLDER_UPDATED + 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 + + 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 KycPayload && + token == other.token && + updateRequest == other.updateRequest && + eventType == other.eventType && + externalId == other.externalId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(token, updateRequest, eventType, externalId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "KycPayload{token=$token, updateRequest=$updateRequest, eventType=$eventType, externalId=$externalId, additionalProperties=$additionalProperties}" + } + + /** Legacy payload for an updated account holder. */ + class LegacyPayload + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val businessAccountToken: JsonField, + private val created: JsonField, + private val email: JsonField, + private val eventType: JsonField, + private val externalId: JsonField, + private val firstName: JsonField, + private val lastName: JsonField, + private val legalBusinessName: JsonField, + private val phoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("business_account_token") + @ExcludeMissing + businessAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + firstName: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + lastName: JsonField = JsonMissing.of(), + @JsonProperty("legal_business_name") + @ExcludeMissing + legalBusinessName: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + ) : this( + token, + businessAccountToken, + created, + email, + eventType, + externalId, + firstName, + lastName, + legalBusinessName, + phoneNumber, + mutableMapOf(), + ) + + /** + * The token of the account_holder that was created. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * If applicable, represents the business account token associated with the account_holder. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun businessAccountToken(): Optional = + businessAccountToken.getOptional("business_account_token") + + /** + * When the account_holder updated event was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") + + /** + * If updated, the newly updated email associated with the account_holder otherwise the + * existing email is provided. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * The type of event that occurred. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun eventType(): Optional = eventType.getOptional("event_type") + + /** + * If applicable, represents the external_id associated with the account_holder. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") + + /** + * If applicable, represents the account_holder's first name. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun firstName(): Optional = firstName.getOptional("first_name") + + /** + * If applicable, represents the account_holder's last name. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastName(): Optional = lastName.getOptional("last_name") + + /** + * If applicable, represents the account_holder's business name. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun legalBusinessName(): Optional = + legalBusinessName.getOptional("legal_business_name") + + /** + * If updated, the newly updated phone_number associated with the account_holder otherwise + * the existing phone_number is provided. + * + * @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") + + /** + * 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 [businessAccountToken]. + * + * Unlike [businessAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("business_account_token") + @ExcludeMissing + fun _businessAccountToken(): JsonField = businessAccountToken + + /** + * 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 [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * 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 [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + + /** + * Returns the raw JSON value of [firstName]. + * + * Unlike [firstName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName + + /** + * Returns the raw JSON value of [lastName]. + * + * Unlike [lastName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName + + /** + * Returns the raw JSON value of [legalBusinessName]. + * + * Unlike [legalBusinessName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("legal_business_name") + @ExcludeMissing + fun _legalBusinessName(): JsonField = legalBusinessName + + /** + * 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 + + @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 [LegacyPayload]. + * + * The following fields are required: + * ```java + * .token() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LegacyPayload]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var businessAccountToken: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var eventType: JsonField = JsonMissing.of() + private var externalId: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var legalBusinessName: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(legacyPayload: LegacyPayload) = apply { + token = legacyPayload.token + businessAccountToken = legacyPayload.businessAccountToken + created = legacyPayload.created + email = legacyPayload.email + eventType = legacyPayload.eventType + externalId = legacyPayload.externalId + firstName = legacyPayload.firstName + lastName = legacyPayload.lastName + legalBusinessName = legacyPayload.legalBusinessName + phoneNumber = legacyPayload.phoneNumber + additionalProperties = legacyPayload.additionalProperties.toMutableMap() + } + + /** The token of the account_holder that was created. */ + 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 } + + /** + * If applicable, represents the business account token associated with the + * account_holder. + */ + fun businessAccountToken(businessAccountToken: String?) = + businessAccountToken(JsonField.ofNullable(businessAccountToken)) + + /** + * Alias for calling [Builder.businessAccountToken] with + * `businessAccountToken.orElse(null)`. + */ + fun businessAccountToken(businessAccountToken: Optional) = + businessAccountToken(businessAccountToken.getOrNull()) + + /** + * Sets [Builder.businessAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.businessAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun businessAccountToken(businessAccountToken: JsonField) = apply { + this.businessAccountToken = businessAccountToken + } + + /** When the account_holder updated event was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** + * If updated, the newly updated email associated with the account_holder otherwise the + * existing email is provided. + */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** 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 } + + /** If applicable, represents the external_id associated with the account_holder. */ + fun externalId(externalId: String?) = externalId(JsonField.ofNullable(externalId)) + + /** Alias for calling [Builder.externalId] with `externalId.orElse(null)`. */ + fun externalId(externalId: Optional) = externalId(externalId.getOrNull()) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + + /** If applicable, represents the account_holder's first name. */ + fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + + /** + * Sets [Builder.firstName] to an arbitrary JSON value. + * + * You should usually call [Builder.firstName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun firstName(firstName: JsonField) = apply { this.firstName = firstName } + + /** If applicable, represents the account_holder's last name. */ + fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + + /** + * Sets [Builder.lastName] to an arbitrary JSON value. + * + * You should usually call [Builder.lastName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + /** If applicable, represents the account_holder's business name. */ + fun legalBusinessName(legalBusinessName: String) = + legalBusinessName(JsonField.of(legalBusinessName)) + + /** + * Sets [Builder.legalBusinessName] to an arbitrary JSON value. + * + * You should usually call [Builder.legalBusinessName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun legalBusinessName(legalBusinessName: JsonField) = apply { + this.legalBusinessName = legalBusinessName + } + + /** + * If updated, the newly updated phone_number associated with the account_holder + * otherwise the existing phone_number is provided. + */ + 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 + } + + 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 [LegacyPayload]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): LegacyPayload = + LegacyPayload( + checkRequired("token", token), + businessAccountToken, + created, + email, + eventType, + externalId, + firstName, + lastName, + legalBusinessName, + phoneNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LegacyPayload = apply { + if (validated) { + return@apply + } + + token() + businessAccountToken() + created() + email() + eventType().ifPresent { it.validate() } + externalId() + firstName() + lastName() + legalBusinessName() + phoneNumber() + 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 (businessAccountToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (if (firstName.asKnown().isPresent) 1 else 0) + + (if (lastName.asKnown().isPresent) 1 else 0) + + (if (legalBusinessName.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + /** 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 ACCOUNT_HOLDER_UPDATED = of("account_holder.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + ACCOUNT_HOLDER_UPDATED + } + + /** + * 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 { + ACCOUNT_HOLDER_UPDATED, + /** + * 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) { + ACCOUNT_HOLDER_UPDATED -> Value.ACCOUNT_HOLDER_UPDATED + 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) { + ACCOUNT_HOLDER_UPDATED -> Known.ACCOUNT_HOLDER_UPDATED + 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 + + 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 LegacyPayload && + token == other.token && + businessAccountToken == other.businessAccountToken && + created == other.created && + email == other.email && + eventType == other.eventType && + externalId == other.externalId && + firstName == other.firstName && + lastName == other.lastName && + legalBusinessName == other.legalBusinessName && + phoneNumber == other.phoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + businessAccountToken, + created, + email, + eventType, + externalId, + firstName, + lastName, + legalBusinessName, + phoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LegacyPayload{token=$token, businessAccountToken=$businessAccountToken, created=$created, email=$email, eventType=$eventType, externalId=$externalId, firstName=$firstName, lastName=$lastName, legalBusinessName=$legalBusinessName, phoneNumber=$phoneNumber, additionalProperties=$additionalProperties}" + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentTransactionCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentTransactionCreatedWebhookEvent.kt new file mode 100644 index 000000000..288e503c4 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentTransactionCreatedWebhookEvent.kt @@ -0,0 +1,1339 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Payment transaction */ +class PaymentTransactionCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val descriptor: JsonField, + private val direction: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val method: JsonField, + private val methodAttributes: JsonField, + private val pendingAmount: JsonField, + private val relatedAccountTokens: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val source: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val currency: JsonField, + private val expectedReleaseDate: JsonField, + private val externalBankAccountToken: JsonField, + private val type: JsonField, + private val userDefinedId: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("method") + @ExcludeMissing + method: JsonField = JsonMissing.of(), + @JsonProperty("method_attributes") + @ExcludeMissing + methodAttributes: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("related_account_tokens") + @ExcludeMissing + relatedAccountTokens: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + source: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("expected_release_date") + @ExcludeMissing + expectedReleaseDate: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_account_token") + @ExcludeMissing + externalBankAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + descriptor, + direction, + events, + family, + financialAccountToken, + method, + methodAttributes, + pendingAmount, + relatedAccountTokens, + result, + settledAmount, + source, + status, + updated, + currency, + expectedReleaseDate, + externalBankAccountToken, + type, + userDefinedId, + eventType, + mutableMapOf(), + ) + + fun toPayment(): Payment = + Payment.builder() + .token(token) + .category(category) + .created(created) + .descriptor(descriptor) + .direction(direction) + .events(events) + .family(family) + .financialAccountToken(financialAccountToken) + .method(method) + .methodAttributes(methodAttributes) + .pendingAmount(pendingAmount) + .relatedAccountTokens(relatedAccountTokens) + .result(result) + .settledAmount(settledAmount) + .source(source) + .status(status) + .updated(updated) + .currency(currency) + .expectedReleaseDate(expectedReleaseDate) + .externalBankAccountToken(externalBankAccountToken) + .type(type) + .userDefinedId(userDefinedId) + .build() + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Transaction category + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): Payment.TransactionCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * Transaction descriptor + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun descriptor(): String = descriptor.getRequired("descriptor") + + /** + * Transfer direction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun direction(): Payment.Direction = direction.getRequired("direction") + + /** + * List of transaction events + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * PAYMENT - Payment Transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun family(): Payment.Family = family.getRequired("family") + + /** + * Financial account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * Transfer method + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun method(): Payment.Method = method.getRequired("method") + + /** + * Method-specific attributes + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun methodAttributes(): Payment.MethodAttributes = + methodAttributes.getRequired("method_attributes") + + /** + * Pending amount in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * Account tokens related to a payment transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun relatedAccountTokens(): Optional = + relatedAccountTokens.getOptional("related_account_tokens") + + /** + * Transaction result + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): Payment.TransactionResult = result.getRequired("result") + + /** + * Settled amount in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * Transaction source + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun source(): Payment.Source = source.getRequired("source") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Payment.TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Currency of the transaction in ISO 4217 format + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * Expected release date for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expectedReleaseDate(): Optional = + expectedReleaseDate.getOptional("expected_release_date") + + /** + * External bank account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalBankAccountToken(): Optional = + externalBankAccountToken.getOptional("external_bank_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * User-defined identifier + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") @ExcludeMissing fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [methodAttributes]. + * + * Unlike [methodAttributes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("method_attributes") + @ExcludeMissing + fun _methodAttributes(): JsonField = methodAttributes + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [relatedAccountTokens]. + * + * Unlike [relatedAccountTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("related_account_tokens") + @ExcludeMissing + fun _relatedAccountTokens(): JsonField = relatedAccountTokens + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [expectedReleaseDate]. + * + * Unlike [expectedReleaseDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expected_release_date") + @ExcludeMissing + fun _expectedReleaseDate(): JsonField = expectedReleaseDate + + /** + * Returns the raw JSON value of [externalBankAccountToken]. + * + * Unlike [externalBankAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun _externalBankAccountToken(): JsonField = externalBankAccountToken + + /** + * Returns the raw JSON value of [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 [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + /** + * 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 + * [PaymentTransactionCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .descriptor() + * .direction() + * .events() + * .family() + * .financialAccountToken() + * .method() + * .methodAttributes() + * .pendingAmount() + * .relatedAccountTokens() + * .result() + * .settledAmount() + * .source() + * .status() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentTransactionCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var descriptor: JsonField? = null + private var direction: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var financialAccountToken: JsonField? = null + private var method: JsonField? = null + private var methodAttributes: JsonField? = null + private var pendingAmount: JsonField? = null + private var relatedAccountTokens: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var source: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var expectedReleaseDate: JsonField = JsonMissing.of() + private var externalBankAccountToken: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + paymentTransactionCreatedWebhookEvent: PaymentTransactionCreatedWebhookEvent + ) = apply { + token = paymentTransactionCreatedWebhookEvent.token + category = paymentTransactionCreatedWebhookEvent.category + created = paymentTransactionCreatedWebhookEvent.created + descriptor = paymentTransactionCreatedWebhookEvent.descriptor + direction = paymentTransactionCreatedWebhookEvent.direction + events = paymentTransactionCreatedWebhookEvent.events.map { it.toMutableList() } + family = paymentTransactionCreatedWebhookEvent.family + financialAccountToken = paymentTransactionCreatedWebhookEvent.financialAccountToken + method = paymentTransactionCreatedWebhookEvent.method + methodAttributes = paymentTransactionCreatedWebhookEvent.methodAttributes + pendingAmount = paymentTransactionCreatedWebhookEvent.pendingAmount + relatedAccountTokens = paymentTransactionCreatedWebhookEvent.relatedAccountTokens + result = paymentTransactionCreatedWebhookEvent.result + settledAmount = paymentTransactionCreatedWebhookEvent.settledAmount + source = paymentTransactionCreatedWebhookEvent.source + status = paymentTransactionCreatedWebhookEvent.status + updated = paymentTransactionCreatedWebhookEvent.updated + currency = paymentTransactionCreatedWebhookEvent.currency + expectedReleaseDate = paymentTransactionCreatedWebhookEvent.expectedReleaseDate + externalBankAccountToken = + paymentTransactionCreatedWebhookEvent.externalBankAccountToken + type = paymentTransactionCreatedWebhookEvent.type + userDefinedId = paymentTransactionCreatedWebhookEvent.userDefinedId + eventType = paymentTransactionCreatedWebhookEvent.eventType + additionalProperties = + paymentTransactionCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Transaction category */ + fun category(category: Payment.TransactionCategory) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [Payment.TransactionCategory] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun category(category: JsonField) = apply { + this.category = category + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Transaction descriptor */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** + * Sets [Builder.descriptor] to an arbitrary JSON value. + * + * You should usually call [Builder.descriptor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** Transfer direction */ + fun direction(direction: Payment.Direction) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [Payment.Direction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun direction(direction: JsonField) = apply { + this.direction = direction + } + + /** List of transaction events */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [Payment.PaymentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: Payment.PaymentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** PAYMENT - Payment Transaction */ + fun family(family: Payment.Family) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [Payment.Family] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** Financial account token */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Transfer method */ + fun method(method: Payment.Method) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Payment.Method] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** Method-specific attributes */ + fun methodAttributes(methodAttributes: Payment.MethodAttributes) = + methodAttributes(JsonField.of(methodAttributes)) + + /** + * Sets [Builder.methodAttributes] to an arbitrary JSON value. + * + * You should usually call [Builder.methodAttributes] with a well-typed + * [Payment.MethodAttributes] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun methodAttributes(methodAttributes: JsonField) = apply { + this.methodAttributes = methodAttributes + } + + /** Alias for calling [methodAttributes] with `Payment.MethodAttributes.ofAch(ach)`. */ + fun methodAttributes(ach: Payment.MethodAttributes.AchMethodAttributes) = + methodAttributes(Payment.MethodAttributes.ofAch(ach)) + + /** Alias for calling [methodAttributes] with `Payment.MethodAttributes.ofWire(wire)`. */ + fun methodAttributes(wire: Payment.MethodAttributes.WireMethodAttributes) = + methodAttributes(Payment.MethodAttributes.ofWire(wire)) + + /** Pending amount in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + /** Account tokens related to a payment transaction */ + fun relatedAccountTokens(relatedAccountTokens: Payment.RelatedAccountTokens?) = + relatedAccountTokens(JsonField.ofNullable(relatedAccountTokens)) + + /** + * Alias for calling [Builder.relatedAccountTokens] with + * `relatedAccountTokens.orElse(null)`. + */ + fun relatedAccountTokens(relatedAccountTokens: Optional) = + relatedAccountTokens(relatedAccountTokens.getOrNull()) + + /** + * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedAccountTokens] with a well-typed + * [Payment.RelatedAccountTokens] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun relatedAccountTokens(relatedAccountTokens: JsonField) = + apply { + this.relatedAccountTokens = relatedAccountTokens + } + + /** Transaction result */ + fun result(result: Payment.TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Payment.TransactionResult] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Settled amount in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** Transaction source */ + fun source(source: Payment.Source) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Payment.Source] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The status of the transaction */ + fun status(status: Payment.TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Payment.TransactionStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** Currency of the transaction in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Expected release date for the transaction */ + fun expectedReleaseDate(expectedReleaseDate: LocalDate?) = + expectedReleaseDate(JsonField.ofNullable(expectedReleaseDate)) + + /** + * Alias for calling [Builder.expectedReleaseDate] with `expectedReleaseDate.orElse(null)`. + */ + fun expectedReleaseDate(expectedReleaseDate: Optional) = + expectedReleaseDate(expectedReleaseDate.getOrNull()) + + /** + * Sets [Builder.expectedReleaseDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedReleaseDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expectedReleaseDate(expectedReleaseDate: JsonField) = apply { + this.expectedReleaseDate = expectedReleaseDate + } + + /** External bank account token */ + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) + + /** + * Alias for calling [Builder.externalBankAccountToken] with + * `externalBankAccountToken.orElse(null)`. + */ + fun externalBankAccountToken(externalBankAccountToken: Optional) = + externalBankAccountToken(externalBankAccountToken.getOrNull()) + + /** + * Sets [Builder.externalBankAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.externalBankAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + fun type(type: Payment.TransferType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Payment.TransferType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** User-defined identifier */ + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** 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 [PaymentTransactionCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .descriptor() + * .direction() + * .events() + * .family() + * .financialAccountToken() + * .method() + * .methodAttributes() + * .pendingAmount() + * .relatedAccountTokens() + * .result() + * .settledAmount() + * .source() + * .status() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentTransactionCreatedWebhookEvent = + PaymentTransactionCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("descriptor", descriptor), + checkRequired("direction", direction), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("method", method), + checkRequired("methodAttributes", methodAttributes), + checkRequired("pendingAmount", pendingAmount), + checkRequired("relatedAccountTokens", relatedAccountTokens), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("source", source), + checkRequired("status", status), + checkRequired("updated", updated), + currency, + expectedReleaseDate, + externalBankAccountToken, + type, + userDefinedId, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentTransactionCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + descriptor() + direction().validate() + events().forEach { it.validate() } + family().validate() + financialAccountToken() + method().validate() + methodAttributes().validate() + pendingAmount() + relatedAccountTokens().ifPresent { it.validate() } + result().validate() + settledAmount() + source().validate() + status().validate() + updated() + currency() + expectedReleaseDate() + externalBankAccountToken() + type().ifPresent { it.validate() } + userDefinedId() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (direction.asKnown().getOrNull()?.validity() ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + (methodAttributes.asKnown().getOrNull()?.validity() ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (relatedAccountTokens.asKnown().getOrNull()?.validity() ?: 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expectedReleaseDate.asKnown().isPresent) 1 else 0) + + (if (externalBankAccountToken.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 PAYMENT_TRANSACTION_CREATED = of("payment_transaction.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + PAYMENT_TRANSACTION_CREATED + } + + /** + * 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 { + PAYMENT_TRANSACTION_CREATED, + /** + * 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) { + PAYMENT_TRANSACTION_CREATED -> Value.PAYMENT_TRANSACTION_CREATED + 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) { + PAYMENT_TRANSACTION_CREATED -> Known.PAYMENT_TRANSACTION_CREATED + 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 + + 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 PaymentTransactionCreatedWebhookEvent && + token == other.token && + category == other.category && + created == other.created && + descriptor == other.descriptor && + direction == other.direction && + events == other.events && + family == other.family && + financialAccountToken == other.financialAccountToken && + method == other.method && + methodAttributes == other.methodAttributes && + pendingAmount == other.pendingAmount && + relatedAccountTokens == other.relatedAccountTokens && + result == other.result && + settledAmount == other.settledAmount && + source == other.source && + status == other.status && + updated == other.updated && + currency == other.currency && + expectedReleaseDate == other.expectedReleaseDate && + externalBankAccountToken == other.externalBankAccountToken && + type == other.type && + userDefinedId == other.userDefinedId && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + descriptor, + direction, + events, + family, + financialAccountToken, + method, + methodAttributes, + pendingAmount, + relatedAccountTokens, + result, + settledAmount, + source, + status, + updated, + currency, + expectedReleaseDate, + externalBankAccountToken, + type, + userDefinedId, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentTransactionCreatedWebhookEvent{token=$token, category=$category, created=$created, descriptor=$descriptor, direction=$direction, events=$events, family=$family, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, currency=$currency, expectedReleaseDate=$expectedReleaseDate, externalBankAccountToken=$externalBankAccountToken, type=$type, userDefinedId=$userDefinedId, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentTransactionUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentTransactionUpdatedWebhookEvent.kt new file mode 100644 index 000000000..b1a1e812a --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/PaymentTransactionUpdatedWebhookEvent.kt @@ -0,0 +1,1339 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Payment transaction */ +class PaymentTransactionUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val category: JsonField, + private val created: JsonField, + private val descriptor: JsonField, + private val direction: JsonField, + private val events: JsonField>, + private val family: JsonField, + private val financialAccountToken: JsonField, + private val method: JsonField, + private val methodAttributes: JsonField, + private val pendingAmount: JsonField, + private val relatedAccountTokens: JsonField, + private val result: JsonField, + private val settledAmount: JsonField, + private val source: JsonField, + private val status: JsonField, + private val updated: JsonField, + private val currency: JsonField, + private val expectedReleaseDate: JsonField, + private val externalBankAccountToken: JsonField, + private val type: JsonField, + private val userDefinedId: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("events") + @ExcludeMissing + events: JsonField> = JsonMissing.of(), + @JsonProperty("family") + @ExcludeMissing + family: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("method") + @ExcludeMissing + method: JsonField = JsonMissing.of(), + @JsonProperty("method_attributes") + @ExcludeMissing + methodAttributes: JsonField = JsonMissing.of(), + @JsonProperty("pending_amount") + @ExcludeMissing + pendingAmount: JsonField = JsonMissing.of(), + @JsonProperty("related_account_tokens") + @ExcludeMissing + relatedAccountTokens: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("settled_amount") + @ExcludeMissing + settledAmount: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + source: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("expected_release_date") + @ExcludeMissing + expectedReleaseDate: JsonField = JsonMissing.of(), + @JsonProperty("external_bank_account_token") + @ExcludeMissing + externalBankAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("user_defined_id") + @ExcludeMissing + userDefinedId: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + category, + created, + descriptor, + direction, + events, + family, + financialAccountToken, + method, + methodAttributes, + pendingAmount, + relatedAccountTokens, + result, + settledAmount, + source, + status, + updated, + currency, + expectedReleaseDate, + externalBankAccountToken, + type, + userDefinedId, + eventType, + mutableMapOf(), + ) + + fun toPayment(): Payment = + Payment.builder() + .token(token) + .category(category) + .created(created) + .descriptor(descriptor) + .direction(direction) + .events(events) + .family(family) + .financialAccountToken(financialAccountToken) + .method(method) + .methodAttributes(methodAttributes) + .pendingAmount(pendingAmount) + .relatedAccountTokens(relatedAccountTokens) + .result(result) + .settledAmount(settledAmount) + .source(source) + .status(status) + .updated(updated) + .currency(currency) + .expectedReleaseDate(expectedReleaseDate) + .externalBankAccountToken(externalBankAccountToken) + .type(type) + .userDefinedId(userDefinedId) + .build() + + /** + * Unique identifier for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * Transaction category + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): Payment.TransactionCategory = category.getRequired("category") + + /** + * ISO 8601 timestamp of when the transaction was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * Transaction descriptor + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun descriptor(): String = descriptor.getRequired("descriptor") + + /** + * Transfer direction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun direction(): Payment.Direction = direction.getRequired("direction") + + /** + * List of transaction events + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun events(): List = events.getRequired("events") + + /** + * PAYMENT - Payment Transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun family(): Payment.Family = family.getRequired("family") + + /** + * Financial account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * Transfer method + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun method(): Payment.Method = method.getRequired("method") + + /** + * Method-specific attributes + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun methodAttributes(): Payment.MethodAttributes = + methodAttributes.getRequired("method_attributes") + + /** + * Pending amount in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pendingAmount(): Long = pendingAmount.getRequired("pending_amount") + + /** + * Account tokens related to a payment transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun relatedAccountTokens(): Optional = + relatedAccountTokens.getOptional("related_account_tokens") + + /** + * Transaction result + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun result(): Payment.TransactionResult = result.getRequired("result") + + /** + * Settled amount in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settledAmount(): Long = settledAmount.getRequired("settled_amount") + + /** + * Transaction source + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun source(): Payment.Source = source.getRequired("source") + + /** + * The status of the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Payment.TransactionStatus = status.getRequired("status") + + /** + * ISO 8601 timestamp of when the transaction was last updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * Currency of the transaction in ISO 4217 format + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * Expected release date for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expectedReleaseDate(): Optional = + expectedReleaseDate.getOptional("expected_release_date") + + /** + * External bank account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalBankAccountToken(): Optional = + externalBankAccountToken.getOptional("external_bank_account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * User-defined identifier + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userDefinedId(): Optional = userDefinedId.getOptional("user_defined_id") + + /** + * 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 [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") + @ExcludeMissing + fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") @ExcludeMissing fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [events]. + * + * Unlike [events], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("events") + @ExcludeMissing + fun _events(): JsonField> = events + + /** + * Returns the raw JSON value of [family]. + * + * Unlike [family], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("family") @ExcludeMissing fun _family(): JsonField = family + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [methodAttributes]. + * + * Unlike [methodAttributes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("method_attributes") + @ExcludeMissing + fun _methodAttributes(): JsonField = methodAttributes + + /** + * Returns the raw JSON value of [pendingAmount]. + * + * Unlike [pendingAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pending_amount") + @ExcludeMissing + fun _pendingAmount(): JsonField = pendingAmount + + /** + * Returns the raw JSON value of [relatedAccountTokens]. + * + * Unlike [relatedAccountTokens], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("related_account_tokens") + @ExcludeMissing + fun _relatedAccountTokens(): JsonField = relatedAccountTokens + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") + @ExcludeMissing + fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [settledAmount]. + * + * Unlike [settledAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settled_amount") + @ExcludeMissing + fun _settledAmount(): JsonField = settledAmount + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [expectedReleaseDate]. + * + * Unlike [expectedReleaseDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expected_release_date") + @ExcludeMissing + fun _expectedReleaseDate(): JsonField = expectedReleaseDate + + /** + * Returns the raw JSON value of [externalBankAccountToken]. + * + * Unlike [externalBankAccountToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("external_bank_account_token") + @ExcludeMissing + fun _externalBankAccountToken(): JsonField = externalBankAccountToken + + /** + * Returns the raw JSON value of [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 [userDefinedId]. + * + * Unlike [userDefinedId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_defined_id") + @ExcludeMissing + fun _userDefinedId(): JsonField = userDefinedId + + /** + * 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 + * [PaymentTransactionUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .descriptor() + * .direction() + * .events() + * .family() + * .financialAccountToken() + * .method() + * .methodAttributes() + * .pendingAmount() + * .relatedAccountTokens() + * .result() + * .settledAmount() + * .source() + * .status() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaymentTransactionUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var category: JsonField? = null + private var created: JsonField? = null + private var descriptor: JsonField? = null + private var direction: JsonField? = null + private var events: JsonField>? = null + private var family: JsonField? = null + private var financialAccountToken: JsonField? = null + private var method: JsonField? = null + private var methodAttributes: JsonField? = null + private var pendingAmount: JsonField? = null + private var relatedAccountTokens: JsonField? = null + private var result: JsonField? = null + private var settledAmount: JsonField? = null + private var source: JsonField? = null + private var status: JsonField? = null + private var updated: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var expectedReleaseDate: JsonField = JsonMissing.of() + private var externalBankAccountToken: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var userDefinedId: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + paymentTransactionUpdatedWebhookEvent: PaymentTransactionUpdatedWebhookEvent + ) = apply { + token = paymentTransactionUpdatedWebhookEvent.token + category = paymentTransactionUpdatedWebhookEvent.category + created = paymentTransactionUpdatedWebhookEvent.created + descriptor = paymentTransactionUpdatedWebhookEvent.descriptor + direction = paymentTransactionUpdatedWebhookEvent.direction + events = paymentTransactionUpdatedWebhookEvent.events.map { it.toMutableList() } + family = paymentTransactionUpdatedWebhookEvent.family + financialAccountToken = paymentTransactionUpdatedWebhookEvent.financialAccountToken + method = paymentTransactionUpdatedWebhookEvent.method + methodAttributes = paymentTransactionUpdatedWebhookEvent.methodAttributes + pendingAmount = paymentTransactionUpdatedWebhookEvent.pendingAmount + relatedAccountTokens = paymentTransactionUpdatedWebhookEvent.relatedAccountTokens + result = paymentTransactionUpdatedWebhookEvent.result + settledAmount = paymentTransactionUpdatedWebhookEvent.settledAmount + source = paymentTransactionUpdatedWebhookEvent.source + status = paymentTransactionUpdatedWebhookEvent.status + updated = paymentTransactionUpdatedWebhookEvent.updated + currency = paymentTransactionUpdatedWebhookEvent.currency + expectedReleaseDate = paymentTransactionUpdatedWebhookEvent.expectedReleaseDate + externalBankAccountToken = + paymentTransactionUpdatedWebhookEvent.externalBankAccountToken + type = paymentTransactionUpdatedWebhookEvent.type + userDefinedId = paymentTransactionUpdatedWebhookEvent.userDefinedId + eventType = paymentTransactionUpdatedWebhookEvent.eventType + additionalProperties = + paymentTransactionUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the transaction */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Transaction category */ + fun category(category: Payment.TransactionCategory) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed + * [Payment.TransactionCategory] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun category(category: JsonField) = apply { + this.category = category + } + + /** ISO 8601 timestamp of when the transaction was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Transaction descriptor */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** + * Sets [Builder.descriptor] to an arbitrary JSON value. + * + * You should usually call [Builder.descriptor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** Transfer direction */ + fun direction(direction: Payment.Direction) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [Payment.Direction] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun direction(direction: JsonField) = apply { + this.direction = direction + } + + /** List of transaction events */ + fun events(events: List) = events(JsonField.of(events)) + + /** + * Sets [Builder.events] to an arbitrary JSON value. + * + * You should usually call [Builder.events] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } + + /** + * Adds a single [Payment.PaymentEvent] to [events]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEvent(event: Payment.PaymentEvent) = apply { + events = + (events ?: JsonField.of(mutableListOf())).also { + checkKnown("events", it).add(event) + } + } + + /** PAYMENT - Payment Transaction */ + fun family(family: Payment.Family) = family(JsonField.of(family)) + + /** + * Sets [Builder.family] to an arbitrary JSON value. + * + * You should usually call [Builder.family] with a well-typed [Payment.Family] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun family(family: JsonField) = apply { this.family = family } + + /** Financial account token */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Transfer method */ + fun method(method: Payment.Method) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Payment.Method] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** Method-specific attributes */ + fun methodAttributes(methodAttributes: Payment.MethodAttributes) = + methodAttributes(JsonField.of(methodAttributes)) + + /** + * Sets [Builder.methodAttributes] to an arbitrary JSON value. + * + * You should usually call [Builder.methodAttributes] with a well-typed + * [Payment.MethodAttributes] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun methodAttributes(methodAttributes: JsonField) = apply { + this.methodAttributes = methodAttributes + } + + /** Alias for calling [methodAttributes] with `Payment.MethodAttributes.ofAch(ach)`. */ + fun methodAttributes(ach: Payment.MethodAttributes.AchMethodAttributes) = + methodAttributes(Payment.MethodAttributes.ofAch(ach)) + + /** Alias for calling [methodAttributes] with `Payment.MethodAttributes.ofWire(wire)`. */ + fun methodAttributes(wire: Payment.MethodAttributes.WireMethodAttributes) = + methodAttributes(Payment.MethodAttributes.ofWire(wire)) + + /** Pending amount in cents */ + fun pendingAmount(pendingAmount: Long) = pendingAmount(JsonField.of(pendingAmount)) + + /** + * Sets [Builder.pendingAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.pendingAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pendingAmount(pendingAmount: JsonField) = apply { + this.pendingAmount = pendingAmount + } + + /** Account tokens related to a payment transaction */ + fun relatedAccountTokens(relatedAccountTokens: Payment.RelatedAccountTokens?) = + relatedAccountTokens(JsonField.ofNullable(relatedAccountTokens)) + + /** + * Alias for calling [Builder.relatedAccountTokens] with + * `relatedAccountTokens.orElse(null)`. + */ + fun relatedAccountTokens(relatedAccountTokens: Optional) = + relatedAccountTokens(relatedAccountTokens.getOrNull()) + + /** + * Sets [Builder.relatedAccountTokens] to an arbitrary JSON value. + * + * You should usually call [Builder.relatedAccountTokens] with a well-typed + * [Payment.RelatedAccountTokens] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun relatedAccountTokens(relatedAccountTokens: JsonField) = + apply { + this.relatedAccountTokens = relatedAccountTokens + } + + /** Transaction result */ + fun result(result: Payment.TransactionResult) = result(JsonField.of(result)) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [Payment.TransactionResult] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Settled amount in cents */ + fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) + + /** + * Sets [Builder.settledAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun settledAmount(settledAmount: JsonField) = apply { + this.settledAmount = settledAmount + } + + /** Transaction source */ + fun source(source: Payment.Source) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Payment.Source] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + /** The status of the transaction */ + fun status(status: Payment.TransactionStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Payment.TransactionStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** ISO 8601 timestamp of when the transaction was last updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** Currency of the transaction in ISO 4217 format */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** Expected release date for the transaction */ + fun expectedReleaseDate(expectedReleaseDate: LocalDate?) = + expectedReleaseDate(JsonField.ofNullable(expectedReleaseDate)) + + /** + * Alias for calling [Builder.expectedReleaseDate] with `expectedReleaseDate.orElse(null)`. + */ + fun expectedReleaseDate(expectedReleaseDate: Optional) = + expectedReleaseDate(expectedReleaseDate.getOrNull()) + + /** + * Sets [Builder.expectedReleaseDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedReleaseDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expectedReleaseDate(expectedReleaseDate: JsonField) = apply { + this.expectedReleaseDate = expectedReleaseDate + } + + /** External bank account token */ + fun externalBankAccountToken(externalBankAccountToken: String?) = + externalBankAccountToken(JsonField.ofNullable(externalBankAccountToken)) + + /** + * Alias for calling [Builder.externalBankAccountToken] with + * `externalBankAccountToken.orElse(null)`. + */ + fun externalBankAccountToken(externalBankAccountToken: Optional) = + externalBankAccountToken(externalBankAccountToken.getOrNull()) + + /** + * Sets [Builder.externalBankAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.externalBankAccountToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun externalBankAccountToken(externalBankAccountToken: JsonField) = apply { + this.externalBankAccountToken = externalBankAccountToken + } + + fun type(type: Payment.TransferType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Payment.TransferType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** User-defined identifier */ + fun userDefinedId(userDefinedId: String?) = + userDefinedId(JsonField.ofNullable(userDefinedId)) + + /** Alias for calling [Builder.userDefinedId] with `userDefinedId.orElse(null)`. */ + fun userDefinedId(userDefinedId: Optional) = + userDefinedId(userDefinedId.getOrNull()) + + /** + * Sets [Builder.userDefinedId] to an arbitrary JSON value. + * + * You should usually call [Builder.userDefinedId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun userDefinedId(userDefinedId: JsonField) = apply { + this.userDefinedId = userDefinedId + } + + /** 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 [PaymentTransactionUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .category() + * .created() + * .descriptor() + * .direction() + * .events() + * .family() + * .financialAccountToken() + * .method() + * .methodAttributes() + * .pendingAmount() + * .relatedAccountTokens() + * .result() + * .settledAmount() + * .source() + * .status() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaymentTransactionUpdatedWebhookEvent = + PaymentTransactionUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("category", category), + checkRequired("created", created), + checkRequired("descriptor", descriptor), + checkRequired("direction", direction), + checkRequired("events", events).map { it.toImmutable() }, + checkRequired("family", family), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("method", method), + checkRequired("methodAttributes", methodAttributes), + checkRequired("pendingAmount", pendingAmount), + checkRequired("relatedAccountTokens", relatedAccountTokens), + checkRequired("result", result), + checkRequired("settledAmount", settledAmount), + checkRequired("source", source), + checkRequired("status", status), + checkRequired("updated", updated), + currency, + expectedReleaseDate, + externalBankAccountToken, + type, + userDefinedId, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaymentTransactionUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + category().validate() + created() + descriptor() + direction().validate() + events().forEach { it.validate() } + family().validate() + financialAccountToken() + method().validate() + methodAttributes().validate() + pendingAmount() + relatedAccountTokens().ifPresent { it.validate() } + result().validate() + settledAmount() + source().validate() + status().validate() + updated() + currency() + expectedReleaseDate() + externalBankAccountToken() + type().ifPresent { it.validate() } + userDefinedId() + 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 = + (if (token.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (direction.asKnown().getOrNull()?.validity() ?: 0) + + (events.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (family.asKnown().getOrNull()?.validity() ?: 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + (methodAttributes.asKnown().getOrNull()?.validity() ?: 0) + + (if (pendingAmount.asKnown().isPresent) 1 else 0) + + (relatedAccountTokens.asKnown().getOrNull()?.validity() ?: 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (settledAmount.asKnown().isPresent) 1 else 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (expectedReleaseDate.asKnown().isPresent) 1 else 0) + + (if (externalBankAccountToken.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (userDefinedId.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 PAYMENT_TRANSACTION_UPDATED = of("payment_transaction.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + PAYMENT_TRANSACTION_UPDATED + } + + /** + * 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 { + PAYMENT_TRANSACTION_UPDATED, + /** + * 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) { + PAYMENT_TRANSACTION_UPDATED -> Value.PAYMENT_TRANSACTION_UPDATED + 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) { + PAYMENT_TRANSACTION_UPDATED -> Known.PAYMENT_TRANSACTION_UPDATED + 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 + + 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 PaymentTransactionUpdatedWebhookEvent && + token == other.token && + category == other.category && + created == other.created && + descriptor == other.descriptor && + direction == other.direction && + events == other.events && + family == other.family && + financialAccountToken == other.financialAccountToken && + method == other.method && + methodAttributes == other.methodAttributes && + pendingAmount == other.pendingAmount && + relatedAccountTokens == other.relatedAccountTokens && + result == other.result && + settledAmount == other.settledAmount && + source == other.source && + status == other.status && + updated == other.updated && + currency == other.currency && + expectedReleaseDate == other.expectedReleaseDate && + externalBankAccountToken == other.externalBankAccountToken && + type == other.type && + userDefinedId == other.userDefinedId && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + category, + created, + descriptor, + direction, + events, + family, + financialAccountToken, + method, + methodAttributes, + pendingAmount, + relatedAccountTokens, + result, + settledAmount, + source, + status, + updated, + currency, + expectedReleaseDate, + externalBankAccountToken, + type, + userDefinedId, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaymentTransactionUpdatedWebhookEvent{token=$token, category=$category, created=$created, descriptor=$descriptor, direction=$direction, events=$events, family=$family, financialAccountToken=$financialAccountToken, method=$method, methodAttributes=$methodAttributes, pendingAmount=$pendingAmount, relatedAccountTokens=$relatedAccountTokens, result=$result, settledAmount=$settledAmount, source=$source, status=$status, updated=$updated, currency=$currency, expectedReleaseDate=$expectedReleaseDate, externalBankAccountToken=$externalBankAccountToken, type=$type, userDefinedId=$userDefinedId, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/SettlementReportUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/SettlementReportUpdatedWebhookEvent.kt new file mode 100644 index 000000000..2f05ec4a4 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/SettlementReportUpdatedWebhookEvent.kt @@ -0,0 +1,887 @@ +// 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 kotlin.jvm.optionals.getOrNull + +class SettlementReportUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val created: JsonField, + private val currency: JsonField, + private val details: JsonField>, + private val disputesGrossAmount: JsonField, + private val interchangeGrossAmount: JsonField, + private val isComplete: JsonField, + private val otherFeesGrossAmount: JsonField, + private val reportDate: JsonField, + private val settledNetAmount: JsonField, + private val transactionsGrossAmount: JsonField, + private val updated: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), + @JsonProperty("details") + @ExcludeMissing + details: JsonField> = JsonMissing.of(), + @JsonProperty("disputes_gross_amount") + @ExcludeMissing + disputesGrossAmount: JsonField = JsonMissing.of(), + @JsonProperty("interchange_gross_amount") + @ExcludeMissing + interchangeGrossAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_complete") + @ExcludeMissing + isComplete: JsonField = JsonMissing.of(), + @JsonProperty("other_fees_gross_amount") + @ExcludeMissing + otherFeesGrossAmount: JsonField = JsonMissing.of(), + @JsonProperty("report_date") + @ExcludeMissing + reportDate: JsonField = JsonMissing.of(), + @JsonProperty("settled_net_amount") + @ExcludeMissing + settledNetAmount: JsonField = JsonMissing.of(), + @JsonProperty("transactions_gross_amount") + @ExcludeMissing + transactionsGrossAmount: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + created, + currency, + details, + disputesGrossAmount, + interchangeGrossAmount, + isComplete, + otherFeesGrossAmount, + reportDate, + settledNetAmount, + transactionsGrossAmount, + updated, + eventType, + mutableMapOf(), + ) + + fun toSettlementReport(): SettlementReport = + SettlementReport.builder() + .created(created) + .currency(currency) + .details(details) + .disputesGrossAmount(disputesGrossAmount) + .interchangeGrossAmount(interchangeGrossAmount) + .isComplete(isComplete) + .otherFeesGrossAmount(otherFeesGrossAmount) + .reportDate(reportDate) + .settledNetAmount(settledNetAmount) + .transactionsGrossAmount(transactionsGrossAmount) + .updated(updated) + .build() + + /** + * Date and time when the transaction first occurred. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * 3-character alphabetic ISO 4217 code. (This field is deprecated and will be removed in a + * future version of the API.) + * + * @throws LithicInvalidDataException 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 currency(): String = currency.getRequired("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 details(): List = details.getRequired("details") + + /** + * The total gross amount of disputes settlements. (This field is deprecated and will be removed + * in a future version of the API. To compute total amounts, Lithic recommends that customers + * sum the relevant settlement amounts found within `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). + */ + @Deprecated("deprecated") + fun disputesGrossAmount(): Long = disputesGrossAmount.getRequired("disputes_gross_amount") + + /** + * The total amount of interchange. (This field is deprecated and will be removed in a future + * version of the API. To compute total amounts, Lithic recommends that customers sum the + * relevant settlement amounts found within `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). + */ + @Deprecated("deprecated") + fun interchangeGrossAmount(): Long = + interchangeGrossAmount.getRequired("interchange_gross_amount") + + /** + * Indicates that all data expected on the given report date is available. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun isComplete(): Boolean = isComplete.getRequired("is_complete") + + /** + * Total amount of gross other fees outside of interchange. (This field is deprecated and will + * be removed in a future version of the API. To compute total amounts, Lithic recommends that + * customers sum the relevant settlement amounts found within `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). + */ + @Deprecated("deprecated") + fun otherFeesGrossAmount(): Long = otherFeesGrossAmount.getRequired("other_fees_gross_amount") + + /** + * Date of when the report was first generated. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun reportDate(): String = reportDate.getRequired("report_date") + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, fees). + * (This field is deprecated and will be removed in a future version of the API. To compute + * total amounts, Lithic recommends that customers sum the relevant settlement amounts found + * within `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). + */ + @Deprecated("deprecated") + fun settledNetAmount(): Long = settledNetAmount.getRequired("settled_net_amount") + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). (This field is deprecated and will be removed in a future version of the API. To + * compute total amounts, Lithic recommends that customers sum the relevant settlement amounts + * found within `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). + */ + @Deprecated("deprecated") + fun transactionsGrossAmount(): Long = + transactionsGrossAmount.getRequired("transactions_gross_amount") + + /** + * Date and time when the transaction first occurred. UTC time zone. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * 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 [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [details]. + * + * Unlike [details], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("details") + @ExcludeMissing + fun _details(): JsonField> = details + + /** + * Returns the raw JSON value of [disputesGrossAmount]. + * + * Unlike [disputesGrossAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("disputes_gross_amount") + @ExcludeMissing + fun _disputesGrossAmount(): JsonField = disputesGrossAmount + + /** + * Returns the raw JSON value of [interchangeGrossAmount]. + * + * Unlike [interchangeGrossAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("interchange_gross_amount") + @ExcludeMissing + fun _interchangeGrossAmount(): JsonField = interchangeGrossAmount + + /** + * Returns the raw JSON value of [isComplete]. + * + * Unlike [isComplete], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_complete") @ExcludeMissing fun _isComplete(): JsonField = isComplete + + /** + * Returns the raw JSON value of [otherFeesGrossAmount]. + * + * Unlike [otherFeesGrossAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("other_fees_gross_amount") + @ExcludeMissing + fun _otherFeesGrossAmount(): JsonField = otherFeesGrossAmount + + /** + * Returns the raw JSON value of [reportDate]. + * + * Unlike [reportDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("report_date") @ExcludeMissing fun _reportDate(): JsonField = reportDate + + /** + * Returns the raw JSON value of [settledNetAmount]. + * + * Unlike [settledNetAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @Deprecated("deprecated") + @JsonProperty("settled_net_amount") + @ExcludeMissing + fun _settledNetAmount(): JsonField = settledNetAmount + + /** + * Returns the raw JSON value of [transactionsGrossAmount]. + * + * Unlike [transactionsGrossAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("transactions_gross_amount") + @ExcludeMissing + fun _transactionsGrossAmount(): JsonField = transactionsGrossAmount + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [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 + * [SettlementReportUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .created() + * .currency() + * .details() + * .disputesGrossAmount() + * .interchangeGrossAmount() + * .isComplete() + * .otherFeesGrossAmount() + * .reportDate() + * .settledNetAmount() + * .transactionsGrossAmount() + * .updated() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SettlementReportUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var created: JsonField? = null + private var currency: JsonField? = null + private var details: JsonField>? = null + private var disputesGrossAmount: JsonField? = null + private var interchangeGrossAmount: JsonField? = null + private var isComplete: JsonField? = null + private var otherFeesGrossAmount: JsonField? = null + private var reportDate: JsonField? = null + private var settledNetAmount: JsonField? = null + private var transactionsGrossAmount: JsonField? = null + private var updated: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + settlementReportUpdatedWebhookEvent: SettlementReportUpdatedWebhookEvent + ) = apply { + created = settlementReportUpdatedWebhookEvent.created + currency = settlementReportUpdatedWebhookEvent.currency + details = settlementReportUpdatedWebhookEvent.details.map { it.toMutableList() } + disputesGrossAmount = settlementReportUpdatedWebhookEvent.disputesGrossAmount + interchangeGrossAmount = settlementReportUpdatedWebhookEvent.interchangeGrossAmount + isComplete = settlementReportUpdatedWebhookEvent.isComplete + otherFeesGrossAmount = settlementReportUpdatedWebhookEvent.otherFeesGrossAmount + reportDate = settlementReportUpdatedWebhookEvent.reportDate + settledNetAmount = settlementReportUpdatedWebhookEvent.settledNetAmount + transactionsGrossAmount = settlementReportUpdatedWebhookEvent.transactionsGrossAmount + updated = settlementReportUpdatedWebhookEvent.updated + eventType = settlementReportUpdatedWebhookEvent.eventType + additionalProperties = + settlementReportUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** + * 3-character alphabetic ISO 4217 code. (This field is deprecated and will be removed in a + * future version of the API.) + */ + @Deprecated("deprecated") 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. + */ + @Deprecated("deprecated") + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun details(details: List) = details(JsonField.of(details)) + + /** + * Sets [Builder.details] to an arbitrary JSON value. + * + * You should usually call [Builder.details] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun details(details: JsonField>) = apply { + this.details = details.map { it.toMutableList() } + } + + /** + * Adds a single [SettlementSummaryDetails] to [details]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDetail(detail: SettlementSummaryDetails) = apply { + details = + (details ?: JsonField.of(mutableListOf())).also { + checkKnown("details", it).add(detail) + } + } + + /** + * The total gross amount of disputes settlements. (This field is deprecated and will be + * removed in a future version of the API. To compute total amounts, Lithic recommends that + * customers sum the relevant settlement amounts found within `details`.) + */ + @Deprecated("deprecated") + fun disputesGrossAmount(disputesGrossAmount: Long) = + disputesGrossAmount(JsonField.of(disputesGrossAmount)) + + /** + * Sets [Builder.disputesGrossAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.disputesGrossAmount] 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 disputesGrossAmount(disputesGrossAmount: JsonField) = apply { + this.disputesGrossAmount = disputesGrossAmount + } + + /** + * The total amount of interchange. (This field is deprecated and will be removed in a + * future version of the API. To compute total amounts, Lithic recommends that customers sum + * the relevant settlement amounts found within `details`.) + */ + @Deprecated("deprecated") + fun interchangeGrossAmount(interchangeGrossAmount: Long) = + interchangeGrossAmount(JsonField.of(interchangeGrossAmount)) + + /** + * Sets [Builder.interchangeGrossAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.interchangeGrossAmount] 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 interchangeGrossAmount(interchangeGrossAmount: JsonField) = apply { + this.interchangeGrossAmount = interchangeGrossAmount + } + + /** Indicates that all data expected on the given report date is available. */ + fun isComplete(isComplete: Boolean) = isComplete(JsonField.of(isComplete)) + + /** + * Sets [Builder.isComplete] to an arbitrary JSON value. + * + * You should usually call [Builder.isComplete] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isComplete(isComplete: JsonField) = apply { this.isComplete = isComplete } + + /** + * Total amount of gross other fees outside of interchange. (This field is deprecated and + * will be removed in a future version of the API. To compute total amounts, Lithic + * recommends that customers sum the relevant settlement amounts found within `details`.) + */ + @Deprecated("deprecated") + fun otherFeesGrossAmount(otherFeesGrossAmount: Long) = + otherFeesGrossAmount(JsonField.of(otherFeesGrossAmount)) + + /** + * Sets [Builder.otherFeesGrossAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.otherFeesGrossAmount] 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 otherFeesGrossAmount(otherFeesGrossAmount: JsonField) = apply { + this.otherFeesGrossAmount = otherFeesGrossAmount + } + + /** Date of when the report was first generated. */ + fun reportDate(reportDate: String) = reportDate(JsonField.of(reportDate)) + + /** + * Sets [Builder.reportDate] to an arbitrary JSON value. + * + * You should usually call [Builder.reportDate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reportDate(reportDate: JsonField) = apply { this.reportDate = reportDate } + + /** + * The total net amount of cash moved. (net value of settled_gross_amount, interchange, + * fees). (This field is deprecated and will be removed in a future version of the API. To + * compute total amounts, Lithic recommends that customers sum the relevant settlement + * amounts found within `details`.) + */ + @Deprecated("deprecated") + fun settledNetAmount(settledNetAmount: Long) = + settledNetAmount(JsonField.of(settledNetAmount)) + + /** + * Sets [Builder.settledNetAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.settledNetAmount] 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 settledNetAmount(settledNetAmount: JsonField) = apply { + this.settledNetAmount = settledNetAmount + } + + /** + * The total amount of settlement impacting transactions (excluding interchange, fees, and + * disputes). (This field is deprecated and will be removed in a future version of the API. + * To compute total amounts, Lithic recommends that customers sum the relevant settlement + * amounts found within `details`.) + */ + @Deprecated("deprecated") + fun transactionsGrossAmount(transactionsGrossAmount: Long) = + transactionsGrossAmount(JsonField.of(transactionsGrossAmount)) + + /** + * Sets [Builder.transactionsGrossAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionsGrossAmount] 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 transactionsGrossAmount(transactionsGrossAmount: JsonField) = apply { + this.transactionsGrossAmount = transactionsGrossAmount + } + + /** Date and time when the transaction first occurred. UTC time zone. */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** 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 [SettlementReportUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .created() + * .currency() + * .details() + * .disputesGrossAmount() + * .interchangeGrossAmount() + * .isComplete() + * .otherFeesGrossAmount() + * .reportDate() + * .settledNetAmount() + * .transactionsGrossAmount() + * .updated() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SettlementReportUpdatedWebhookEvent = + SettlementReportUpdatedWebhookEvent( + checkRequired("created", created), + checkRequired("currency", currency), + checkRequired("details", details).map { it.toImmutable() }, + checkRequired("disputesGrossAmount", disputesGrossAmount), + checkRequired("interchangeGrossAmount", interchangeGrossAmount), + checkRequired("isComplete", isComplete), + checkRequired("otherFeesGrossAmount", otherFeesGrossAmount), + checkRequired("reportDate", reportDate), + checkRequired("settledNetAmount", settledNetAmount), + checkRequired("transactionsGrossAmount", transactionsGrossAmount), + checkRequired("updated", updated), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SettlementReportUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + created() + currency() + details().forEach { it.validate() } + disputesGrossAmount() + interchangeGrossAmount() + isComplete() + otherFeesGrossAmount() + reportDate() + settledNetAmount() + transactionsGrossAmount() + updated() + 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 = + (if (created.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (details.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (disputesGrossAmount.asKnown().isPresent) 1 else 0) + + (if (interchangeGrossAmount.asKnown().isPresent) 1 else 0) + + (if (isComplete.asKnown().isPresent) 1 else 0) + + (if (otherFeesGrossAmount.asKnown().isPresent) 1 else 0) + + (if (reportDate.asKnown().isPresent) 1 else 0) + + (if (settledNetAmount.asKnown().isPresent) 1 else 0) + + (if (transactionsGrossAmount.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 SETTLEMENT_REPORT_UPDATED = of("settlement_report.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + SETTLEMENT_REPORT_UPDATED + } + + /** + * 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 { + SETTLEMENT_REPORT_UPDATED, + /** + * 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) { + SETTLEMENT_REPORT_UPDATED -> Value.SETTLEMENT_REPORT_UPDATED + 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) { + SETTLEMENT_REPORT_UPDATED -> Known.SETTLEMENT_REPORT_UPDATED + 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 + + 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 SettlementReportUpdatedWebhookEvent && + created == other.created && + currency == other.currency && + details == other.details && + disputesGrossAmount == other.disputesGrossAmount && + interchangeGrossAmount == other.interchangeGrossAmount && + isComplete == other.isComplete && + otherFeesGrossAmount == other.otherFeesGrossAmount && + reportDate == other.reportDate && + settledNetAmount == other.settledNetAmount && + transactionsGrossAmount == other.transactionsGrossAmount && + updated == other.updated && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + created, + currency, + details, + disputesGrossAmount, + interchangeGrossAmount, + isComplete, + otherFeesGrossAmount, + reportDate, + settledNetAmount, + transactionsGrossAmount, + updated, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SettlementReportUpdatedWebhookEvent{created=$created, currency=$currency, details=$details, disputesGrossAmount=$disputesGrossAmount, interchangeGrossAmount=$interchangeGrossAmount, isComplete=$isComplete, otherFeesGrossAmount=$otherFeesGrossAmount, reportDate=$reportDate, settledNetAmount=$settledNetAmount, transactionsGrossAmount=$transactionsGrossAmount, updated=$updated, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/StatementsCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/StatementsCreatedWebhookEvent.kt new file mode 100644 index 000000000..521d74b8c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/StatementsCreatedWebhookEvent.kt @@ -0,0 +1,1324 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class StatementsCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountStanding: JsonField, + private val amountDue: JsonField, + private val availableCredit: JsonField, + private val created: JsonField, + private val creditLimit: JsonField, + private val creditProductToken: JsonField, + private val daysInBillingCycle: JsonField, + private val endingBalance: JsonField, + private val financialAccountToken: JsonField, + private val paymentDueDate: JsonField, + private val periodTotals: JsonField, + private val startingBalance: JsonField, + private val statementEndDate: JsonField, + private val statementStartDate: JsonField, + private val statementType: JsonField, + private val updated: JsonField, + private val ytdTotals: JsonField, + private val interestDetails: JsonField, + private val nextPaymentDueDate: JsonField, + private val nextStatementEndDate: JsonField, + private val payoffDetails: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_standing") + @ExcludeMissing + accountStanding: JsonField = JsonMissing.of(), + @JsonProperty("amount_due") + @ExcludeMissing + amountDue: JsonField = JsonMissing.of(), + @JsonProperty("available_credit") + @ExcludeMissing + availableCredit: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("credit_limit") + @ExcludeMissing + creditLimit: JsonField = JsonMissing.of(), + @JsonProperty("credit_product_token") + @ExcludeMissing + creditProductToken: JsonField = JsonMissing.of(), + @JsonProperty("days_in_billing_cycle") + @ExcludeMissing + daysInBillingCycle: JsonField = JsonMissing.of(), + @JsonProperty("ending_balance") + @ExcludeMissing + endingBalance: JsonField = JsonMissing.of(), + @JsonProperty("financial_account_token") + @ExcludeMissing + financialAccountToken: JsonField = JsonMissing.of(), + @JsonProperty("payment_due_date") + @ExcludeMissing + paymentDueDate: JsonField = JsonMissing.of(), + @JsonProperty("period_totals") + @ExcludeMissing + periodTotals: JsonField = JsonMissing.of(), + @JsonProperty("starting_balance") + @ExcludeMissing + startingBalance: JsonField = JsonMissing.of(), + @JsonProperty("statement_end_date") + @ExcludeMissing + statementEndDate: JsonField = JsonMissing.of(), + @JsonProperty("statement_start_date") + @ExcludeMissing + statementStartDate: JsonField = JsonMissing.of(), + @JsonProperty("statement_type") + @ExcludeMissing + statementType: JsonField = JsonMissing.of(), + @JsonProperty("updated") + @ExcludeMissing + updated: JsonField = JsonMissing.of(), + @JsonProperty("ytd_totals") + @ExcludeMissing + ytdTotals: JsonField = JsonMissing.of(), + @JsonProperty("interest_details") + @ExcludeMissing + interestDetails: JsonField = JsonMissing.of(), + @JsonProperty("next_payment_due_date") + @ExcludeMissing + nextPaymentDueDate: JsonField = JsonMissing.of(), + @JsonProperty("next_statement_end_date") + @ExcludeMissing + nextStatementEndDate: JsonField = JsonMissing.of(), + @JsonProperty("payoff_details") + @ExcludeMissing + payoffDetails: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountStanding, + amountDue, + availableCredit, + created, + creditLimit, + creditProductToken, + daysInBillingCycle, + endingBalance, + financialAccountToken, + paymentDueDate, + periodTotals, + startingBalance, + statementEndDate, + statementStartDate, + statementType, + updated, + ytdTotals, + interestDetails, + nextPaymentDueDate, + nextStatementEndDate, + payoffDetails, + eventType, + mutableMapOf(), + ) + + fun toStatement(): Statement = + Statement.builder() + .token(token) + .accountStanding(accountStanding) + .amountDue(amountDue) + .availableCredit(availableCredit) + .created(created) + .creditLimit(creditLimit) + .creditProductToken(creditProductToken) + .daysInBillingCycle(daysInBillingCycle) + .endingBalance(endingBalance) + .financialAccountToken(financialAccountToken) + .paymentDueDate(paymentDueDate) + .periodTotals(periodTotals) + .startingBalance(startingBalance) + .statementEndDate(statementEndDate) + .statementStartDate(statementStartDate) + .statementType(statementType) + .updated(updated) + .ytdTotals(ytdTotals) + .interestDetails(interestDetails) + .nextPaymentDueDate(nextPaymentDueDate) + .nextStatementEndDate(nextStatementEndDate) + .payoffDetails(payoffDetails) + .build() + + /** + * Globally unique identifier for a statement + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun token(): String = token.getRequired("token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountStanding(): Statement.AccountStanding = + accountStanding.getRequired("account_standing") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amountDue(): Statement.AmountDue = amountDue.getRequired("amount_due") + + /** + * Amount of credit available to spend in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun availableCredit(): Long = availableCredit.getRequired("available_credit") + + /** + * Timestamp of when the statement was created + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): OffsetDateTime = created.getRequired("created") + + /** + * This is the maximum credit balance extended by the lender in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditLimit(): Long = creditLimit.getRequired("credit_limit") + + /** + * Globally unique identifier for a credit product + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditProductToken(): String = creditProductToken.getRequired("credit_product_token") + + /** + * Number of days in the billing cycle + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun daysInBillingCycle(): Long = daysInBillingCycle.getRequired("days_in_billing_cycle") + + /** + * Balance at the end of the billing period. For charge cards, this should be the same at the + * statement amount due in cents + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun endingBalance(): Long = endingBalance.getRequired("ending_balance") + + /** + * Globally unique identifier for a financial account + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun financialAccountToken(): String = + financialAccountToken.getRequired("financial_account_token") + + /** + * Date when the payment is due + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentDueDate(): Optional = paymentDueDate.getOptional("payment_due_date") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun periodTotals(): StatementTotals = periodTotals.getRequired("period_totals") + + /** + * Balance at the start of the billing period + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun startingBalance(): Long = startingBalance.getRequired("starting_balance") + + /** + * Date when the billing period ended + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun statementEndDate(): LocalDate = statementEndDate.getRequired("statement_end_date") + + /** + * Date when the billing period began + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun statementStartDate(): LocalDate = statementStartDate.getRequired("statement_start_date") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun statementType(): Statement.StatementType = statementType.getRequired("statement_type") + + /** + * Timestamp of when the statement was updated + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): OffsetDateTime = updated.getRequired("updated") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun ytdTotals(): StatementTotals = ytdTotals.getRequired("ytd_totals") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun interestDetails(): Optional = + interestDetails.getOptional("interest_details") + + /** + * Date when the next payment is due + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextPaymentDueDate(): Optional = + nextPaymentDueDate.getOptional("next_payment_due_date") + + /** + * Date when the next billing period will end + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextStatementEndDate(): Optional = + nextStatementEndDate.getOptional("next_statement_end_date") + + /** + * Details on number and size of payments to pay off balance + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun payoffDetails(): Optional = + payoffDetails.getOptional("payoff_details") + + /** + * 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 [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 [accountStanding]. + * + * Unlike [accountStanding], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_standing") + @ExcludeMissing + fun _accountStanding(): JsonField = accountStanding + + /** + * Returns the raw JSON value of [amountDue]. + * + * Unlike [amountDue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_due") + @ExcludeMissing + fun _amountDue(): JsonField = amountDue + + /** + * Returns the raw JSON value of [availableCredit]. + * + * Unlike [availableCredit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("available_credit") + @ExcludeMissing + fun _availableCredit(): JsonField = availableCredit + + /** + * 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 [creditLimit]. + * + * Unlike [creditLimit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_limit") @ExcludeMissing fun _creditLimit(): JsonField = creditLimit + + /** + * Returns the raw JSON value of [creditProductToken]. + * + * Unlike [creditProductToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("credit_product_token") + @ExcludeMissing + fun _creditProductToken(): JsonField = creditProductToken + + /** + * Returns the raw JSON value of [daysInBillingCycle]. + * + * Unlike [daysInBillingCycle], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("days_in_billing_cycle") + @ExcludeMissing + fun _daysInBillingCycle(): JsonField = daysInBillingCycle + + /** + * Returns the raw JSON value of [endingBalance]. + * + * Unlike [endingBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance + + /** + * Returns the raw JSON value of [financialAccountToken]. + * + * Unlike [financialAccountToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("financial_account_token") + @ExcludeMissing + fun _financialAccountToken(): JsonField = financialAccountToken + + /** + * Returns the raw JSON value of [paymentDueDate]. + * + * Unlike [paymentDueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_due_date") + @ExcludeMissing + fun _paymentDueDate(): JsonField = paymentDueDate + + /** + * Returns the raw JSON value of [periodTotals]. + * + * Unlike [periodTotals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("period_totals") + @ExcludeMissing + fun _periodTotals(): JsonField = periodTotals + + /** + * Returns the raw JSON value of [startingBalance]. + * + * Unlike [startingBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance + + /** + * Returns the raw JSON value of [statementEndDate]. + * + * Unlike [statementEndDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statement_end_date") + @ExcludeMissing + fun _statementEndDate(): JsonField = statementEndDate + + /** + * Returns the raw JSON value of [statementStartDate]. + * + * Unlike [statementStartDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statement_start_date") + @ExcludeMissing + fun _statementStartDate(): JsonField = statementStartDate + + /** + * Returns the raw JSON value of [statementType]. + * + * Unlike [statementType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("statement_type") + @ExcludeMissing + fun _statementType(): JsonField = statementType + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [ytdTotals]. + * + * Unlike [ytdTotals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ytd_totals") + @ExcludeMissing + fun _ytdTotals(): JsonField = ytdTotals + + /** + * Returns the raw JSON value of [interestDetails]. + * + * Unlike [interestDetails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("interest_details") + @ExcludeMissing + fun _interestDetails(): JsonField = interestDetails + + /** + * Returns the raw JSON value of [nextPaymentDueDate]. + * + * Unlike [nextPaymentDueDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("next_payment_due_date") + @ExcludeMissing + fun _nextPaymentDueDate(): JsonField = nextPaymentDueDate + + /** + * Returns the raw JSON value of [nextStatementEndDate]. + * + * Unlike [nextStatementEndDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("next_statement_end_date") + @ExcludeMissing + fun _nextStatementEndDate(): JsonField = nextStatementEndDate + + /** + * Returns the raw JSON value of [payoffDetails]. + * + * Unlike [payoffDetails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payoff_details") + @ExcludeMissing + fun _payoffDetails(): JsonField = payoffDetails + + /** + * 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 + * [StatementsCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountStanding() + * .amountDue() + * .availableCredit() + * .created() + * .creditLimit() + * .creditProductToken() + * .daysInBillingCycle() + * .endingBalance() + * .financialAccountToken() + * .paymentDueDate() + * .periodTotals() + * .startingBalance() + * .statementEndDate() + * .statementStartDate() + * .statementType() + * .updated() + * .ytdTotals() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [StatementsCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountStanding: JsonField? = null + private var amountDue: JsonField? = null + private var availableCredit: JsonField? = null + private var created: JsonField? = null + private var creditLimit: JsonField? = null + private var creditProductToken: JsonField? = null + private var daysInBillingCycle: JsonField? = null + private var endingBalance: JsonField? = null + private var financialAccountToken: JsonField? = null + private var paymentDueDate: JsonField? = null + private var periodTotals: JsonField? = null + private var startingBalance: JsonField? = null + private var statementEndDate: JsonField? = null + private var statementStartDate: JsonField? = null + private var statementType: JsonField? = null + private var updated: JsonField? = null + private var ytdTotals: JsonField? = null + private var interestDetails: JsonField = JsonMissing.of() + private var nextPaymentDueDate: JsonField = JsonMissing.of() + private var nextStatementEndDate: JsonField = JsonMissing.of() + private var payoffDetails: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(statementsCreatedWebhookEvent: StatementsCreatedWebhookEvent) = apply { + token = statementsCreatedWebhookEvent.token + accountStanding = statementsCreatedWebhookEvent.accountStanding + amountDue = statementsCreatedWebhookEvent.amountDue + availableCredit = statementsCreatedWebhookEvent.availableCredit + created = statementsCreatedWebhookEvent.created + creditLimit = statementsCreatedWebhookEvent.creditLimit + creditProductToken = statementsCreatedWebhookEvent.creditProductToken + daysInBillingCycle = statementsCreatedWebhookEvent.daysInBillingCycle + endingBalance = statementsCreatedWebhookEvent.endingBalance + financialAccountToken = statementsCreatedWebhookEvent.financialAccountToken + paymentDueDate = statementsCreatedWebhookEvent.paymentDueDate + periodTotals = statementsCreatedWebhookEvent.periodTotals + startingBalance = statementsCreatedWebhookEvent.startingBalance + statementEndDate = statementsCreatedWebhookEvent.statementEndDate + statementStartDate = statementsCreatedWebhookEvent.statementStartDate + statementType = statementsCreatedWebhookEvent.statementType + updated = statementsCreatedWebhookEvent.updated + ytdTotals = statementsCreatedWebhookEvent.ytdTotals + interestDetails = statementsCreatedWebhookEvent.interestDetails + nextPaymentDueDate = statementsCreatedWebhookEvent.nextPaymentDueDate + nextStatementEndDate = statementsCreatedWebhookEvent.nextStatementEndDate + payoffDetails = statementsCreatedWebhookEvent.payoffDetails + eventType = statementsCreatedWebhookEvent.eventType + additionalProperties = statementsCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for a statement */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun accountStanding(accountStanding: Statement.AccountStanding) = + accountStanding(JsonField.of(accountStanding)) + + /** + * Sets [Builder.accountStanding] to an arbitrary JSON value. + * + * You should usually call [Builder.accountStanding] with a well-typed + * [Statement.AccountStanding] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun accountStanding(accountStanding: JsonField) = apply { + this.accountStanding = accountStanding + } + + fun amountDue(amountDue: Statement.AmountDue) = amountDue(JsonField.of(amountDue)) + + /** + * Sets [Builder.amountDue] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDue] with a well-typed [Statement.AmountDue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amountDue(amountDue: JsonField) = apply { + this.amountDue = amountDue + } + + /** Amount of credit available to spend in cents */ + fun availableCredit(availableCredit: Long) = availableCredit(JsonField.of(availableCredit)) + + /** + * Sets [Builder.availableCredit] to an arbitrary JSON value. + * + * You should usually call [Builder.availableCredit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun availableCredit(availableCredit: JsonField) = apply { + this.availableCredit = availableCredit + } + + /** Timestamp of when the statement was created */ + fun created(created: OffsetDateTime) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** This is the maximum credit balance extended by the lender in cents */ + fun creditLimit(creditLimit: Long) = creditLimit(JsonField.of(creditLimit)) + + /** + * Sets [Builder.creditLimit] to an arbitrary JSON value. + * + * You should usually call [Builder.creditLimit] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creditLimit(creditLimit: JsonField) = apply { this.creditLimit = creditLimit } + + /** Globally unique identifier for a credit product */ + fun creditProductToken(creditProductToken: String) = + creditProductToken(JsonField.of(creditProductToken)) + + /** + * Sets [Builder.creditProductToken] to an arbitrary JSON value. + * + * You should usually call [Builder.creditProductToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun creditProductToken(creditProductToken: JsonField) = apply { + this.creditProductToken = creditProductToken + } + + /** Number of days in the billing cycle */ + fun daysInBillingCycle(daysInBillingCycle: Long) = + daysInBillingCycle(JsonField.of(daysInBillingCycle)) + + /** + * Sets [Builder.daysInBillingCycle] to an arbitrary JSON value. + * + * You should usually call [Builder.daysInBillingCycle] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun daysInBillingCycle(daysInBillingCycle: JsonField) = apply { + this.daysInBillingCycle = daysInBillingCycle + } + + /** + * Balance at the end of the billing period. For charge cards, this should be the same at + * the statement amount due in cents + */ + fun endingBalance(endingBalance: Long) = endingBalance(JsonField.of(endingBalance)) + + /** + * Sets [Builder.endingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.endingBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endingBalance(endingBalance: JsonField) = apply { + this.endingBalance = endingBalance + } + + /** Globally unique identifier for a financial account */ + fun financialAccountToken(financialAccountToken: String) = + financialAccountToken(JsonField.of(financialAccountToken)) + + /** + * Sets [Builder.financialAccountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.financialAccountToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun financialAccountToken(financialAccountToken: JsonField) = apply { + this.financialAccountToken = financialAccountToken + } + + /** Date when the payment is due */ + fun paymentDueDate(paymentDueDate: LocalDate?) = + paymentDueDate(JsonField.ofNullable(paymentDueDate)) + + /** Alias for calling [Builder.paymentDueDate] with `paymentDueDate.orElse(null)`. */ + fun paymentDueDate(paymentDueDate: Optional) = + paymentDueDate(paymentDueDate.getOrNull()) + + /** + * Sets [Builder.paymentDueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentDueDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentDueDate(paymentDueDate: JsonField) = apply { + this.paymentDueDate = paymentDueDate + } + + fun periodTotals(periodTotals: StatementTotals) = periodTotals(JsonField.of(periodTotals)) + + /** + * Sets [Builder.periodTotals] to an arbitrary JSON value. + * + * You should usually call [Builder.periodTotals] with a well-typed [StatementTotals] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun periodTotals(periodTotals: JsonField) = apply { + this.periodTotals = periodTotals + } + + /** Balance at the start of the billing period */ + fun startingBalance(startingBalance: Long) = startingBalance(JsonField.of(startingBalance)) + + /** + * Sets [Builder.startingBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.startingBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startingBalance(startingBalance: JsonField) = apply { + this.startingBalance = startingBalance + } + + /** Date when the billing period ended */ + fun statementEndDate(statementEndDate: LocalDate) = + statementEndDate(JsonField.of(statementEndDate)) + + /** + * Sets [Builder.statementEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.statementEndDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statementEndDate(statementEndDate: JsonField) = apply { + this.statementEndDate = statementEndDate + } + + /** Date when the billing period began */ + fun statementStartDate(statementStartDate: LocalDate) = + statementStartDate(JsonField.of(statementStartDate)) + + /** + * Sets [Builder.statementStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.statementStartDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statementStartDate(statementStartDate: JsonField) = apply { + this.statementStartDate = statementStartDate + } + + fun statementType(statementType: Statement.StatementType) = + statementType(JsonField.of(statementType)) + + /** + * Sets [Builder.statementType] to an arbitrary JSON value. + * + * You should usually call [Builder.statementType] with a well-typed + * [Statement.StatementType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun statementType(statementType: JsonField) = apply { + this.statementType = statementType + } + + /** Timestamp of when the statement was updated */ + fun updated(updated: OffsetDateTime) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun ytdTotals(ytdTotals: StatementTotals) = ytdTotals(JsonField.of(ytdTotals)) + + /** + * Sets [Builder.ytdTotals] to an arbitrary JSON value. + * + * You should usually call [Builder.ytdTotals] with a well-typed [StatementTotals] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ytdTotals(ytdTotals: JsonField) = apply { this.ytdTotals = ytdTotals } + + fun interestDetails(interestDetails: Statement.InterestDetails?) = + interestDetails(JsonField.ofNullable(interestDetails)) + + /** Alias for calling [Builder.interestDetails] with `interestDetails.orElse(null)`. */ + fun interestDetails(interestDetails: Optional) = + interestDetails(interestDetails.getOrNull()) + + /** + * Sets [Builder.interestDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.interestDetails] with a well-typed + * [Statement.InterestDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun interestDetails(interestDetails: JsonField) = apply { + this.interestDetails = interestDetails + } + + /** Date when the next payment is due */ + fun nextPaymentDueDate(nextPaymentDueDate: LocalDate) = + nextPaymentDueDate(JsonField.of(nextPaymentDueDate)) + + /** + * Sets [Builder.nextPaymentDueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.nextPaymentDueDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun nextPaymentDueDate(nextPaymentDueDate: JsonField) = apply { + this.nextPaymentDueDate = nextPaymentDueDate + } + + /** Date when the next billing period will end */ + fun nextStatementEndDate(nextStatementEndDate: LocalDate) = + nextStatementEndDate(JsonField.of(nextStatementEndDate)) + + /** + * Sets [Builder.nextStatementEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.nextStatementEndDate] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun nextStatementEndDate(nextStatementEndDate: JsonField) = apply { + this.nextStatementEndDate = nextStatementEndDate + } + + /** Details on number and size of payments to pay off balance */ + fun payoffDetails(payoffDetails: Statement.PayoffDetails?) = + payoffDetails(JsonField.ofNullable(payoffDetails)) + + /** Alias for calling [Builder.payoffDetails] with `payoffDetails.orElse(null)`. */ + fun payoffDetails(payoffDetails: Optional) = + payoffDetails(payoffDetails.getOrNull()) + + /** + * Sets [Builder.payoffDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.payoffDetails] with a well-typed + * [Statement.PayoffDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun payoffDetails(payoffDetails: JsonField) = apply { + this.payoffDetails = payoffDetails + } + + /** 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 [StatementsCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountStanding() + * .amountDue() + * .availableCredit() + * .created() + * .creditLimit() + * .creditProductToken() + * .daysInBillingCycle() + * .endingBalance() + * .financialAccountToken() + * .paymentDueDate() + * .periodTotals() + * .startingBalance() + * .statementEndDate() + * .statementStartDate() + * .statementType() + * .updated() + * .ytdTotals() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): StatementsCreatedWebhookEvent = + StatementsCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountStanding", accountStanding), + checkRequired("amountDue", amountDue), + checkRequired("availableCredit", availableCredit), + checkRequired("created", created), + checkRequired("creditLimit", creditLimit), + checkRequired("creditProductToken", creditProductToken), + checkRequired("daysInBillingCycle", daysInBillingCycle), + checkRequired("endingBalance", endingBalance), + checkRequired("financialAccountToken", financialAccountToken), + checkRequired("paymentDueDate", paymentDueDate), + checkRequired("periodTotals", periodTotals), + checkRequired("startingBalance", startingBalance), + checkRequired("statementEndDate", statementEndDate), + checkRequired("statementStartDate", statementStartDate), + checkRequired("statementType", statementType), + checkRequired("updated", updated), + checkRequired("ytdTotals", ytdTotals), + interestDetails, + nextPaymentDueDate, + nextStatementEndDate, + payoffDetails, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): StatementsCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountStanding().validate() + amountDue().validate() + availableCredit() + created() + creditLimit() + creditProductToken() + daysInBillingCycle() + endingBalance() + financialAccountToken() + paymentDueDate() + periodTotals().validate() + startingBalance() + statementEndDate() + statementStartDate() + statementType().validate() + updated() + ytdTotals().validate() + interestDetails().ifPresent { it.validate() } + nextPaymentDueDate() + nextStatementEndDate() + payoffDetails().ifPresent { it.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 = + (if (token.asKnown().isPresent) 1 else 0) + + (accountStanding.asKnown().getOrNull()?.validity() ?: 0) + + (amountDue.asKnown().getOrNull()?.validity() ?: 0) + + (if (availableCredit.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (creditLimit.asKnown().isPresent) 1 else 0) + + (if (creditProductToken.asKnown().isPresent) 1 else 0) + + (if (daysInBillingCycle.asKnown().isPresent) 1 else 0) + + (if (endingBalance.asKnown().isPresent) 1 else 0) + + (if (financialAccountToken.asKnown().isPresent) 1 else 0) + + (if (paymentDueDate.asKnown().isPresent) 1 else 0) + + (periodTotals.asKnown().getOrNull()?.validity() ?: 0) + + (if (startingBalance.asKnown().isPresent) 1 else 0) + + (if (statementEndDate.asKnown().isPresent) 1 else 0) + + (if (statementStartDate.asKnown().isPresent) 1 else 0) + + (statementType.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (ytdTotals.asKnown().getOrNull()?.validity() ?: 0) + + (interestDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (nextPaymentDueDate.asKnown().isPresent) 1 else 0) + + (if (nextStatementEndDate.asKnown().isPresent) 1 else 0) + + (payoffDetails.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 STATEMENTS_CREATED = of("statements.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + STATEMENTS_CREATED + } + + /** + * 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 { + STATEMENTS_CREATED, + /** + * 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) { + STATEMENTS_CREATED -> Value.STATEMENTS_CREATED + 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) { + STATEMENTS_CREATED -> Known.STATEMENTS_CREATED + 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 + + 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 StatementsCreatedWebhookEvent && + token == other.token && + accountStanding == other.accountStanding && + amountDue == other.amountDue && + availableCredit == other.availableCredit && + created == other.created && + creditLimit == other.creditLimit && + creditProductToken == other.creditProductToken && + daysInBillingCycle == other.daysInBillingCycle && + endingBalance == other.endingBalance && + financialAccountToken == other.financialAccountToken && + paymentDueDate == other.paymentDueDate && + periodTotals == other.periodTotals && + startingBalance == other.startingBalance && + statementEndDate == other.statementEndDate && + statementStartDate == other.statementStartDate && + statementType == other.statementType && + updated == other.updated && + ytdTotals == other.ytdTotals && + interestDetails == other.interestDetails && + nextPaymentDueDate == other.nextPaymentDueDate && + nextStatementEndDate == other.nextStatementEndDate && + payoffDetails == other.payoffDetails && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountStanding, + amountDue, + availableCredit, + created, + creditLimit, + creditProductToken, + daysInBillingCycle, + endingBalance, + financialAccountToken, + paymentDueDate, + periodTotals, + startingBalance, + statementEndDate, + statementStartDate, + statementType, + updated, + ytdTotals, + interestDetails, + nextPaymentDueDate, + nextStatementEndDate, + payoffDetails, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "StatementsCreatedWebhookEvent{token=$token, accountStanding=$accountStanding, amountDue=$amountDue, availableCredit=$availableCredit, created=$created, creditLimit=$creditLimit, creditProductToken=$creditProductToken, daysInBillingCycle=$daysInBillingCycle, endingBalance=$endingBalance, financialAccountToken=$financialAccountToken, paymentDueDate=$paymentDueDate, periodTotals=$periodTotals, startingBalance=$startingBalance, statementEndDate=$statementEndDate, statementStartDate=$statementStartDate, statementType=$statementType, updated=$updated, ytdTotals=$ytdTotals, interestDetails=$interestDetails, nextPaymentDueDate=$nextPaymentDueDate, nextStatementEndDate=$nextStatementEndDate, payoffDetails=$payoffDetails, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationChallengeWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationChallengeWebhookEvent.kt new file mode 100644 index 000000000..469ec3540 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationChallengeWebhookEvent.kt @@ -0,0 +1,839 @@ +// 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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ThreeDSAuthenticationChallengeWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val authenticationObject: JsonField, + private val challenge: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("authentication_object") + @ExcludeMissing + authenticationObject: JsonField = JsonMissing.of(), + @JsonProperty("challenge") + @ExcludeMissing + challenge: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this(authenticationObject, challenge, eventType, mutableMapOf()) + + /** + * Represents a 3DS authentication + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun authenticationObject(): ThreeDSAuthentication = + authenticationObject.getRequired("authentication_object") + + /** + * Represents a challenge object for 3DS authentication + * + * @throws LithicInvalidDataException if 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(): Challenge = challenge.getRequired("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 eventType(): EventType = eventType.getRequired("event_type") + + /** + * Returns the raw JSON value of [authenticationObject]. + * + * Unlike [authenticationObject], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_object") + @ExcludeMissing + fun _authenticationObject(): JsonField = authenticationObject + + /** + * 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 + * [ThreeDSAuthenticationChallengeWebhookEvent]. + * + * The following fields are required: + * ```java + * .authenticationObject() + * .challenge() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThreeDSAuthenticationChallengeWebhookEvent]. */ + class Builder internal constructor() { + + private var authenticationObject: JsonField? = null + private var challenge: JsonField? = null + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + threeDSAuthenticationChallengeWebhookEvent: ThreeDSAuthenticationChallengeWebhookEvent + ) = apply { + authenticationObject = threeDSAuthenticationChallengeWebhookEvent.authenticationObject + challenge = threeDSAuthenticationChallengeWebhookEvent.challenge + eventType = threeDSAuthenticationChallengeWebhookEvent.eventType + additionalProperties = + threeDSAuthenticationChallengeWebhookEvent.additionalProperties.toMutableMap() + } + + /** Represents a 3DS authentication */ + fun authenticationObject(authenticationObject: ThreeDSAuthentication) = + authenticationObject(JsonField.of(authenticationObject)) + + /** + * Sets [Builder.authenticationObject] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationObject] with a well-typed + * [ThreeDSAuthentication] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authenticationObject(authenticationObject: JsonField) = apply { + this.authenticationObject = authenticationObject + } + + /** Represents a challenge object for 3DS authentication */ + fun challenge(challenge: Challenge) = challenge(JsonField.of(challenge)) + + /** + * Sets [Builder.challenge] to an arbitrary JSON value. + * + * You should usually call [Builder.challenge] with a well-typed [Challenge] 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 } + + 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 [ThreeDSAuthenticationChallengeWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .authenticationObject() + * .challenge() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThreeDSAuthenticationChallengeWebhookEvent = + ThreeDSAuthenticationChallengeWebhookEvent( + checkRequired("authenticationObject", authenticationObject), + checkRequired("challenge", challenge), + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThreeDSAuthenticationChallengeWebhookEvent = apply { + if (validated) { + return@apply + } + + authenticationObject().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 = + (authenticationObject.asKnown().getOrNull()?.validity() ?: 0) + + (challenge.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** Represents a challenge object for 3DS authentication */ + class Challenge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val challengeMethodType: JsonField, + private val expiryTime: JsonField, + private val startTime: JsonField, + private val appRequestorUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("challenge_method_type") + @ExcludeMissing + challengeMethodType: JsonField = JsonMissing.of(), + @JsonProperty("expiry_time") + @ExcludeMissing + expiryTime: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + @JsonProperty("app_requestor_url") + @ExcludeMissing + appRequestorUrl: JsonField = JsonMissing.of(), + ) : this(challengeMethodType, expiryTime, startTime, appRequestorUrl, mutableMapOf()) + + /** + * The type of challenge method issued to 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). + */ + fun challengeMethodType(): ChallengeMethodType = + challengeMethodType.getRequired("challenge_method_type") + + /** + * 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 has started + * + * @throws LithicInvalidDataException if 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") + + /** + * Fully qualified app URL of the merchant app. This should be used to redirect the + * cardholder back to the merchant app after completing an app-based challenge. This URL + * will only be populated if the 3DS Requestor App is provided to the 3DS SDK. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun appRequestorUrl(): Optional = appRequestorUrl.getOptional("app_requestor_url") + + /** + * Returns the raw JSON value of [challengeMethodType]. + * + * Unlike [challengeMethodType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("challenge_method_type") + @ExcludeMissing + fun _challengeMethodType(): JsonField = challengeMethodType + + /** + * 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 + + /** + * Returns the raw JSON value of [appRequestorUrl]. + * + * Unlike [appRequestorUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("app_requestor_url") + @ExcludeMissing + fun _appRequestorUrl(): JsonField = appRequestorUrl + + @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 [Challenge]. + * + * The following fields are required: + * ```java + * .challengeMethodType() + * .expiryTime() + * .startTime() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Challenge]. */ + class Builder internal constructor() { + + private var challengeMethodType: JsonField? = null + private var expiryTime: JsonField? = null + private var startTime: JsonField? = null + private var appRequestorUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(challenge: Challenge) = apply { + challengeMethodType = challenge.challengeMethodType + expiryTime = challenge.expiryTime + startTime = challenge.startTime + appRequestorUrl = challenge.appRequestorUrl + additionalProperties = challenge.additionalProperties.toMutableMap() + } + + /** The type of challenge method issued to the cardholder */ + fun challengeMethodType(challengeMethodType: ChallengeMethodType) = + challengeMethodType(JsonField.of(challengeMethodType)) + + /** + * Sets [Builder.challengeMethodType] to an arbitrary JSON value. + * + * You should usually call [Builder.challengeMethodType] with a well-typed + * [ChallengeMethodType] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun challengeMethodType(challengeMethodType: JsonField) = apply { + this.challengeMethodType = challengeMethodType + } + + /** 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 has started */ + 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 + } + + /** + * Fully qualified app URL of the merchant app. This should be used to redirect the + * cardholder back to the merchant app after completing an app-based challenge. This URL + * will only be populated if the 3DS Requestor App is provided to the 3DS SDK. + */ + fun appRequestorUrl(appRequestorUrl: String?) = + appRequestorUrl(JsonField.ofNullable(appRequestorUrl)) + + /** Alias for calling [Builder.appRequestorUrl] with `appRequestorUrl.orElse(null)`. */ + fun appRequestorUrl(appRequestorUrl: Optional) = + appRequestorUrl(appRequestorUrl.getOrNull()) + + /** + * Sets [Builder.appRequestorUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.appRequestorUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun appRequestorUrl(appRequestorUrl: JsonField) = apply { + this.appRequestorUrl = appRequestorUrl + } + + 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 [Challenge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .challengeMethodType() + * .expiryTime() + * .startTime() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Challenge = + Challenge( + checkRequired("challengeMethodType", challengeMethodType), + checkRequired("expiryTime", expiryTime), + checkRequired("startTime", startTime), + appRequestorUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Challenge = apply { + if (validated) { + return@apply + } + + challengeMethodType().validate() + expiryTime() + startTime() + appRequestorUrl() + 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 = + (challengeMethodType.asKnown().getOrNull()?.validity() ?: 0) + + (if (expiryTime.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + (if (appRequestorUrl.asKnown().isPresent) 1 else 0) + + /** The type of challenge method issued to the cardholder */ + class ChallengeMethodType + @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 OUT_OF_BAND = of("OUT_OF_BAND") + + @JvmStatic fun of(value: String) = ChallengeMethodType(JsonField.of(value)) + } + + /** An enum containing [ChallengeMethodType]'s known values. */ + enum class Known { + OUT_OF_BAND + } + + /** + * An enum containing [ChallengeMethodType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ChallengeMethodType] 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 { + OUT_OF_BAND, + /** + * An enum member indicating that [ChallengeMethodType] 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) { + OUT_OF_BAND -> Value.OUT_OF_BAND + 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) { + OUT_OF_BAND -> Known.OUT_OF_BAND + else -> throw LithicInvalidDataException("Unknown ChallengeMethodType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ChallengeMethodType = 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 ChallengeMethodType && 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 Challenge && + challengeMethodType == other.challengeMethodType && + expiryTime == other.expiryTime && + startTime == other.startTime && + appRequestorUrl == other.appRequestorUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + challengeMethodType, + expiryTime, + startTime, + appRequestorUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Challenge{challengeMethodType=$challengeMethodType, expiryTime=$expiryTime, startTime=$startTime, appRequestorUrl=$appRequestorUrl, 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 THREE_DS_AUTHENTICATION_CHALLENGE = of("three_ds_authentication.challenge") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + THREE_DS_AUTHENTICATION_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 { + THREE_DS_AUTHENTICATION_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) { + THREE_DS_AUTHENTICATION_CHALLENGE -> Value.THREE_DS_AUTHENTICATION_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) { + THREE_DS_AUTHENTICATION_CHALLENGE -> Known.THREE_DS_AUTHENTICATION_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 + + 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 ThreeDSAuthenticationChallengeWebhookEvent && + authenticationObject == other.authenticationObject && + challenge == other.challenge && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(authenticationObject, challenge, eventType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThreeDSAuthenticationChallengeWebhookEvent{authenticationObject=$authenticationObject, challenge=$challenge, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationCreatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationCreatedWebhookEvent.kt new file mode 100644 index 000000000..23aea275d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationCreatedWebhookEvent.kt @@ -0,0 +1,1410 @@ +// 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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Represents a 3DS authentication */ +class ThreeDSAuthenticationCreatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountType: JsonField, + private val authenticationResult: JsonField, + private val cardExpiryCheck: JsonField, + private val cardToken: JsonField, + private val cardholder: JsonField, + private val channel: JsonField, + private val created: JsonField, + private val merchant: JsonField, + private val messageCategory: JsonField, + private val threeDSRequestorChallengeIndicator: + JsonField, + private val additionalData: JsonField, + private val app: JsonField, + private val authenticationRequestType: + JsonField, + private val browser: JsonField, + private val challengeMetadata: JsonField, + private val challengeOrchestratedBy: JsonField, + private val decisionMadeBy: JsonField, + private val threeRiRequestType: JsonField, + private val transaction: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_type") + @ExcludeMissing + accountType: JsonField = JsonMissing.of(), + @JsonProperty("authentication_result") + @ExcludeMissing + authenticationResult: JsonField = + JsonMissing.of(), + @JsonProperty("card_expiry_check") + @ExcludeMissing + cardExpiryCheck: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("cardholder") + @ExcludeMissing + cardholder: JsonField = JsonMissing.of(), + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("merchant") + @ExcludeMissing + merchant: JsonField = JsonMissing.of(), + @JsonProperty("message_category") + @ExcludeMissing + messageCategory: JsonField = JsonMissing.of(), + @JsonProperty("three_ds_requestor_challenge_indicator") + @ExcludeMissing + threeDSRequestorChallengeIndicator: + JsonField = + JsonMissing.of(), + @JsonProperty("additional_data") + @ExcludeMissing + additionalData: JsonField = JsonMissing.of(), + @JsonProperty("app") + @ExcludeMissing + app: JsonField = JsonMissing.of(), + @JsonProperty("authentication_request_type") + @ExcludeMissing + authenticationRequestType: JsonField = + JsonMissing.of(), + @JsonProperty("browser") + @ExcludeMissing + browser: JsonField = JsonMissing.of(), + @JsonProperty("challenge_metadata") + @ExcludeMissing + challengeMetadata: JsonField = JsonMissing.of(), + @JsonProperty("challenge_orchestrated_by") + @ExcludeMissing + challengeOrchestratedBy: JsonField = + JsonMissing.of(), + @JsonProperty("decision_made_by") + @ExcludeMissing + decisionMadeBy: JsonField = JsonMissing.of(), + @JsonProperty("three_ri_request_type") + @ExcludeMissing + threeRiRequestType: JsonField = JsonMissing.of(), + @JsonProperty("transaction") + @ExcludeMissing + transaction: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountType, + authenticationResult, + cardExpiryCheck, + cardToken, + cardholder, + channel, + created, + merchant, + messageCategory, + threeDSRequestorChallengeIndicator, + additionalData, + app, + authenticationRequestType, + browser, + challengeMetadata, + challengeOrchestratedBy, + decisionMadeBy, + threeRiRequestType, + transaction, + eventType, + mutableMapOf(), + ) + + fun toThreeDSAuthentication(): ThreeDSAuthentication = + ThreeDSAuthentication.builder() + .token(token) + .accountType(accountType) + .authenticationResult(authenticationResult) + .cardExpiryCheck(cardExpiryCheck) + .cardToken(cardToken) + .cardholder(cardholder) + .channel(channel) + .created(created) + .merchant(merchant) + .messageCategory(messageCategory) + .threeDSRequestorChallengeIndicator(threeDSRequestorChallengeIndicator) + .additionalData(additionalData) + .app(app) + .authenticationRequestType(authenticationRequestType) + .browser(browser) + .challengeMetadata(challengeMetadata) + .challengeOrchestratedBy(challengeOrchestratedBy) + .decisionMadeBy(decisionMadeBy) + .threeRiRequestType(threeRiRequestType) + .transaction(transaction) + .build() + + /** + * Globally unique identifier for the 3DS authentication. Permitted values: 36-digit version 4 + * UUID (including hyphens). + * + * @throws LithicInvalidDataException if 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") + + /** + * Type of account/card that is being used for the transaction. Maps to EMV 3DS field + * `acctType`. + * + * @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") + + /** + * Indicates the outcome of the 3DS authentication process. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun authenticationResult(): ThreeDSAuthentication.AuthenticationResult = + authenticationResult.getRequired("authentication_result") + + /** + * Indicates whether the expiration date provided by the cardholder during checkout matches + * Lithic's record of the card's expiration date. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardExpiryCheck(): ThreeDSAuthentication.CardExpiryCheck = + cardExpiryCheck.getRequired("card_expiry_check") + + /** + * Globally unique identifier for the card on which the 3DS authentication has occurred. + * Permitted values: 36-digit version 4 UUID (including hyphens). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Object containing data about the cardholder provided during 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 cardholder(): ThreeDSAuthentication.Cardholder = cardholder.getRequired("cardholder") + + /** + * Channel in which the authentication occurs. Maps to EMV 3DS field `deviceChannel`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): ThreeDSAuthentication.Channel = channel.getRequired("channel") + + /** + * Date and time when the authentication was created in Lithic's system. Permitted values: Date + * string in the ISO 8601 format yyyy-MM-dd'T'hh:mm:ssZ. + * + * @throws LithicInvalidDataException if 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") + + /** + * Object containing data about the merchant involved in the e-commerce 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 merchant(): ThreeDSAuthentication.Merchant = merchant.getRequired("merchant") + + /** + * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For NON_PAYMENT_AUTHENTICATION, + * additional_data and transaction fields are not populated. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messageCategory(): ThreeDSAuthentication.MessageCategory = + messageCategory.getRequired("message_category") + + /** + * Indicates whether a challenge is requested for this transaction + * * `NO_PREFERENCE` - No Preference + * * `NO_CHALLENGE_REQUESTED` - No Challenge Requested + * * `CHALLENGE_PREFERENCE` - Challenge requested (3DS Requestor preference) + * * `CHALLENGE_MANDATE` - Challenge requested (Mandate) + * * `NO_CHALLENGE_RISK_ALREADY_ASSESSED` - No Challenge requested (Transactional risk analysis + * is already performed) + * * `DATA_SHARE_ONLY` - No Challenge requested (Data Share Only) + * * `OTHER` - Other indicators not captured by above. These are rarely used + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun threeDSRequestorChallengeIndicator(): + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator = + threeDSRequestorChallengeIndicator.getRequired("three_ds_requestor_challenge_indicator") + + /** + * Object containing additional data about the 3DS request that is beyond the EMV 3DS standard + * spec (e.g., specific fields that only certain card networks send but are not required across + * all 3DS requests). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun additionalData(): Optional = + additionalData.getOptional("additional_data") + + /** + * Object containing data about the app used in the e-commerce transaction. Present if the + * channel is 'APP_BASED'. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun app(): Optional = app.getOptional("app") + + /** + * Type of authentication request - i.e., the type of transaction or interaction is causing the + * merchant to request an authentication. Maps to EMV 3DS field + * `threeDSRequestorAuthenticationInd`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authenticationRequestType(): Optional = + authenticationRequestType.getOptional("authentication_request_type") + + /** + * Object containing data about the browser used in the e-commerce transaction. Present if the + * channel is 'BROWSER'. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun browser(): Optional = browser.getOptional("browser") + + /** + * Metadata about the challenge method and delivery. Only present when a challenge is triggered. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun challengeMetadata(): Optional = + challengeMetadata.getOptional("challenge_metadata") + + /** + * Entity that orchestrates the challenge. This won't be set for authentications for which a + * decision has not yet been made (e.g. in-flight customer decisioning request). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun challengeOrchestratedBy(): Optional = + challengeOrchestratedBy.getOptional("challenge_orchestrated_by") + + /** + * Entity that made the authentication decision. This won't be set for authentications for which + * a decision has not yet been made (e.g. in-flight customer decisioning request). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun decisionMadeBy(): Optional = + decisionMadeBy.getOptional("decision_made_by") + + /** + * Type of 3DS Requestor Initiated (3RI) request — i.e., a 3DS authentication that takes place + * at the initiation of the merchant rather than the cardholder. The most common example of this + * is where a merchant is authenticating before billing for a recurring transaction such as a + * pay TV subscription or a utility bill. Maps to EMV 3DS field `threeRIInd`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun threeRiRequestType(): Optional = + threeRiRequestType.getOptional("three_ri_request_type") + + /** + * Object containing data about the e-commerce transaction for which the merchant is requesting + * authentication. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transaction(): Optional = + transaction.getOptional("transaction") + + /** + * 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 [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 [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 [authenticationResult]. + * + * Unlike [authenticationResult], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_result") + @ExcludeMissing + fun _authenticationResult(): JsonField = + authenticationResult + + /** + * Returns the raw JSON value of [cardExpiryCheck]. + * + * Unlike [cardExpiryCheck], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_expiry_check") + @ExcludeMissing + fun _cardExpiryCheck(): JsonField = cardExpiryCheck + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") + @ExcludeMissing + fun _channel(): JsonField = channel + + /** + * 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 [messageCategory]. + * + * Unlike [messageCategory], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message_category") + @ExcludeMissing + fun _messageCategory(): JsonField = messageCategory + + /** + * Returns the raw JSON value of [threeDSRequestorChallengeIndicator]. + * + * Unlike [threeDSRequestorChallengeIndicator], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("three_ds_requestor_challenge_indicator") + @ExcludeMissing + fun _threeDSRequestorChallengeIndicator(): + JsonField = + threeDSRequestorChallengeIndicator + + /** + * Returns the raw JSON value of [additionalData]. + * + * Unlike [additionalData], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("additional_data") + @ExcludeMissing + fun _additionalData(): JsonField = additionalData + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + /** + * Returns the raw JSON value of [authenticationRequestType]. + * + * Unlike [authenticationRequestType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("authentication_request_type") + @ExcludeMissing + fun _authenticationRequestType(): JsonField = + authenticationRequestType + + /** + * Returns the raw JSON value of [browser]. + * + * Unlike [browser], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("browser") + @ExcludeMissing + fun _browser(): JsonField = browser + + /** + * Returns the raw JSON value of [challengeMetadata]. + * + * Unlike [challengeMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("challenge_metadata") + @ExcludeMissing + fun _challengeMetadata(): JsonField = challengeMetadata + + /** + * Returns the raw JSON value of [challengeOrchestratedBy]. + * + * Unlike [challengeOrchestratedBy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("challenge_orchestrated_by") + @ExcludeMissing + fun _challengeOrchestratedBy(): JsonField = + challengeOrchestratedBy + + /** + * Returns the raw JSON value of [decisionMadeBy]. + * + * Unlike [decisionMadeBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("decision_made_by") + @ExcludeMissing + fun _decisionMadeBy(): JsonField = decisionMadeBy + + /** + * Returns the raw JSON value of [threeRiRequestType]. + * + * Unlike [threeRiRequestType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("three_ri_request_type") + @ExcludeMissing + fun _threeRiRequestType(): JsonField = + threeRiRequestType + + /** + * Returns the raw JSON value of [transaction]. + * + * Unlike [transaction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transaction") + @ExcludeMissing + fun _transaction(): JsonField = transaction + + /** + * 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 + * [ThreeDSAuthenticationCreatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountType() + * .authenticationResult() + * .cardExpiryCheck() + * .cardToken() + * .cardholder() + * .channel() + * .created() + * .merchant() + * .messageCategory() + * .threeDSRequestorChallengeIndicator() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThreeDSAuthenticationCreatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountType: JsonField? = null + private var authenticationResult: JsonField? = + null + private var cardExpiryCheck: JsonField? = null + private var cardToken: JsonField? = null + private var cardholder: JsonField? = null + private var channel: JsonField? = null + private var created: JsonField? = null + private var merchant: JsonField? = null + private var messageCategory: JsonField? = null + private var threeDSRequestorChallengeIndicator: + JsonField? = + null + private var additionalData: JsonField = + JsonMissing.of() + private var app: JsonField = JsonMissing.of() + private var authenticationRequestType: + JsonField = + JsonMissing.of() + private var browser: JsonField = JsonMissing.of() + private var challengeMetadata: JsonField = + JsonMissing.of() + private var challengeOrchestratedBy: + JsonField = + JsonMissing.of() + private var decisionMadeBy: JsonField = + JsonMissing.of() + private var threeRiRequestType: JsonField = + JsonMissing.of() + private var transaction: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + threeDSAuthenticationCreatedWebhookEvent: ThreeDSAuthenticationCreatedWebhookEvent + ) = apply { + token = threeDSAuthenticationCreatedWebhookEvent.token + accountType = threeDSAuthenticationCreatedWebhookEvent.accountType + authenticationResult = threeDSAuthenticationCreatedWebhookEvent.authenticationResult + cardExpiryCheck = threeDSAuthenticationCreatedWebhookEvent.cardExpiryCheck + cardToken = threeDSAuthenticationCreatedWebhookEvent.cardToken + cardholder = threeDSAuthenticationCreatedWebhookEvent.cardholder + channel = threeDSAuthenticationCreatedWebhookEvent.channel + created = threeDSAuthenticationCreatedWebhookEvent.created + merchant = threeDSAuthenticationCreatedWebhookEvent.merchant + messageCategory = threeDSAuthenticationCreatedWebhookEvent.messageCategory + threeDSRequestorChallengeIndicator = + threeDSAuthenticationCreatedWebhookEvent.threeDSRequestorChallengeIndicator + additionalData = threeDSAuthenticationCreatedWebhookEvent.additionalData + app = threeDSAuthenticationCreatedWebhookEvent.app + authenticationRequestType = + threeDSAuthenticationCreatedWebhookEvent.authenticationRequestType + browser = threeDSAuthenticationCreatedWebhookEvent.browser + challengeMetadata = threeDSAuthenticationCreatedWebhookEvent.challengeMetadata + challengeOrchestratedBy = + threeDSAuthenticationCreatedWebhookEvent.challengeOrchestratedBy + decisionMadeBy = threeDSAuthenticationCreatedWebhookEvent.decisionMadeBy + threeRiRequestType = threeDSAuthenticationCreatedWebhookEvent.threeRiRequestType + transaction = threeDSAuthenticationCreatedWebhookEvent.transaction + eventType = threeDSAuthenticationCreatedWebhookEvent.eventType + additionalProperties = + threeDSAuthenticationCreatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** + * Globally unique identifier for the 3DS authentication. Permitted values: 36-digit version + * 4 UUID (including hyphens). + */ + 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 } + + /** + * Type of account/card that is being used for the transaction. Maps to EMV 3DS field + * `acctType`. + */ + fun accountType(accountType: ThreeDSAuthentication.AccountType?) = + accountType(JsonField.ofNullable(accountType)) + + /** Alias for calling [Builder.accountType] with `accountType.orElse(null)`. */ + fun accountType(accountType: Optional) = + accountType(accountType.getOrNull()) + + /** + * Sets [Builder.accountType] to an arbitrary JSON value. + * + * You should usually call [Builder.accountType] with a well-typed + * [ThreeDSAuthentication.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 + } + + /** Indicates the outcome of the 3DS authentication process. */ + fun authenticationResult(authenticationResult: ThreeDSAuthentication.AuthenticationResult) = + authenticationResult(JsonField.of(authenticationResult)) + + /** + * Sets [Builder.authenticationResult] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationResult] with a well-typed + * [ThreeDSAuthentication.AuthenticationResult] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun authenticationResult( + authenticationResult: JsonField + ) = apply { this.authenticationResult = authenticationResult } + + /** + * Indicates whether the expiration date provided by the cardholder during checkout matches + * Lithic's record of the card's expiration date. + */ + fun cardExpiryCheck(cardExpiryCheck: ThreeDSAuthentication.CardExpiryCheck) = + cardExpiryCheck(JsonField.of(cardExpiryCheck)) + + /** + * Sets [Builder.cardExpiryCheck] to an arbitrary JSON value. + * + * You should usually call [Builder.cardExpiryCheck] with a well-typed + * [ThreeDSAuthentication.CardExpiryCheck] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun cardExpiryCheck(cardExpiryCheck: JsonField) = + apply { + this.cardExpiryCheck = cardExpiryCheck + } + + /** + * Globally unique identifier for the card on which the 3DS authentication has occurred. + * Permitted values: 36-digit version 4 UUID (including hyphens). + */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Object containing data about the cardholder provided during the transaction. */ + fun cardholder(cardholder: ThreeDSAuthentication.Cardholder) = + cardholder(JsonField.of(cardholder)) + + /** + * Sets [Builder.cardholder] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholder] with a well-typed + * [ThreeDSAuthentication.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 + } + + /** Channel in which the authentication occurs. Maps to EMV 3DS field `deviceChannel`. */ + fun channel(channel: ThreeDSAuthentication.Channel) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed + * [ThreeDSAuthentication.Channel] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun channel(channel: JsonField) = apply { + this.channel = channel + } + + /** + * Date and time when the authentication was created in Lithic's system. Permitted values: + * Date string in the ISO 8601 format yyyy-MM-dd'T'hh:mm:ssZ. + */ + 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 } + + /** Object containing data about the merchant involved in the e-commerce transaction. */ + fun merchant(merchant: ThreeDSAuthentication.Merchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed + * [ThreeDSAuthentication.Merchant] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun merchant(merchant: JsonField) = apply { + this.merchant = merchant + } + + /** + * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For + * NON_PAYMENT_AUTHENTICATION, additional_data and transaction fields are not populated. + */ + fun messageCategory(messageCategory: ThreeDSAuthentication.MessageCategory) = + messageCategory(JsonField.of(messageCategory)) + + /** + * Sets [Builder.messageCategory] to an arbitrary JSON value. + * + * You should usually call [Builder.messageCategory] with a well-typed + * [ThreeDSAuthentication.MessageCategory] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun messageCategory(messageCategory: JsonField) = + apply { + this.messageCategory = messageCategory + } + + /** + * Indicates whether a challenge is requested for this transaction + * * `NO_PREFERENCE` - No Preference + * * `NO_CHALLENGE_REQUESTED` - No Challenge Requested + * * `CHALLENGE_PREFERENCE` - Challenge requested (3DS Requestor preference) + * * `CHALLENGE_MANDATE` - Challenge requested (Mandate) + * * `NO_CHALLENGE_RISK_ALREADY_ASSESSED` - No Challenge requested (Transactional risk + * analysis is already performed) + * * `DATA_SHARE_ONLY` - No Challenge requested (Data Share Only) + * * `OTHER` - Other indicators not captured by above. These are rarely used + */ + fun threeDSRequestorChallengeIndicator( + threeDSRequestorChallengeIndicator: + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator + ) = threeDSRequestorChallengeIndicator(JsonField.of(threeDSRequestorChallengeIndicator)) + + /** + * Sets [Builder.threeDSRequestorChallengeIndicator] to an arbitrary JSON value. + * + * You should usually call [Builder.threeDSRequestorChallengeIndicator] with a well-typed + * [ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun threeDSRequestorChallengeIndicator( + threeDSRequestorChallengeIndicator: + JsonField + ) = apply { this.threeDSRequestorChallengeIndicator = threeDSRequestorChallengeIndicator } + + /** + * Object containing additional data about the 3DS request that is beyond the EMV 3DS + * standard spec (e.g., specific fields that only certain card networks send but are not + * required across all 3DS requests). + */ + fun additionalData(additionalData: ThreeDSAuthentication.AdditionalData?) = + additionalData(JsonField.ofNullable(additionalData)) + + /** Alias for calling [Builder.additionalData] with `additionalData.orElse(null)`. */ + fun additionalData(additionalData: Optional) = + additionalData(additionalData.getOrNull()) + + /** + * Sets [Builder.additionalData] to an arbitrary JSON value. + * + * You should usually call [Builder.additionalData] with a well-typed + * [ThreeDSAuthentication.AdditionalData] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun additionalData(additionalData: JsonField) = + apply { + this.additionalData = additionalData + } + + /** + * Object containing data about the app used in the e-commerce transaction. Present if the + * channel is 'APP_BASED'. + */ + fun app(app: ThreeDSAuthentication.App?) = app(JsonField.ofNullable(app)) + + /** Alias for calling [Builder.app] with `app.orElse(null)`. */ + fun app(app: Optional) = app(app.getOrNull()) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [ThreeDSAuthentication.App] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + /** + * Type of authentication request - i.e., the type of transaction or interaction is causing + * the merchant to request an authentication. Maps to EMV 3DS field + * `threeDSRequestorAuthenticationInd`. + */ + fun authenticationRequestType( + authenticationRequestType: ThreeDSAuthentication.AuthenticationRequestType? + ) = authenticationRequestType(JsonField.ofNullable(authenticationRequestType)) + + /** + * Alias for calling [Builder.authenticationRequestType] with + * `authenticationRequestType.orElse(null)`. + */ + fun authenticationRequestType( + authenticationRequestType: Optional + ) = authenticationRequestType(authenticationRequestType.getOrNull()) + + /** + * Sets [Builder.authenticationRequestType] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationRequestType] with a well-typed + * [ThreeDSAuthentication.AuthenticationRequestType] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun authenticationRequestType( + authenticationRequestType: JsonField + ) = apply { this.authenticationRequestType = authenticationRequestType } + + /** + * Object containing data about the browser used in the e-commerce transaction. Present if + * the channel is 'BROWSER'. + */ + fun browser(browser: ThreeDSAuthentication.Browser?) = + browser(JsonField.ofNullable(browser)) + + /** Alias for calling [Builder.browser] with `browser.orElse(null)`. */ + fun browser(browser: Optional) = browser(browser.getOrNull()) + + /** + * Sets [Builder.browser] to an arbitrary JSON value. + * + * You should usually call [Builder.browser] with a well-typed + * [ThreeDSAuthentication.Browser] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun browser(browser: JsonField) = apply { + this.browser = browser + } + + /** + * Metadata about the challenge method and delivery. Only present when a challenge is + * triggered. + */ + fun challengeMetadata(challengeMetadata: ThreeDSAuthentication.ChallengeMetadata?) = + challengeMetadata(JsonField.ofNullable(challengeMetadata)) + + /** Alias for calling [Builder.challengeMetadata] with `challengeMetadata.orElse(null)`. */ + fun challengeMetadata( + challengeMetadata: Optional + ) = challengeMetadata(challengeMetadata.getOrNull()) + + /** + * Sets [Builder.challengeMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.challengeMetadata] with a well-typed + * [ThreeDSAuthentication.ChallengeMetadata] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun challengeMetadata( + challengeMetadata: JsonField + ) = apply { this.challengeMetadata = challengeMetadata } + + /** + * Entity that orchestrates the challenge. This won't be set for authentications for which a + * decision has not yet been made (e.g. in-flight customer decisioning request). + */ + fun challengeOrchestratedBy( + challengeOrchestratedBy: ThreeDSAuthentication.ChallengeOrchestratedBy? + ) = challengeOrchestratedBy(JsonField.ofNullable(challengeOrchestratedBy)) + + /** + * Alias for calling [Builder.challengeOrchestratedBy] with + * `challengeOrchestratedBy.orElse(null)`. + */ + fun challengeOrchestratedBy( + challengeOrchestratedBy: Optional + ) = challengeOrchestratedBy(challengeOrchestratedBy.getOrNull()) + + /** + * Sets [Builder.challengeOrchestratedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.challengeOrchestratedBy] with a well-typed + * [ThreeDSAuthentication.ChallengeOrchestratedBy] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun challengeOrchestratedBy( + challengeOrchestratedBy: JsonField + ) = apply { this.challengeOrchestratedBy = challengeOrchestratedBy } + + /** + * Entity that made the authentication decision. This won't be set for authentications for + * which a decision has not yet been made (e.g. in-flight customer decisioning request). + */ + fun decisionMadeBy(decisionMadeBy: ThreeDSAuthentication.DecisionMadeBy?) = + decisionMadeBy(JsonField.ofNullable(decisionMadeBy)) + + /** Alias for calling [Builder.decisionMadeBy] with `decisionMadeBy.orElse(null)`. */ + fun decisionMadeBy(decisionMadeBy: Optional) = + decisionMadeBy(decisionMadeBy.getOrNull()) + + /** + * Sets [Builder.decisionMadeBy] to an arbitrary JSON value. + * + * You should usually call [Builder.decisionMadeBy] with a well-typed + * [ThreeDSAuthentication.DecisionMadeBy] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun decisionMadeBy(decisionMadeBy: JsonField) = + apply { + this.decisionMadeBy = decisionMadeBy + } + + /** + * Type of 3DS Requestor Initiated (3RI) request — i.e., a 3DS authentication that takes + * place at the initiation of the merchant rather than the cardholder. The most common + * example of this is where a merchant is authenticating before billing for a recurring + * transaction such as a pay TV subscription or a utility bill. Maps to EMV 3DS field + * `threeRIInd`. + */ + fun threeRiRequestType(threeRiRequestType: ThreeDSAuthentication.ThreeRiRequestType?) = + threeRiRequestType(JsonField.ofNullable(threeRiRequestType)) + + /** + * Alias for calling [Builder.threeRiRequestType] with `threeRiRequestType.orElse(null)`. + */ + fun threeRiRequestType( + threeRiRequestType: Optional + ) = threeRiRequestType(threeRiRequestType.getOrNull()) + + /** + * Sets [Builder.threeRiRequestType] to an arbitrary JSON value. + * + * You should usually call [Builder.threeRiRequestType] with a well-typed + * [ThreeDSAuthentication.ThreeRiRequestType] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun threeRiRequestType( + threeRiRequestType: JsonField + ) = apply { this.threeRiRequestType = threeRiRequestType } + + /** + * Object containing data about the e-commerce transaction for which the merchant is + * requesting authentication. + */ + fun transaction(transaction: ThreeDSAuthentication.Transaction?) = + transaction(JsonField.ofNullable(transaction)) + + /** Alias for calling [Builder.transaction] with `transaction.orElse(null)`. */ + fun transaction(transaction: Optional) = + transaction(transaction.getOrNull()) + + /** + * Sets [Builder.transaction] to an arbitrary JSON value. + * + * You should usually call [Builder.transaction] with a well-typed + * [ThreeDSAuthentication.Transaction] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun transaction(transaction: JsonField) = apply { + this.transaction = transaction + } + + /** 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 [ThreeDSAuthenticationCreatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountType() + * .authenticationResult() + * .cardExpiryCheck() + * .cardToken() + * .cardholder() + * .channel() + * .created() + * .merchant() + * .messageCategory() + * .threeDSRequestorChallengeIndicator() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThreeDSAuthenticationCreatedWebhookEvent = + ThreeDSAuthenticationCreatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountType", accountType), + checkRequired("authenticationResult", authenticationResult), + checkRequired("cardExpiryCheck", cardExpiryCheck), + checkRequired("cardToken", cardToken), + checkRequired("cardholder", cardholder), + checkRequired("channel", channel), + checkRequired("created", created), + checkRequired("merchant", merchant), + checkRequired("messageCategory", messageCategory), + checkRequired( + "threeDSRequestorChallengeIndicator", + threeDSRequestorChallengeIndicator, + ), + additionalData, + app, + authenticationRequestType, + browser, + challengeMetadata, + challengeOrchestratedBy, + decisionMadeBy, + threeRiRequestType, + transaction, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThreeDSAuthenticationCreatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountType().ifPresent { it.validate() } + authenticationResult().validate() + cardExpiryCheck().validate() + cardToken() + cardholder().validate() + channel().validate() + created() + merchant().validate() + messageCategory().validate() + threeDSRequestorChallengeIndicator().validate() + additionalData().ifPresent { it.validate() } + app().ifPresent { it.validate() } + authenticationRequestType().ifPresent { it.validate() } + browser().ifPresent { it.validate() } + challengeMetadata().ifPresent { it.validate() } + challengeOrchestratedBy().ifPresent { it.validate() } + decisionMadeBy().ifPresent { it.validate() } + threeRiRequestType().ifPresent { it.validate() } + transaction().ifPresent { it.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 = + (if (token.asKnown().isPresent) 1 else 0) + + (accountType.asKnown().getOrNull()?.validity() ?: 0) + + (authenticationResult.asKnown().getOrNull()?.validity() ?: 0) + + (cardExpiryCheck.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (cardholder.asKnown().getOrNull()?.validity() ?: 0) + + (channel.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (messageCategory.asKnown().getOrNull()?.validity() ?: 0) + + (threeDSRequestorChallengeIndicator.asKnown().getOrNull()?.validity() ?: 0) + + (additionalData.asKnown().getOrNull()?.validity() ?: 0) + + (app.asKnown().getOrNull()?.validity() ?: 0) + + (authenticationRequestType.asKnown().getOrNull()?.validity() ?: 0) + + (browser.asKnown().getOrNull()?.validity() ?: 0) + + (challengeMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (challengeOrchestratedBy.asKnown().getOrNull()?.validity() ?: 0) + + (decisionMadeBy.asKnown().getOrNull()?.validity() ?: 0) + + (threeRiRequestType.asKnown().getOrNull()?.validity() ?: 0) + + (transaction.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 THREE_DS_AUTHENTICATION_CREATED = of("three_ds_authentication.created") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + THREE_DS_AUTHENTICATION_CREATED + } + + /** + * 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 { + THREE_DS_AUTHENTICATION_CREATED, + /** + * 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) { + THREE_DS_AUTHENTICATION_CREATED -> Value.THREE_DS_AUTHENTICATION_CREATED + 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) { + THREE_DS_AUTHENTICATION_CREATED -> Known.THREE_DS_AUTHENTICATION_CREATED + 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 + + 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 ThreeDSAuthenticationCreatedWebhookEvent && + token == other.token && + accountType == other.accountType && + authenticationResult == other.authenticationResult && + cardExpiryCheck == other.cardExpiryCheck && + cardToken == other.cardToken && + cardholder == other.cardholder && + channel == other.channel && + created == other.created && + merchant == other.merchant && + messageCategory == other.messageCategory && + threeDSRequestorChallengeIndicator == other.threeDSRequestorChallengeIndicator && + additionalData == other.additionalData && + app == other.app && + authenticationRequestType == other.authenticationRequestType && + browser == other.browser && + challengeMetadata == other.challengeMetadata && + challengeOrchestratedBy == other.challengeOrchestratedBy && + decisionMadeBy == other.decisionMadeBy && + threeRiRequestType == other.threeRiRequestType && + transaction == other.transaction && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountType, + authenticationResult, + cardExpiryCheck, + cardToken, + cardholder, + channel, + created, + merchant, + messageCategory, + threeDSRequestorChallengeIndicator, + additionalData, + app, + authenticationRequestType, + browser, + challengeMetadata, + challengeOrchestratedBy, + decisionMadeBy, + threeRiRequestType, + transaction, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThreeDSAuthenticationCreatedWebhookEvent{token=$token, accountType=$accountType, authenticationResult=$authenticationResult, cardExpiryCheck=$cardExpiryCheck, cardToken=$cardToken, cardholder=$cardholder, channel=$channel, created=$created, merchant=$merchant, messageCategory=$messageCategory, threeDSRequestorChallengeIndicator=$threeDSRequestorChallengeIndicator, additionalData=$additionalData, app=$app, authenticationRequestType=$authenticationRequestType, browser=$browser, challengeMetadata=$challengeMetadata, challengeOrchestratedBy=$challengeOrchestratedBy, decisionMadeBy=$decisionMadeBy, threeRiRequestType=$threeRiRequestType, transaction=$transaction, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationUpdatedWebhookEvent.kt new file mode 100644 index 000000000..679149e0f --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ThreeDSAuthenticationUpdatedWebhookEvent.kt @@ -0,0 +1,1410 @@ +// 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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Represents a 3DS authentication */ +class ThreeDSAuthenticationUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val accountType: JsonField, + private val authenticationResult: JsonField, + private val cardExpiryCheck: JsonField, + private val cardToken: JsonField, + private val cardholder: JsonField, + private val channel: JsonField, + private val created: JsonField, + private val merchant: JsonField, + private val messageCategory: JsonField, + private val threeDSRequestorChallengeIndicator: + JsonField, + private val additionalData: JsonField, + private val app: JsonField, + private val authenticationRequestType: + JsonField, + private val browser: JsonField, + private val challengeMetadata: JsonField, + private val challengeOrchestratedBy: JsonField, + private val decisionMadeBy: JsonField, + private val threeRiRequestType: JsonField, + private val transaction: JsonField, + private val eventType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("account_type") + @ExcludeMissing + accountType: JsonField = JsonMissing.of(), + @JsonProperty("authentication_result") + @ExcludeMissing + authenticationResult: JsonField = + JsonMissing.of(), + @JsonProperty("card_expiry_check") + @ExcludeMissing + cardExpiryCheck: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("cardholder") + @ExcludeMissing + cardholder: JsonField = JsonMissing.of(), + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("merchant") + @ExcludeMissing + merchant: JsonField = JsonMissing.of(), + @JsonProperty("message_category") + @ExcludeMissing + messageCategory: JsonField = JsonMissing.of(), + @JsonProperty("three_ds_requestor_challenge_indicator") + @ExcludeMissing + threeDSRequestorChallengeIndicator: + JsonField = + JsonMissing.of(), + @JsonProperty("additional_data") + @ExcludeMissing + additionalData: JsonField = JsonMissing.of(), + @JsonProperty("app") + @ExcludeMissing + app: JsonField = JsonMissing.of(), + @JsonProperty("authentication_request_type") + @ExcludeMissing + authenticationRequestType: JsonField = + JsonMissing.of(), + @JsonProperty("browser") + @ExcludeMissing + browser: JsonField = JsonMissing.of(), + @JsonProperty("challenge_metadata") + @ExcludeMissing + challengeMetadata: JsonField = JsonMissing.of(), + @JsonProperty("challenge_orchestrated_by") + @ExcludeMissing + challengeOrchestratedBy: JsonField = + JsonMissing.of(), + @JsonProperty("decision_made_by") + @ExcludeMissing + decisionMadeBy: JsonField = JsonMissing.of(), + @JsonProperty("three_ri_request_type") + @ExcludeMissing + threeRiRequestType: JsonField = JsonMissing.of(), + @JsonProperty("transaction") + @ExcludeMissing + transaction: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + ) : this( + token, + accountType, + authenticationResult, + cardExpiryCheck, + cardToken, + cardholder, + channel, + created, + merchant, + messageCategory, + threeDSRequestorChallengeIndicator, + additionalData, + app, + authenticationRequestType, + browser, + challengeMetadata, + challengeOrchestratedBy, + decisionMadeBy, + threeRiRequestType, + transaction, + eventType, + mutableMapOf(), + ) + + fun toThreeDSAuthentication(): ThreeDSAuthentication = + ThreeDSAuthentication.builder() + .token(token) + .accountType(accountType) + .authenticationResult(authenticationResult) + .cardExpiryCheck(cardExpiryCheck) + .cardToken(cardToken) + .cardholder(cardholder) + .channel(channel) + .created(created) + .merchant(merchant) + .messageCategory(messageCategory) + .threeDSRequestorChallengeIndicator(threeDSRequestorChallengeIndicator) + .additionalData(additionalData) + .app(app) + .authenticationRequestType(authenticationRequestType) + .browser(browser) + .challengeMetadata(challengeMetadata) + .challengeOrchestratedBy(challengeOrchestratedBy) + .decisionMadeBy(decisionMadeBy) + .threeRiRequestType(threeRiRequestType) + .transaction(transaction) + .build() + + /** + * Globally unique identifier for the 3DS authentication. Permitted values: 36-digit version 4 + * UUID (including hyphens). + * + * @throws LithicInvalidDataException if 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") + + /** + * Type of account/card that is being used for the transaction. Maps to EMV 3DS field + * `acctType`. + * + * @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") + + /** + * Indicates the outcome of the 3DS authentication process. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun authenticationResult(): ThreeDSAuthentication.AuthenticationResult = + authenticationResult.getRequired("authentication_result") + + /** + * Indicates whether the expiration date provided by the cardholder during checkout matches + * Lithic's record of the card's expiration date. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardExpiryCheck(): ThreeDSAuthentication.CardExpiryCheck = + cardExpiryCheck.getRequired("card_expiry_check") + + /** + * Globally unique identifier for the card on which the 3DS authentication has occurred. + * Permitted values: 36-digit version 4 UUID (including hyphens). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Object containing data about the cardholder provided during 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 cardholder(): ThreeDSAuthentication.Cardholder = cardholder.getRequired("cardholder") + + /** + * Channel in which the authentication occurs. Maps to EMV 3DS field `deviceChannel`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): ThreeDSAuthentication.Channel = channel.getRequired("channel") + + /** + * Date and time when the authentication was created in Lithic's system. Permitted values: Date + * string in the ISO 8601 format yyyy-MM-dd'T'hh:mm:ssZ. + * + * @throws LithicInvalidDataException if 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") + + /** + * Object containing data about the merchant involved in the e-commerce 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 merchant(): ThreeDSAuthentication.Merchant = merchant.getRequired("merchant") + + /** + * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For NON_PAYMENT_AUTHENTICATION, + * additional_data and transaction fields are not populated. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messageCategory(): ThreeDSAuthentication.MessageCategory = + messageCategory.getRequired("message_category") + + /** + * Indicates whether a challenge is requested for this transaction + * * `NO_PREFERENCE` - No Preference + * * `NO_CHALLENGE_REQUESTED` - No Challenge Requested + * * `CHALLENGE_PREFERENCE` - Challenge requested (3DS Requestor preference) + * * `CHALLENGE_MANDATE` - Challenge requested (Mandate) + * * `NO_CHALLENGE_RISK_ALREADY_ASSESSED` - No Challenge requested (Transactional risk analysis + * is already performed) + * * `DATA_SHARE_ONLY` - No Challenge requested (Data Share Only) + * * `OTHER` - Other indicators not captured by above. These are rarely used + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun threeDSRequestorChallengeIndicator(): + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator = + threeDSRequestorChallengeIndicator.getRequired("three_ds_requestor_challenge_indicator") + + /** + * Object containing additional data about the 3DS request that is beyond the EMV 3DS standard + * spec (e.g., specific fields that only certain card networks send but are not required across + * all 3DS requests). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun additionalData(): Optional = + additionalData.getOptional("additional_data") + + /** + * Object containing data about the app used in the e-commerce transaction. Present if the + * channel is 'APP_BASED'. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun app(): Optional = app.getOptional("app") + + /** + * Type of authentication request - i.e., the type of transaction or interaction is causing the + * merchant to request an authentication. Maps to EMV 3DS field + * `threeDSRequestorAuthenticationInd`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun authenticationRequestType(): Optional = + authenticationRequestType.getOptional("authentication_request_type") + + /** + * Object containing data about the browser used in the e-commerce transaction. Present if the + * channel is 'BROWSER'. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun browser(): Optional = browser.getOptional("browser") + + /** + * Metadata about the challenge method and delivery. Only present when a challenge is triggered. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun challengeMetadata(): Optional = + challengeMetadata.getOptional("challenge_metadata") + + /** + * Entity that orchestrates the challenge. This won't be set for authentications for which a + * decision has not yet been made (e.g. in-flight customer decisioning request). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun challengeOrchestratedBy(): Optional = + challengeOrchestratedBy.getOptional("challenge_orchestrated_by") + + /** + * Entity that made the authentication decision. This won't be set for authentications for which + * a decision has not yet been made (e.g. in-flight customer decisioning request). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun decisionMadeBy(): Optional = + decisionMadeBy.getOptional("decision_made_by") + + /** + * Type of 3DS Requestor Initiated (3RI) request — i.e., a 3DS authentication that takes place + * at the initiation of the merchant rather than the cardholder. The most common example of this + * is where a merchant is authenticating before billing for a recurring transaction such as a + * pay TV subscription or a utility bill. Maps to EMV 3DS field `threeRIInd`. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun threeRiRequestType(): Optional = + threeRiRequestType.getOptional("three_ri_request_type") + + /** + * Object containing data about the e-commerce transaction for which the merchant is requesting + * authentication. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transaction(): Optional = + transaction.getOptional("transaction") + + /** + * 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 [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 [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 [authenticationResult]. + * + * Unlike [authenticationResult], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_result") + @ExcludeMissing + fun _authenticationResult(): JsonField = + authenticationResult + + /** + * Returns the raw JSON value of [cardExpiryCheck]. + * + * Unlike [cardExpiryCheck], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_expiry_check") + @ExcludeMissing + fun _cardExpiryCheck(): JsonField = cardExpiryCheck + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") + @ExcludeMissing + fun _channel(): JsonField = channel + + /** + * 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 [messageCategory]. + * + * Unlike [messageCategory], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message_category") + @ExcludeMissing + fun _messageCategory(): JsonField = messageCategory + + /** + * Returns the raw JSON value of [threeDSRequestorChallengeIndicator]. + * + * Unlike [threeDSRequestorChallengeIndicator], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("three_ds_requestor_challenge_indicator") + @ExcludeMissing + fun _threeDSRequestorChallengeIndicator(): + JsonField = + threeDSRequestorChallengeIndicator + + /** + * Returns the raw JSON value of [additionalData]. + * + * Unlike [additionalData], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("additional_data") + @ExcludeMissing + fun _additionalData(): JsonField = additionalData + + /** + * Returns the raw JSON value of [app]. + * + * Unlike [app], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app") @ExcludeMissing fun _app(): JsonField = app + + /** + * Returns the raw JSON value of [authenticationRequestType]. + * + * Unlike [authenticationRequestType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("authentication_request_type") + @ExcludeMissing + fun _authenticationRequestType(): JsonField = + authenticationRequestType + + /** + * Returns the raw JSON value of [browser]. + * + * Unlike [browser], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("browser") + @ExcludeMissing + fun _browser(): JsonField = browser + + /** + * Returns the raw JSON value of [challengeMetadata]. + * + * Unlike [challengeMetadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("challenge_metadata") + @ExcludeMissing + fun _challengeMetadata(): JsonField = challengeMetadata + + /** + * Returns the raw JSON value of [challengeOrchestratedBy]. + * + * Unlike [challengeOrchestratedBy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("challenge_orchestrated_by") + @ExcludeMissing + fun _challengeOrchestratedBy(): JsonField = + challengeOrchestratedBy + + /** + * Returns the raw JSON value of [decisionMadeBy]. + * + * Unlike [decisionMadeBy], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("decision_made_by") + @ExcludeMissing + fun _decisionMadeBy(): JsonField = decisionMadeBy + + /** + * Returns the raw JSON value of [threeRiRequestType]. + * + * Unlike [threeRiRequestType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("three_ri_request_type") + @ExcludeMissing + fun _threeRiRequestType(): JsonField = + threeRiRequestType + + /** + * Returns the raw JSON value of [transaction]. + * + * Unlike [transaction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transaction") + @ExcludeMissing + fun _transaction(): JsonField = transaction + + /** + * 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 + * [ThreeDSAuthenticationUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .token() + * .accountType() + * .authenticationResult() + * .cardExpiryCheck() + * .cardToken() + * .cardholder() + * .channel() + * .created() + * .merchant() + * .messageCategory() + * .threeDSRequestorChallengeIndicator() + * .eventType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ThreeDSAuthenticationUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var accountType: JsonField? = null + private var authenticationResult: JsonField? = + null + private var cardExpiryCheck: JsonField? = null + private var cardToken: JsonField? = null + private var cardholder: JsonField? = null + private var channel: JsonField? = null + private var created: JsonField? = null + private var merchant: JsonField? = null + private var messageCategory: JsonField? = null + private var threeDSRequestorChallengeIndicator: + JsonField? = + null + private var additionalData: JsonField = + JsonMissing.of() + private var app: JsonField = JsonMissing.of() + private var authenticationRequestType: + JsonField = + JsonMissing.of() + private var browser: JsonField = JsonMissing.of() + private var challengeMetadata: JsonField = + JsonMissing.of() + private var challengeOrchestratedBy: + JsonField = + JsonMissing.of() + private var decisionMadeBy: JsonField = + JsonMissing.of() + private var threeRiRequestType: JsonField = + JsonMissing.of() + private var transaction: JsonField = JsonMissing.of() + private var eventType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + threeDSAuthenticationUpdatedWebhookEvent: ThreeDSAuthenticationUpdatedWebhookEvent + ) = apply { + token = threeDSAuthenticationUpdatedWebhookEvent.token + accountType = threeDSAuthenticationUpdatedWebhookEvent.accountType + authenticationResult = threeDSAuthenticationUpdatedWebhookEvent.authenticationResult + cardExpiryCheck = threeDSAuthenticationUpdatedWebhookEvent.cardExpiryCheck + cardToken = threeDSAuthenticationUpdatedWebhookEvent.cardToken + cardholder = threeDSAuthenticationUpdatedWebhookEvent.cardholder + channel = threeDSAuthenticationUpdatedWebhookEvent.channel + created = threeDSAuthenticationUpdatedWebhookEvent.created + merchant = threeDSAuthenticationUpdatedWebhookEvent.merchant + messageCategory = threeDSAuthenticationUpdatedWebhookEvent.messageCategory + threeDSRequestorChallengeIndicator = + threeDSAuthenticationUpdatedWebhookEvent.threeDSRequestorChallengeIndicator + additionalData = threeDSAuthenticationUpdatedWebhookEvent.additionalData + app = threeDSAuthenticationUpdatedWebhookEvent.app + authenticationRequestType = + threeDSAuthenticationUpdatedWebhookEvent.authenticationRequestType + browser = threeDSAuthenticationUpdatedWebhookEvent.browser + challengeMetadata = threeDSAuthenticationUpdatedWebhookEvent.challengeMetadata + challengeOrchestratedBy = + threeDSAuthenticationUpdatedWebhookEvent.challengeOrchestratedBy + decisionMadeBy = threeDSAuthenticationUpdatedWebhookEvent.decisionMadeBy + threeRiRequestType = threeDSAuthenticationUpdatedWebhookEvent.threeRiRequestType + transaction = threeDSAuthenticationUpdatedWebhookEvent.transaction + eventType = threeDSAuthenticationUpdatedWebhookEvent.eventType + additionalProperties = + threeDSAuthenticationUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** + * Globally unique identifier for the 3DS authentication. Permitted values: 36-digit version + * 4 UUID (including hyphens). + */ + 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 } + + /** + * Type of account/card that is being used for the transaction. Maps to EMV 3DS field + * `acctType`. + */ + fun accountType(accountType: ThreeDSAuthentication.AccountType?) = + accountType(JsonField.ofNullable(accountType)) + + /** Alias for calling [Builder.accountType] with `accountType.orElse(null)`. */ + fun accountType(accountType: Optional) = + accountType(accountType.getOrNull()) + + /** + * Sets [Builder.accountType] to an arbitrary JSON value. + * + * You should usually call [Builder.accountType] with a well-typed + * [ThreeDSAuthentication.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 + } + + /** Indicates the outcome of the 3DS authentication process. */ + fun authenticationResult(authenticationResult: ThreeDSAuthentication.AuthenticationResult) = + authenticationResult(JsonField.of(authenticationResult)) + + /** + * Sets [Builder.authenticationResult] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationResult] with a well-typed + * [ThreeDSAuthentication.AuthenticationResult] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun authenticationResult( + authenticationResult: JsonField + ) = apply { this.authenticationResult = authenticationResult } + + /** + * Indicates whether the expiration date provided by the cardholder during checkout matches + * Lithic's record of the card's expiration date. + */ + fun cardExpiryCheck(cardExpiryCheck: ThreeDSAuthentication.CardExpiryCheck) = + cardExpiryCheck(JsonField.of(cardExpiryCheck)) + + /** + * Sets [Builder.cardExpiryCheck] to an arbitrary JSON value. + * + * You should usually call [Builder.cardExpiryCheck] with a well-typed + * [ThreeDSAuthentication.CardExpiryCheck] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun cardExpiryCheck(cardExpiryCheck: JsonField) = + apply { + this.cardExpiryCheck = cardExpiryCheck + } + + /** + * Globally unique identifier for the card on which the 3DS authentication has occurred. + * Permitted values: 36-digit version 4 UUID (including hyphens). + */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Object containing data about the cardholder provided during the transaction. */ + fun cardholder(cardholder: ThreeDSAuthentication.Cardholder) = + cardholder(JsonField.of(cardholder)) + + /** + * Sets [Builder.cardholder] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholder] with a well-typed + * [ThreeDSAuthentication.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 + } + + /** Channel in which the authentication occurs. Maps to EMV 3DS field `deviceChannel`. */ + fun channel(channel: ThreeDSAuthentication.Channel) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed + * [ThreeDSAuthentication.Channel] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun channel(channel: JsonField) = apply { + this.channel = channel + } + + /** + * Date and time when the authentication was created in Lithic's system. Permitted values: + * Date string in the ISO 8601 format yyyy-MM-dd'T'hh:mm:ssZ. + */ + 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 } + + /** Object containing data about the merchant involved in the e-commerce transaction. */ + fun merchant(merchant: ThreeDSAuthentication.Merchant) = merchant(JsonField.of(merchant)) + + /** + * Sets [Builder.merchant] to an arbitrary JSON value. + * + * You should usually call [Builder.merchant] with a well-typed + * [ThreeDSAuthentication.Merchant] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun merchant(merchant: JsonField) = apply { + this.merchant = merchant + } + + /** + * Either PAYMENT_AUTHENTICATION or NON_PAYMENT_AUTHENTICATION. For + * NON_PAYMENT_AUTHENTICATION, additional_data and transaction fields are not populated. + */ + fun messageCategory(messageCategory: ThreeDSAuthentication.MessageCategory) = + messageCategory(JsonField.of(messageCategory)) + + /** + * Sets [Builder.messageCategory] to an arbitrary JSON value. + * + * You should usually call [Builder.messageCategory] with a well-typed + * [ThreeDSAuthentication.MessageCategory] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun messageCategory(messageCategory: JsonField) = + apply { + this.messageCategory = messageCategory + } + + /** + * Indicates whether a challenge is requested for this transaction + * * `NO_PREFERENCE` - No Preference + * * `NO_CHALLENGE_REQUESTED` - No Challenge Requested + * * `CHALLENGE_PREFERENCE` - Challenge requested (3DS Requestor preference) + * * `CHALLENGE_MANDATE` - Challenge requested (Mandate) + * * `NO_CHALLENGE_RISK_ALREADY_ASSESSED` - No Challenge requested (Transactional risk + * analysis is already performed) + * * `DATA_SHARE_ONLY` - No Challenge requested (Data Share Only) + * * `OTHER` - Other indicators not captured by above. These are rarely used + */ + fun threeDSRequestorChallengeIndicator( + threeDSRequestorChallengeIndicator: + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator + ) = threeDSRequestorChallengeIndicator(JsonField.of(threeDSRequestorChallengeIndicator)) + + /** + * Sets [Builder.threeDSRequestorChallengeIndicator] to an arbitrary JSON value. + * + * You should usually call [Builder.threeDSRequestorChallengeIndicator] with a well-typed + * [ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun threeDSRequestorChallengeIndicator( + threeDSRequestorChallengeIndicator: + JsonField + ) = apply { this.threeDSRequestorChallengeIndicator = threeDSRequestorChallengeIndicator } + + /** + * Object containing additional data about the 3DS request that is beyond the EMV 3DS + * standard spec (e.g., specific fields that only certain card networks send but are not + * required across all 3DS requests). + */ + fun additionalData(additionalData: ThreeDSAuthentication.AdditionalData?) = + additionalData(JsonField.ofNullable(additionalData)) + + /** Alias for calling [Builder.additionalData] with `additionalData.orElse(null)`. */ + fun additionalData(additionalData: Optional) = + additionalData(additionalData.getOrNull()) + + /** + * Sets [Builder.additionalData] to an arbitrary JSON value. + * + * You should usually call [Builder.additionalData] with a well-typed + * [ThreeDSAuthentication.AdditionalData] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun additionalData(additionalData: JsonField) = + apply { + this.additionalData = additionalData + } + + /** + * Object containing data about the app used in the e-commerce transaction. Present if the + * channel is 'APP_BASED'. + */ + fun app(app: ThreeDSAuthentication.App?) = app(JsonField.ofNullable(app)) + + /** Alias for calling [Builder.app] with `app.orElse(null)`. */ + fun app(app: Optional) = app(app.getOrNull()) + + /** + * Sets [Builder.app] to an arbitrary JSON value. + * + * You should usually call [Builder.app] with a well-typed [ThreeDSAuthentication.App] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun app(app: JsonField) = apply { this.app = app } + + /** + * Type of authentication request - i.e., the type of transaction or interaction is causing + * the merchant to request an authentication. Maps to EMV 3DS field + * `threeDSRequestorAuthenticationInd`. + */ + fun authenticationRequestType( + authenticationRequestType: ThreeDSAuthentication.AuthenticationRequestType? + ) = authenticationRequestType(JsonField.ofNullable(authenticationRequestType)) + + /** + * Alias for calling [Builder.authenticationRequestType] with + * `authenticationRequestType.orElse(null)`. + */ + fun authenticationRequestType( + authenticationRequestType: Optional + ) = authenticationRequestType(authenticationRequestType.getOrNull()) + + /** + * Sets [Builder.authenticationRequestType] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationRequestType] with a well-typed + * [ThreeDSAuthentication.AuthenticationRequestType] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun authenticationRequestType( + authenticationRequestType: JsonField + ) = apply { this.authenticationRequestType = authenticationRequestType } + + /** + * Object containing data about the browser used in the e-commerce transaction. Present if + * the channel is 'BROWSER'. + */ + fun browser(browser: ThreeDSAuthentication.Browser?) = + browser(JsonField.ofNullable(browser)) + + /** Alias for calling [Builder.browser] with `browser.orElse(null)`. */ + fun browser(browser: Optional) = browser(browser.getOrNull()) + + /** + * Sets [Builder.browser] to an arbitrary JSON value. + * + * You should usually call [Builder.browser] with a well-typed + * [ThreeDSAuthentication.Browser] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun browser(browser: JsonField) = apply { + this.browser = browser + } + + /** + * Metadata about the challenge method and delivery. Only present when a challenge is + * triggered. + */ + fun challengeMetadata(challengeMetadata: ThreeDSAuthentication.ChallengeMetadata?) = + challengeMetadata(JsonField.ofNullable(challengeMetadata)) + + /** Alias for calling [Builder.challengeMetadata] with `challengeMetadata.orElse(null)`. */ + fun challengeMetadata( + challengeMetadata: Optional + ) = challengeMetadata(challengeMetadata.getOrNull()) + + /** + * Sets [Builder.challengeMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.challengeMetadata] with a well-typed + * [ThreeDSAuthentication.ChallengeMetadata] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun challengeMetadata( + challengeMetadata: JsonField + ) = apply { this.challengeMetadata = challengeMetadata } + + /** + * Entity that orchestrates the challenge. This won't be set for authentications for which a + * decision has not yet been made (e.g. in-flight customer decisioning request). + */ + fun challengeOrchestratedBy( + challengeOrchestratedBy: ThreeDSAuthentication.ChallengeOrchestratedBy? + ) = challengeOrchestratedBy(JsonField.ofNullable(challengeOrchestratedBy)) + + /** + * Alias for calling [Builder.challengeOrchestratedBy] with + * `challengeOrchestratedBy.orElse(null)`. + */ + fun challengeOrchestratedBy( + challengeOrchestratedBy: Optional + ) = challengeOrchestratedBy(challengeOrchestratedBy.getOrNull()) + + /** + * Sets [Builder.challengeOrchestratedBy] to an arbitrary JSON value. + * + * You should usually call [Builder.challengeOrchestratedBy] with a well-typed + * [ThreeDSAuthentication.ChallengeOrchestratedBy] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun challengeOrchestratedBy( + challengeOrchestratedBy: JsonField + ) = apply { this.challengeOrchestratedBy = challengeOrchestratedBy } + + /** + * Entity that made the authentication decision. This won't be set for authentications for + * which a decision has not yet been made (e.g. in-flight customer decisioning request). + */ + fun decisionMadeBy(decisionMadeBy: ThreeDSAuthentication.DecisionMadeBy?) = + decisionMadeBy(JsonField.ofNullable(decisionMadeBy)) + + /** Alias for calling [Builder.decisionMadeBy] with `decisionMadeBy.orElse(null)`. */ + fun decisionMadeBy(decisionMadeBy: Optional) = + decisionMadeBy(decisionMadeBy.getOrNull()) + + /** + * Sets [Builder.decisionMadeBy] to an arbitrary JSON value. + * + * You should usually call [Builder.decisionMadeBy] with a well-typed + * [ThreeDSAuthentication.DecisionMadeBy] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun decisionMadeBy(decisionMadeBy: JsonField) = + apply { + this.decisionMadeBy = decisionMadeBy + } + + /** + * Type of 3DS Requestor Initiated (3RI) request — i.e., a 3DS authentication that takes + * place at the initiation of the merchant rather than the cardholder. The most common + * example of this is where a merchant is authenticating before billing for a recurring + * transaction such as a pay TV subscription or a utility bill. Maps to EMV 3DS field + * `threeRIInd`. + */ + fun threeRiRequestType(threeRiRequestType: ThreeDSAuthentication.ThreeRiRequestType?) = + threeRiRequestType(JsonField.ofNullable(threeRiRequestType)) + + /** + * Alias for calling [Builder.threeRiRequestType] with `threeRiRequestType.orElse(null)`. + */ + fun threeRiRequestType( + threeRiRequestType: Optional + ) = threeRiRequestType(threeRiRequestType.getOrNull()) + + /** + * Sets [Builder.threeRiRequestType] to an arbitrary JSON value. + * + * You should usually call [Builder.threeRiRequestType] with a well-typed + * [ThreeDSAuthentication.ThreeRiRequestType] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun threeRiRequestType( + threeRiRequestType: JsonField + ) = apply { this.threeRiRequestType = threeRiRequestType } + + /** + * Object containing data about the e-commerce transaction for which the merchant is + * requesting authentication. + */ + fun transaction(transaction: ThreeDSAuthentication.Transaction?) = + transaction(JsonField.ofNullable(transaction)) + + /** Alias for calling [Builder.transaction] with `transaction.orElse(null)`. */ + fun transaction(transaction: Optional) = + transaction(transaction.getOrNull()) + + /** + * Sets [Builder.transaction] to an arbitrary JSON value. + * + * You should usually call [Builder.transaction] with a well-typed + * [ThreeDSAuthentication.Transaction] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun transaction(transaction: JsonField) = apply { + this.transaction = transaction + } + + /** 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 [ThreeDSAuthenticationUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .accountType() + * .authenticationResult() + * .cardExpiryCheck() + * .cardToken() + * .cardholder() + * .channel() + * .created() + * .merchant() + * .messageCategory() + * .threeDSRequestorChallengeIndicator() + * .eventType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ThreeDSAuthenticationUpdatedWebhookEvent = + ThreeDSAuthenticationUpdatedWebhookEvent( + checkRequired("token", token), + checkRequired("accountType", accountType), + checkRequired("authenticationResult", authenticationResult), + checkRequired("cardExpiryCheck", cardExpiryCheck), + checkRequired("cardToken", cardToken), + checkRequired("cardholder", cardholder), + checkRequired("channel", channel), + checkRequired("created", created), + checkRequired("merchant", merchant), + checkRequired("messageCategory", messageCategory), + checkRequired( + "threeDSRequestorChallengeIndicator", + threeDSRequestorChallengeIndicator, + ), + additionalData, + app, + authenticationRequestType, + browser, + challengeMetadata, + challengeOrchestratedBy, + decisionMadeBy, + threeRiRequestType, + transaction, + checkRequired("eventType", eventType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ThreeDSAuthenticationUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + token() + accountType().ifPresent { it.validate() } + authenticationResult().validate() + cardExpiryCheck().validate() + cardToken() + cardholder().validate() + channel().validate() + created() + merchant().validate() + messageCategory().validate() + threeDSRequestorChallengeIndicator().validate() + additionalData().ifPresent { it.validate() } + app().ifPresent { it.validate() } + authenticationRequestType().ifPresent { it.validate() } + browser().ifPresent { it.validate() } + challengeMetadata().ifPresent { it.validate() } + challengeOrchestratedBy().ifPresent { it.validate() } + decisionMadeBy().ifPresent { it.validate() } + threeRiRequestType().ifPresent { it.validate() } + transaction().ifPresent { it.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 = + (if (token.asKnown().isPresent) 1 else 0) + + (accountType.asKnown().getOrNull()?.validity() ?: 0) + + (authenticationResult.asKnown().getOrNull()?.validity() ?: 0) + + (cardExpiryCheck.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (cardholder.asKnown().getOrNull()?.validity() ?: 0) + + (channel.asKnown().getOrNull()?.validity() ?: 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (merchant.asKnown().getOrNull()?.validity() ?: 0) + + (messageCategory.asKnown().getOrNull()?.validity() ?: 0) + + (threeDSRequestorChallengeIndicator.asKnown().getOrNull()?.validity() ?: 0) + + (additionalData.asKnown().getOrNull()?.validity() ?: 0) + + (app.asKnown().getOrNull()?.validity() ?: 0) + + (authenticationRequestType.asKnown().getOrNull()?.validity() ?: 0) + + (browser.asKnown().getOrNull()?.validity() ?: 0) + + (challengeMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (challengeOrchestratedBy.asKnown().getOrNull()?.validity() ?: 0) + + (decisionMadeBy.asKnown().getOrNull()?.validity() ?: 0) + + (threeRiRequestType.asKnown().getOrNull()?.validity() ?: 0) + + (transaction.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 THREE_DS_AUTHENTICATION_UPDATED = of("three_ds_authentication.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + THREE_DS_AUTHENTICATION_UPDATED + } + + /** + * 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 { + THREE_DS_AUTHENTICATION_UPDATED, + /** + * 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) { + THREE_DS_AUTHENTICATION_UPDATED -> Value.THREE_DS_AUTHENTICATION_UPDATED + 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) { + THREE_DS_AUTHENTICATION_UPDATED -> Known.THREE_DS_AUTHENTICATION_UPDATED + 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 + + 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 ThreeDSAuthenticationUpdatedWebhookEvent && + token == other.token && + accountType == other.accountType && + authenticationResult == other.authenticationResult && + cardExpiryCheck == other.cardExpiryCheck && + cardToken == other.cardToken && + cardholder == other.cardholder && + channel == other.channel && + created == other.created && + merchant == other.merchant && + messageCategory == other.messageCategory && + threeDSRequestorChallengeIndicator == other.threeDSRequestorChallengeIndicator && + additionalData == other.additionalData && + app == other.app && + authenticationRequestType == other.authenticationRequestType && + browser == other.browser && + challengeMetadata == other.challengeMetadata && + challengeOrchestratedBy == other.challengeOrchestratedBy && + decisionMadeBy == other.decisionMadeBy && + threeRiRequestType == other.threeRiRequestType && + transaction == other.transaction && + eventType == other.eventType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + accountType, + authenticationResult, + cardExpiryCheck, + cardToken, + cardholder, + channel, + created, + merchant, + messageCategory, + threeDSRequestorChallengeIndicator, + additionalData, + app, + authenticationRequestType, + browser, + challengeMetadata, + challengeOrchestratedBy, + decisionMadeBy, + threeRiRequestType, + transaction, + eventType, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ThreeDSAuthenticationUpdatedWebhookEvent{token=$token, accountType=$accountType, authenticationResult=$authenticationResult, cardExpiryCheck=$cardExpiryCheck, cardToken=$cardToken, cardholder=$cardholder, channel=$channel, created=$created, merchant=$merchant, messageCategory=$messageCategory, threeDSRequestorChallengeIndicator=$threeDSRequestorChallengeIndicator, additionalData=$additionalData, app=$app, authenticationRequestType=$authenticationRequestType, browser=$browser, challengeMetadata=$challengeMetadata, challengeOrchestratedBy=$challengeOrchestratedBy, decisionMadeBy=$decisionMadeBy, threeRiRequestType=$threeRiRequestType, transaction=$transaction, eventType=$eventType, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationApprovalRequestWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationApprovalRequestWebhookEvent.kt new file mode 100644 index 000000000..317468a35 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationApprovalRequestWebhookEvent.kt @@ -0,0 +1,1876 @@ +// 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 + +class TokenizationApprovalRequestWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val customerTokenizationDecision: JsonField, + private val eventType: JsonField, + private val issuerDecision: JsonField, + private val tokenizationChannel: JsonField, + private val tokenizationToken: JsonField, + private val walletDecisioningInfo: JsonField, + private val device: JsonField, + private val digitalWalletTokenMetadata: JsonField, + private val ruleResults: JsonField>, + private val tokenizationDeclineReasons: JsonField>, + private val tokenizationSource: JsonField, + private val tokenizationTfaReasons: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("customer_tokenization_decision") + @ExcludeMissing + customerTokenizationDecision: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("issuer_decision") + @ExcludeMissing + issuerDecision: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_channel") + @ExcludeMissing + tokenizationChannel: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + @JsonProperty("wallet_decisioning_info") + @ExcludeMissing + walletDecisioningInfo: JsonField = JsonMissing.of(), + @JsonProperty("device") @ExcludeMissing device: JsonField = JsonMissing.of(), + @JsonProperty("digital_wallet_token_metadata") + @ExcludeMissing + digitalWalletTokenMetadata: JsonField = JsonMissing.of(), + @JsonProperty("rule_results") + @ExcludeMissing + ruleResults: JsonField> = JsonMissing.of(), + @JsonProperty("tokenization_decline_reasons") + @ExcludeMissing + tokenizationDeclineReasons: JsonField> = JsonMissing.of(), + @JsonProperty("tokenization_source") + @ExcludeMissing + tokenizationSource: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_tfa_reasons") + @ExcludeMissing + tokenizationTfaReasons: JsonField> = JsonMissing.of(), + ) : this( + accountToken, + cardToken, + created, + customerTokenizationDecision, + eventType, + issuerDecision, + tokenizationChannel, + tokenizationToken, + walletDecisioningInfo, + device, + digitalWalletTokenMetadata, + ruleResults, + tokenizationDeclineReasons, + tokenizationSource, + tokenizationTfaReasons, + mutableMapOf(), + ) + + /** + * Unique identifier for the user tokenizing a 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * Unique identifier for the card being tokenized + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Indicate when the request was received from Mastercard or Visa + * + * @throws LithicInvalidDataException if 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") + + /** + * Contains the metadata for the customer tokenization decision. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerTokenizationDecision(): Optional = + customerTokenizationDecision.getOptional("customer_tokenization_decision") + + /** + * The name of this event + * + * @throws LithicInvalidDataException if 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") + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun issuerDecision(): IssuerDecision = issuerDecision.getRequired("issuer_decision") + + /** + * The channel through which the tokenization was made. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationChannel(): TokenizationChannel = + tokenizationChannel.getRequired("tokenization_channel") + + /** + * Unique identifier for the digital wallet token attempt + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun walletDecisioningInfo(): WalletDecisioningInfo = + walletDecisioningInfo.getRequired("wallet_decisioning_info") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun device(): Optional = device.getOptional("device") + + /** + * Contains the metadata for the digital wallet being tokenized. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun digitalWalletTokenMetadata(): Optional = + digitalWalletTokenMetadata.getOptional("digital_wallet_token_metadata") + + /** + * Results from rules that were evaluated for this tokenization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ruleResults(): Optional> = + ruleResults.getOptional("rule_results") + + /** + * List of reasons why the tokenization was declined + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationDeclineReasons(): Optional> = + tokenizationDeclineReasons.getOptional("tokenization_decline_reasons") + + /** + * The source of the tokenization. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationSource(): Optional = + tokenizationSource.getOptional("tokenization_source") + + /** + * List of reasons why two-factor authentication was required + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationTfaReasons(): Optional> = + tokenizationTfaReasons.getOptional("tokenization_tfa_reasons") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [customerTokenizationDecision]. + * + * Unlike [customerTokenizationDecision], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customer_tokenization_decision") + @ExcludeMissing + fun _customerTokenizationDecision(): JsonField = + customerTokenizationDecision + + /** + * 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 [issuerDecision]. + * + * Unlike [issuerDecision], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issuer_decision") + @ExcludeMissing + fun _issuerDecision(): JsonField = issuerDecision + + /** + * Returns the raw JSON value of [tokenizationChannel]. + * + * Unlike [tokenizationChannel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_channel") + @ExcludeMissing + fun _tokenizationChannel(): JsonField = tokenizationChannel + + /** + * Returns the raw JSON value of [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + /** + * Returns the raw JSON value of [walletDecisioningInfo]. + * + * Unlike [walletDecisioningInfo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wallet_decisioning_info") + @ExcludeMissing + fun _walletDecisioningInfo(): JsonField = walletDecisioningInfo + + /** + * Returns the raw JSON value of [device]. + * + * Unlike [device], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device") @ExcludeMissing fun _device(): JsonField = device + + /** + * Returns the raw JSON value of [digitalWalletTokenMetadata]. + * + * Unlike [digitalWalletTokenMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("digital_wallet_token_metadata") + @ExcludeMissing + fun _digitalWalletTokenMetadata(): JsonField = + digitalWalletTokenMetadata + + /** + * Returns the raw JSON value of [ruleResults]. + * + * Unlike [ruleResults], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_results") + @ExcludeMissing + fun _ruleResults(): JsonField> = ruleResults + + /** + * Returns the raw JSON value of [tokenizationDeclineReasons]. + * + * Unlike [tokenizationDeclineReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_decline_reasons") + @ExcludeMissing + fun _tokenizationDeclineReasons(): JsonField> = + tokenizationDeclineReasons + + /** + * Returns the raw JSON value of [tokenizationSource]. + * + * Unlike [tokenizationSource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_source") + @ExcludeMissing + fun _tokenizationSource(): JsonField = tokenizationSource + + /** + * Returns the raw JSON value of [tokenizationTfaReasons]. + * + * Unlike [tokenizationTfaReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_tfa_reasons") + @ExcludeMissing + fun _tokenizationTfaReasons(): JsonField> = tokenizationTfaReasons + + @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 + * [TokenizationApprovalRequestWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .customerTokenizationDecision() + * .eventType() + * .issuerDecision() + * .tokenizationChannel() + * .tokenizationToken() + * .walletDecisioningInfo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationApprovalRequestWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var customerTokenizationDecision: JsonField? = null + private var eventType: JsonField? = null + private var issuerDecision: JsonField? = null + private var tokenizationChannel: JsonField? = null + private var tokenizationToken: JsonField? = null + private var walletDecisioningInfo: JsonField? = null + private var device: JsonField = JsonMissing.of() + private var digitalWalletTokenMetadata: JsonField = + JsonMissing.of() + private var ruleResults: JsonField>? = null + private var tokenizationDeclineReasons: JsonField>? = + null + private var tokenizationSource: JsonField = JsonMissing.of() + private var tokenizationTfaReasons: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + tokenizationApprovalRequestWebhookEvent: TokenizationApprovalRequestWebhookEvent + ) = apply { + accountToken = tokenizationApprovalRequestWebhookEvent.accountToken + cardToken = tokenizationApprovalRequestWebhookEvent.cardToken + created = tokenizationApprovalRequestWebhookEvent.created + customerTokenizationDecision = + tokenizationApprovalRequestWebhookEvent.customerTokenizationDecision + eventType = tokenizationApprovalRequestWebhookEvent.eventType + issuerDecision = tokenizationApprovalRequestWebhookEvent.issuerDecision + tokenizationChannel = tokenizationApprovalRequestWebhookEvent.tokenizationChannel + tokenizationToken = tokenizationApprovalRequestWebhookEvent.tokenizationToken + walletDecisioningInfo = tokenizationApprovalRequestWebhookEvent.walletDecisioningInfo + device = tokenizationApprovalRequestWebhookEvent.device + digitalWalletTokenMetadata = + tokenizationApprovalRequestWebhookEvent.digitalWalletTokenMetadata + ruleResults = + tokenizationApprovalRequestWebhookEvent.ruleResults.map { it.toMutableList() } + tokenizationDeclineReasons = + tokenizationApprovalRequestWebhookEvent.tokenizationDeclineReasons.map { + it.toMutableList() + } + tokenizationSource = tokenizationApprovalRequestWebhookEvent.tokenizationSource + tokenizationTfaReasons = + tokenizationApprovalRequestWebhookEvent.tokenizationTfaReasons.map { + it.toMutableList() + } + additionalProperties = + tokenizationApprovalRequestWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the user tokenizing a card */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Unique identifier for the card being tokenized */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Indicate when the request was received from Mastercard or Visa */ + 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 } + + /** Contains the metadata for the customer tokenization decision. */ + fun customerTokenizationDecision( + customerTokenizationDecision: CustomerTokenizationDecision? + ) = customerTokenizationDecision(JsonField.ofNullable(customerTokenizationDecision)) + + /** + * Alias for calling [Builder.customerTokenizationDecision] with + * `customerTokenizationDecision.orElse(null)`. + */ + fun customerTokenizationDecision( + customerTokenizationDecision: Optional + ) = customerTokenizationDecision(customerTokenizationDecision.getOrNull()) + + /** + * Sets [Builder.customerTokenizationDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.customerTokenizationDecision] with a well-typed + * [CustomerTokenizationDecision] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customerTokenizationDecision( + customerTokenizationDecision: JsonField + ) = apply { this.customerTokenizationDecision = customerTokenizationDecision } + + /** The name of this event */ + 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 } + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + */ + fun issuerDecision(issuerDecision: IssuerDecision) = + issuerDecision(JsonField.of(issuerDecision)) + + /** + * Sets [Builder.issuerDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerDecision] with a well-typed [IssuerDecision] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuerDecision(issuerDecision: JsonField) = apply { + this.issuerDecision = issuerDecision + } + + /** The channel through which the tokenization was made. */ + fun tokenizationChannel(tokenizationChannel: TokenizationChannel) = + tokenizationChannel(JsonField.of(tokenizationChannel)) + + /** + * Sets [Builder.tokenizationChannel] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationChannel] with a well-typed + * [TokenizationChannel] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenizationChannel(tokenizationChannel: JsonField) = apply { + this.tokenizationChannel = tokenizationChannel + } + + /** Unique identifier for the digital wallet token attempt */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + fun walletDecisioningInfo(walletDecisioningInfo: WalletDecisioningInfo) = + walletDecisioningInfo(JsonField.of(walletDecisioningInfo)) + + /** + * Sets [Builder.walletDecisioningInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.walletDecisioningInfo] with a well-typed + * [WalletDecisioningInfo] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun walletDecisioningInfo(walletDecisioningInfo: JsonField) = apply { + this.walletDecisioningInfo = walletDecisioningInfo + } + + fun device(device: Device) = device(JsonField.of(device)) + + /** + * Sets [Builder.device] to an arbitrary JSON value. + * + * You should usually call [Builder.device] with a well-typed [Device] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun device(device: JsonField) = apply { this.device = device } + + /** Contains the metadata for the digital wallet being tokenized. */ + fun digitalWalletTokenMetadata(digitalWalletTokenMetadata: DigitalWalletTokenMetadata) = + digitalWalletTokenMetadata(JsonField.of(digitalWalletTokenMetadata)) + + /** + * Sets [Builder.digitalWalletTokenMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.digitalWalletTokenMetadata] with a well-typed + * [DigitalWalletTokenMetadata] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun digitalWalletTokenMetadata( + digitalWalletTokenMetadata: JsonField + ) = apply { this.digitalWalletTokenMetadata = digitalWalletTokenMetadata } + + /** Results from rules that were evaluated for this tokenization */ + fun ruleResults(ruleResults: List) = + ruleResults(JsonField.of(ruleResults)) + + /** + * Sets [Builder.ruleResults] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleResults] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun ruleResults(ruleResults: JsonField>) = apply { + this.ruleResults = ruleResults.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationRuleResult] to [ruleResults]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRuleResult(ruleResult: TokenizationRuleResult) = apply { + ruleResults = + (ruleResults ?: JsonField.of(mutableListOf())).also { + checkKnown("ruleResults", it).add(ruleResult) + } + } + + /** List of reasons why the tokenization was declined */ + fun tokenizationDeclineReasons( + tokenizationDeclineReasons: List + ) = tokenizationDeclineReasons(JsonField.of(tokenizationDeclineReasons)) + + /** + * Sets [Builder.tokenizationDeclineReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationDeclineReasons] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tokenizationDeclineReasons( + tokenizationDeclineReasons: JsonField> + ) = apply { + this.tokenizationDeclineReasons = tokenizationDeclineReasons.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationDeclineReason] to [tokenizationDeclineReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTokenizationDeclineReason(tokenizationDeclineReason: TokenizationDeclineReason) = + apply { + tokenizationDeclineReasons = + (tokenizationDeclineReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("tokenizationDeclineReasons", it).add(tokenizationDeclineReason) + } + } + + /** The source of the tokenization. */ + fun tokenizationSource(tokenizationSource: TokenizationSource) = + tokenizationSource(JsonField.of(tokenizationSource)) + + /** + * Sets [Builder.tokenizationSource] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationSource] with a well-typed + * [TokenizationSource] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenizationSource(tokenizationSource: JsonField) = apply { + this.tokenizationSource = tokenizationSource + } + + /** List of reasons why two-factor authentication was required */ + fun tokenizationTfaReasons(tokenizationTfaReasons: List) = + tokenizationTfaReasons(JsonField.of(tokenizationTfaReasons)) + + /** + * Sets [Builder.tokenizationTfaReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationTfaReasons] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tokenizationTfaReasons(tokenizationTfaReasons: JsonField>) = + apply { + this.tokenizationTfaReasons = tokenizationTfaReasons.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationTfaReason] to [tokenizationTfaReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTokenizationTfaReason(tokenizationTfaReason: TokenizationTfaReason) = apply { + tokenizationTfaReasons = + (tokenizationTfaReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("tokenizationTfaReasons", it).add(tokenizationTfaReason) + } + } + + 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 [TokenizationApprovalRequestWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .customerTokenizationDecision() + * .eventType() + * .issuerDecision() + * .tokenizationChannel() + * .tokenizationToken() + * .walletDecisioningInfo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationApprovalRequestWebhookEvent = + TokenizationApprovalRequestWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("customerTokenizationDecision", customerTokenizationDecision), + checkRequired("eventType", eventType), + checkRequired("issuerDecision", issuerDecision), + checkRequired("tokenizationChannel", tokenizationChannel), + checkRequired("tokenizationToken", tokenizationToken), + checkRequired("walletDecisioningInfo", walletDecisioningInfo), + device, + digitalWalletTokenMetadata, + (ruleResults ?: JsonMissing.of()).map { it.toImmutable() }, + (tokenizationDeclineReasons ?: JsonMissing.of()).map { it.toImmutable() }, + tokenizationSource, + (tokenizationTfaReasons ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationApprovalRequestWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + cardToken() + created() + customerTokenizationDecision().ifPresent { it.validate() } + eventType().validate() + issuerDecision().validate() + tokenizationChannel().validate() + tokenizationToken() + walletDecisioningInfo().validate() + device().ifPresent { it.validate() } + digitalWalletTokenMetadata().ifPresent { it.validate() } + ruleResults().ifPresent { it.forEach { it.validate() } } + tokenizationDeclineReasons().ifPresent { it.forEach { it.validate() } } + tokenizationSource().ifPresent { it.validate() } + tokenizationTfaReasons().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (customerTokenizationDecision.asKnown().getOrNull()?.validity() ?: 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (issuerDecision.asKnown().getOrNull()?.validity() ?: 0) + + (tokenizationChannel.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + (walletDecisioningInfo.asKnown().getOrNull()?.validity() ?: 0) + + (device.asKnown().getOrNull()?.validity() ?: 0) + + (digitalWalletTokenMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (ruleResults.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (tokenizationDeclineReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (tokenizationSource.asKnown().getOrNull()?.validity() ?: 0) + + (tokenizationTfaReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** Contains the metadata for the customer tokenization decision. */ + class CustomerTokenizationDecision + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val outcome: JsonField, + private val responderUrl: JsonField, + private val latency: JsonField, + private val responseCode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("outcome") @ExcludeMissing outcome: JsonField = JsonMissing.of(), + @JsonProperty("responder_url") + @ExcludeMissing + responderUrl: JsonField = JsonMissing.of(), + @JsonProperty("latency") @ExcludeMissing latency: JsonField = JsonMissing.of(), + @JsonProperty("response_code") + @ExcludeMissing + responseCode: JsonField = JsonMissing.of(), + ) : this(outcome, responderUrl, latency, responseCode, mutableMapOf()) + + /** + * The outcome of the customer's decision + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun outcome(): Outcome = outcome.getRequired("outcome") + + /** + * The customer's subscribed URL + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun responderUrl(): String = responderUrl.getRequired("responder_url") + + /** + * Time in ms it took for the customer's URL to respond + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun latency(): Optional = latency.getOptional("latency") + + /** + * The response code that the customer provided + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun responseCode(): Optional = responseCode.getOptional("response_code") + + /** + * Returns the raw JSON value of [outcome]. + * + * Unlike [outcome], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("outcome") @ExcludeMissing fun _outcome(): JsonField = outcome + + /** + * Returns the raw JSON value of [responderUrl]. + * + * Unlike [responderUrl], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("responder_url") + @ExcludeMissing + fun _responderUrl(): JsonField = responderUrl + + /** + * Returns the raw JSON value of [latency]. + * + * Unlike [latency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("latency") @ExcludeMissing fun _latency(): JsonField = latency + + /** + * Returns the raw JSON value of [responseCode]. + * + * Unlike [responseCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("response_code") + @ExcludeMissing + fun _responseCode(): JsonField = responseCode + + @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 + * [CustomerTokenizationDecision]. + * + * The following fields are required: + * ```java + * .outcome() + * .responderUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CustomerTokenizationDecision]. */ + class Builder internal constructor() { + + private var outcome: JsonField? = null + private var responderUrl: JsonField? = null + private var latency: JsonField = JsonMissing.of() + private var responseCode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(customerTokenizationDecision: CustomerTokenizationDecision) = apply { + outcome = customerTokenizationDecision.outcome + responderUrl = customerTokenizationDecision.responderUrl + latency = customerTokenizationDecision.latency + responseCode = customerTokenizationDecision.responseCode + additionalProperties = + customerTokenizationDecision.additionalProperties.toMutableMap() + } + + /** The outcome of the customer's decision */ + fun outcome(outcome: Outcome) = outcome(JsonField.of(outcome)) + + /** + * Sets [Builder.outcome] to an arbitrary JSON value. + * + * You should usually call [Builder.outcome] with a well-typed [Outcome] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun outcome(outcome: JsonField) = apply { this.outcome = outcome } + + /** The customer's subscribed URL */ + fun responderUrl(responderUrl: String) = responderUrl(JsonField.of(responderUrl)) + + /** + * Sets [Builder.responderUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.responderUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun responderUrl(responderUrl: JsonField) = apply { + this.responderUrl = responderUrl + } + + /** Time in ms it took for the customer's URL to respond */ + fun latency(latency: String) = latency(JsonField.of(latency)) + + /** + * Sets [Builder.latency] to an arbitrary JSON value. + * + * You should usually call [Builder.latency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun latency(latency: JsonField) = apply { this.latency = latency } + + /** The response code that the customer provided */ + fun responseCode(responseCode: String) = responseCode(JsonField.of(responseCode)) + + /** + * Sets [Builder.responseCode] to an arbitrary JSON value. + * + * You should usually call [Builder.responseCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun responseCode(responseCode: JsonField) = apply { + this.responseCode = responseCode + } + + 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 [CustomerTokenizationDecision]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .outcome() + * .responderUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CustomerTokenizationDecision = + CustomerTokenizationDecision( + checkRequired("outcome", outcome), + checkRequired("responderUrl", responderUrl), + latency, + responseCode, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CustomerTokenizationDecision = apply { + if (validated) { + return@apply + } + + outcome().validate() + responderUrl() + latency() + responseCode() + 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 = + (outcome.asKnown().getOrNull()?.validity() ?: 0) + + (if (responderUrl.asKnown().isPresent) 1 else 0) + + (if (latency.asKnown().isPresent) 1 else 0) + + (if (responseCode.asKnown().isPresent) 1 else 0) + + /** The outcome of the customer's decision */ + class Outcome @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPROVED = of("APPROVED") + + @JvmField val DECLINED = of("DECLINED") + + @JvmField val ERROR = of("ERROR") + + @JvmField val INVALID_RESPONSE = of("INVALID_RESPONSE") + + @JvmField + val REQUIRE_ADDITIONAL_AUTHENTICATION = of("REQUIRE_ADDITIONAL_AUTHENTICATION") + + @JvmField val TIMEOUT = of("TIMEOUT") + + @JvmStatic fun of(value: String) = Outcome(JsonField.of(value)) + } + + /** An enum containing [Outcome]'s known values. */ + enum class Known { + APPROVED, + DECLINED, + ERROR, + INVALID_RESPONSE, + REQUIRE_ADDITIONAL_AUTHENTICATION, + TIMEOUT, + } + + /** + * An enum containing [Outcome]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Outcome] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPROVED, + DECLINED, + ERROR, + INVALID_RESPONSE, + REQUIRE_ADDITIONAL_AUTHENTICATION, + TIMEOUT, + /** + * An enum member indicating that [Outcome] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DECLINED -> Value.DECLINED + ERROR -> Value.ERROR + INVALID_RESPONSE -> Value.INVALID_RESPONSE + REQUIRE_ADDITIONAL_AUTHENTICATION -> Value.REQUIRE_ADDITIONAL_AUTHENTICATION + TIMEOUT -> Value.TIMEOUT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DECLINED -> Known.DECLINED + ERROR -> Known.ERROR + INVALID_RESPONSE -> Known.INVALID_RESPONSE + REQUIRE_ADDITIONAL_AUTHENTICATION -> Known.REQUIRE_ADDITIONAL_AUTHENTICATION + TIMEOUT -> Known.TIMEOUT + else -> throw LithicInvalidDataException("Unknown Outcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Outcome = 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 Outcome && 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 CustomerTokenizationDecision && + outcome == other.outcome && + responderUrl == other.responderUrl && + latency == other.latency && + responseCode == other.responseCode && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(outcome, responderUrl, latency, responseCode, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CustomerTokenizationDecision{outcome=$outcome, responderUrl=$responderUrl, latency=$latency, responseCode=$responseCode, additionalProperties=$additionalProperties}" + } + + /** The name of this event */ + 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 TOKENIZATION_APPROVAL_REQUEST = of("tokenization.approval_request") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + TOKENIZATION_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 { + TOKENIZATION_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) { + TOKENIZATION_APPROVAL_REQUEST -> Value.TOKENIZATION_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) { + TOKENIZATION_APPROVAL_REQUEST -> Known.TOKENIZATION_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 + + 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() + } + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + */ + class IssuerDecision @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPROVED = of("APPROVED") + + @JvmField val DENIED = of("DENIED") + + @JvmField val VERIFICATION_REQUIRED = of("VERIFICATION_REQUIRED") + + @JvmStatic fun of(value: String) = IssuerDecision(JsonField.of(value)) + } + + /** An enum containing [IssuerDecision]'s known values. */ + enum class Known { + APPROVED, + DENIED, + VERIFICATION_REQUIRED, + } + + /** + * An enum containing [IssuerDecision]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IssuerDecision] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPROVED, + DENIED, + VERIFICATION_REQUIRED, + /** + * An enum member indicating that [IssuerDecision] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DENIED -> Value.DENIED + VERIFICATION_REQUIRED -> Value.VERIFICATION_REQUIRED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DENIED -> Known.DENIED + VERIFICATION_REQUIRED -> Known.VERIFICATION_REQUIRED + else -> throw LithicInvalidDataException("Unknown IssuerDecision: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): IssuerDecision = 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 IssuerDecision && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The channel through which the tokenization was made. */ + class TokenizationChannel + @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 DIGITAL_WALLET = of("DIGITAL_WALLET") + + @JvmField val MERCHANT = of("MERCHANT") + + @JvmStatic fun of(value: String) = TokenizationChannel(JsonField.of(value)) + } + + /** An enum containing [TokenizationChannel]'s known values. */ + enum class Known { + DIGITAL_WALLET, + MERCHANT, + } + + /** + * An enum containing [TokenizationChannel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TokenizationChannel] 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 { + DIGITAL_WALLET, + MERCHANT, + /** + * An enum member indicating that [TokenizationChannel] 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) { + DIGITAL_WALLET -> Value.DIGITAL_WALLET + MERCHANT -> Value.MERCHANT + 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) { + DIGITAL_WALLET -> Known.DIGITAL_WALLET + MERCHANT -> Known.MERCHANT + else -> throw LithicInvalidDataException("Unknown TokenizationChannel: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenizationChannel = 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 TokenizationChannel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The source of the tokenization. */ + class TokenizationSource + @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 ACCOUNT_ON_FILE = of("ACCOUNT_ON_FILE") + + @JvmField val CONTACTLESS_TAP = of("CONTACTLESS_TAP") + + @JvmField val MANUAL_PROVISION = of("MANUAL_PROVISION") + + @JvmField val PUSH_PROVISION = of("PUSH_PROVISION") + + @JvmField val TOKEN = of("TOKEN") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = TokenizationSource(JsonField.of(value)) + } + + /** An enum containing [TokenizationSource]'s known values. */ + enum class Known { + ACCOUNT_ON_FILE, + CONTACTLESS_TAP, + MANUAL_PROVISION, + PUSH_PROVISION, + TOKEN, + UNKNOWN, + } + + /** + * An enum containing [TokenizationSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TokenizationSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_ON_FILE, + CONTACTLESS_TAP, + MANUAL_PROVISION, + PUSH_PROVISION, + TOKEN, + UNKNOWN, + /** + * An enum member indicating that [TokenizationSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_ON_FILE -> Value.ACCOUNT_ON_FILE + CONTACTLESS_TAP -> Value.CONTACTLESS_TAP + MANUAL_PROVISION -> Value.MANUAL_PROVISION + PUSH_PROVISION -> Value.PUSH_PROVISION + TOKEN -> Value.TOKEN + 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) { + ACCOUNT_ON_FILE -> Known.ACCOUNT_ON_FILE + CONTACTLESS_TAP -> Known.CONTACTLESS_TAP + MANUAL_PROVISION -> Known.MANUAL_PROVISION + PUSH_PROVISION -> Known.PUSH_PROVISION + TOKEN -> Known.TOKEN + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown TokenizationSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenizationSource = 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 TokenizationSource && 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 TokenizationApprovalRequestWebhookEvent && + accountToken == other.accountToken && + cardToken == other.cardToken && + created == other.created && + customerTokenizationDecision == other.customerTokenizationDecision && + eventType == other.eventType && + issuerDecision == other.issuerDecision && + tokenizationChannel == other.tokenizationChannel && + tokenizationToken == other.tokenizationToken && + walletDecisioningInfo == other.walletDecisioningInfo && + device == other.device && + digitalWalletTokenMetadata == other.digitalWalletTokenMetadata && + ruleResults == other.ruleResults && + tokenizationDeclineReasons == other.tokenizationDeclineReasons && + tokenizationSource == other.tokenizationSource && + tokenizationTfaReasons == other.tokenizationTfaReasons && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + cardToken, + created, + customerTokenizationDecision, + eventType, + issuerDecision, + tokenizationChannel, + tokenizationToken, + walletDecisioningInfo, + device, + digitalWalletTokenMetadata, + ruleResults, + tokenizationDeclineReasons, + tokenizationSource, + tokenizationTfaReasons, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationApprovalRequestWebhookEvent{accountToken=$accountToken, cardToken=$cardToken, created=$created, customerTokenizationDecision=$customerTokenizationDecision, eventType=$eventType, issuerDecision=$issuerDecision, tokenizationChannel=$tokenizationChannel, tokenizationToken=$tokenizationToken, walletDecisioningInfo=$walletDecisioningInfo, device=$device, digitalWalletTokenMetadata=$digitalWalletTokenMetadata, ruleResults=$ruleResults, tokenizationDeclineReasons=$tokenizationDeclineReasons, tokenizationSource=$tokenizationSource, tokenizationTfaReasons=$tokenizationTfaReasons, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationDecisioningRequestWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationDecisioningRequestWebhookEvent.kt new file mode 100644 index 000000000..8f4efba6f --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationDecisioningRequestWebhookEvent.kt @@ -0,0 +1,1189 @@ +// 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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A webhook for tokenization decisioning sent to the customer's responder endpoint */ +class TokenizationDecisioningRequestWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val issuerDecision: JsonField, + private val tokenizationChannel: JsonField, + private val tokenizationToken: JsonField, + private val walletDecisioningInfo: JsonField, + private val device: JsonField, + private val digitalWalletTokenMetadata: JsonField, + private val tokenizationSource: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("issuer_decision") + @ExcludeMissing + issuerDecision: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_channel") + @ExcludeMissing + tokenizationChannel: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + @JsonProperty("wallet_decisioning_info") + @ExcludeMissing + walletDecisioningInfo: JsonField = JsonMissing.of(), + @JsonProperty("device") @ExcludeMissing device: JsonField = JsonMissing.of(), + @JsonProperty("digital_wallet_token_metadata") + @ExcludeMissing + digitalWalletTokenMetadata: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_source") + @ExcludeMissing + tokenizationSource: JsonField = JsonMissing.of(), + ) : this( + accountToken, + cardToken, + created, + eventType, + issuerDecision, + tokenizationChannel, + tokenizationToken, + walletDecisioningInfo, + device, + digitalWalletTokenMetadata, + tokenizationSource, + mutableMapOf(), + ) + + /** + * Unique identifier for the user tokenizing a 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * Unique identifier for the card being tokenized + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Indicate when the request was received from Mastercard or Visa + * + * @throws LithicInvalidDataException if 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") + + /** + * The name of this event + * + * @throws LithicInvalidDataException if 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") + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun issuerDecision(): IssuerDecision = issuerDecision.getRequired("issuer_decision") + + /** + * The channel through which the tokenization was made. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationChannel(): TokenizationChannel = + tokenizationChannel.getRequired("tokenization_channel") + + /** + * Unique identifier for the digital wallet token attempt + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun walletDecisioningInfo(): WalletDecisioningInfo = + walletDecisioningInfo.getRequired("wallet_decisioning_info") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun device(): Optional = device.getOptional("device") + + /** + * Contains the metadata for the digital wallet being tokenized. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun digitalWalletTokenMetadata(): Optional = + digitalWalletTokenMetadata.getOptional("digital_wallet_token_metadata") + + /** + * The source of the tokenization. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationSource(): Optional = + tokenizationSource.getOptional("tokenization_source") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [issuerDecision]. + * + * Unlike [issuerDecision], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("issuer_decision") + @ExcludeMissing + fun _issuerDecision(): JsonField = issuerDecision + + /** + * Returns the raw JSON value of [tokenizationChannel]. + * + * Unlike [tokenizationChannel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_channel") + @ExcludeMissing + fun _tokenizationChannel(): JsonField = tokenizationChannel + + /** + * Returns the raw JSON value of [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + /** + * Returns the raw JSON value of [walletDecisioningInfo]. + * + * Unlike [walletDecisioningInfo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wallet_decisioning_info") + @ExcludeMissing + fun _walletDecisioningInfo(): JsonField = walletDecisioningInfo + + /** + * Returns the raw JSON value of [device]. + * + * Unlike [device], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device") @ExcludeMissing fun _device(): JsonField = device + + /** + * Returns the raw JSON value of [digitalWalletTokenMetadata]. + * + * Unlike [digitalWalletTokenMetadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("digital_wallet_token_metadata") + @ExcludeMissing + fun _digitalWalletTokenMetadata(): JsonField = + digitalWalletTokenMetadata + + /** + * Returns the raw JSON value of [tokenizationSource]. + * + * Unlike [tokenizationSource], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_source") + @ExcludeMissing + fun _tokenizationSource(): JsonField = tokenizationSource + + @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 + * [TokenizationDecisioningRequestWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .issuerDecision() + * .tokenizationChannel() + * .tokenizationToken() + * .walletDecisioningInfo() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationDecisioningRequestWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var issuerDecision: JsonField? = null + private var tokenizationChannel: JsonField? = null + private var tokenizationToken: JsonField? = null + private var walletDecisioningInfo: JsonField? = null + private var device: JsonField = JsonMissing.of() + private var digitalWalletTokenMetadata: JsonField = + JsonMissing.of() + private var tokenizationSource: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + tokenizationDecisioningRequestWebhookEvent: TokenizationDecisioningRequestWebhookEvent + ) = apply { + accountToken = tokenizationDecisioningRequestWebhookEvent.accountToken + cardToken = tokenizationDecisioningRequestWebhookEvent.cardToken + created = tokenizationDecisioningRequestWebhookEvent.created + eventType = tokenizationDecisioningRequestWebhookEvent.eventType + issuerDecision = tokenizationDecisioningRequestWebhookEvent.issuerDecision + tokenizationChannel = tokenizationDecisioningRequestWebhookEvent.tokenizationChannel + tokenizationToken = tokenizationDecisioningRequestWebhookEvent.tokenizationToken + walletDecisioningInfo = tokenizationDecisioningRequestWebhookEvent.walletDecisioningInfo + device = tokenizationDecisioningRequestWebhookEvent.device + digitalWalletTokenMetadata = + tokenizationDecisioningRequestWebhookEvent.digitalWalletTokenMetadata + tokenizationSource = tokenizationDecisioningRequestWebhookEvent.tokenizationSource + additionalProperties = + tokenizationDecisioningRequestWebhookEvent.additionalProperties.toMutableMap() + } + + /** Unique identifier for the user tokenizing a card */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Unique identifier for the card being tokenized */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Indicate when the request was received from Mastercard or Visa */ + 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 } + + /** The name of this event */ + 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 } + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + */ + fun issuerDecision(issuerDecision: IssuerDecision) = + issuerDecision(JsonField.of(issuerDecision)) + + /** + * Sets [Builder.issuerDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerDecision] with a well-typed [IssuerDecision] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuerDecision(issuerDecision: JsonField) = apply { + this.issuerDecision = issuerDecision + } + + /** The channel through which the tokenization was made. */ + fun tokenizationChannel(tokenizationChannel: TokenizationChannel) = + tokenizationChannel(JsonField.of(tokenizationChannel)) + + /** + * Sets [Builder.tokenizationChannel] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationChannel] with a well-typed + * [TokenizationChannel] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenizationChannel(tokenizationChannel: JsonField) = apply { + this.tokenizationChannel = tokenizationChannel + } + + /** Unique identifier for the digital wallet token attempt */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + fun walletDecisioningInfo(walletDecisioningInfo: WalletDecisioningInfo) = + walletDecisioningInfo(JsonField.of(walletDecisioningInfo)) + + /** + * Sets [Builder.walletDecisioningInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.walletDecisioningInfo] with a well-typed + * [WalletDecisioningInfo] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun walletDecisioningInfo(walletDecisioningInfo: JsonField) = apply { + this.walletDecisioningInfo = walletDecisioningInfo + } + + fun device(device: Device) = device(JsonField.of(device)) + + /** + * Sets [Builder.device] to an arbitrary JSON value. + * + * You should usually call [Builder.device] with a well-typed [Device] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun device(device: JsonField) = apply { this.device = device } + + /** Contains the metadata for the digital wallet being tokenized. */ + fun digitalWalletTokenMetadata(digitalWalletTokenMetadata: DigitalWalletTokenMetadata) = + digitalWalletTokenMetadata(JsonField.of(digitalWalletTokenMetadata)) + + /** + * Sets [Builder.digitalWalletTokenMetadata] to an arbitrary JSON value. + * + * You should usually call [Builder.digitalWalletTokenMetadata] with a well-typed + * [DigitalWalletTokenMetadata] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun digitalWalletTokenMetadata( + digitalWalletTokenMetadata: JsonField + ) = apply { this.digitalWalletTokenMetadata = digitalWalletTokenMetadata } + + /** The source of the tokenization. */ + fun tokenizationSource(tokenizationSource: TokenizationSource) = + tokenizationSource(JsonField.of(tokenizationSource)) + + /** + * Sets [Builder.tokenizationSource] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationSource] with a well-typed + * [TokenizationSource] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenizationSource(tokenizationSource: JsonField) = apply { + this.tokenizationSource = tokenizationSource + } + + 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 [TokenizationDecisioningRequestWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .issuerDecision() + * .tokenizationChannel() + * .tokenizationToken() + * .walletDecisioningInfo() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationDecisioningRequestWebhookEvent = + TokenizationDecisioningRequestWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("issuerDecision", issuerDecision), + checkRequired("tokenizationChannel", tokenizationChannel), + checkRequired("tokenizationToken", tokenizationToken), + checkRequired("walletDecisioningInfo", walletDecisioningInfo), + device, + digitalWalletTokenMetadata, + tokenizationSource, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationDecisioningRequestWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + cardToken() + created() + eventType().validate() + issuerDecision().validate() + tokenizationChannel().validate() + tokenizationToken() + walletDecisioningInfo().validate() + device().ifPresent { it.validate() } + digitalWalletTokenMetadata().ifPresent { it.validate() } + tokenizationSource().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (issuerDecision.asKnown().getOrNull()?.validity() ?: 0) + + (tokenizationChannel.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + (walletDecisioningInfo.asKnown().getOrNull()?.validity() ?: 0) + + (device.asKnown().getOrNull()?.validity() ?: 0) + + (digitalWalletTokenMetadata.asKnown().getOrNull()?.validity() ?: 0) + + (tokenizationSource.asKnown().getOrNull()?.validity() ?: 0) + + /** The name of this event */ + 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 DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST = + of("digital_wallet.tokenization_approval_request") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + DIGITAL_WALLET_TOKENIZATION_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 { + DIGITAL_WALLET_TOKENIZATION_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) { + DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST -> + Value.DIGITAL_WALLET_TOKENIZATION_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) { + DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST -> + Known.DIGITAL_WALLET_TOKENIZATION_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 + + 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() + } + + /** + * Whether Lithic decisioned on the token, and if so, what the decision was. + * APPROVED/VERIFICATION_REQUIRED/DENIED. + */ + class IssuerDecision @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val APPROVED = of("APPROVED") + + @JvmField val DENIED = of("DENIED") + + @JvmField val VERIFICATION_REQUIRED = of("VERIFICATION_REQUIRED") + + @JvmStatic fun of(value: String) = IssuerDecision(JsonField.of(value)) + } + + /** An enum containing [IssuerDecision]'s known values. */ + enum class Known { + APPROVED, + DENIED, + VERIFICATION_REQUIRED, + } + + /** + * An enum containing [IssuerDecision]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [IssuerDecision] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + APPROVED, + DENIED, + VERIFICATION_REQUIRED, + /** + * An enum member indicating that [IssuerDecision] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APPROVED -> Value.APPROVED + DENIED -> Value.DENIED + VERIFICATION_REQUIRED -> Value.VERIFICATION_REQUIRED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws LithicInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APPROVED -> Known.APPROVED + DENIED -> Known.DENIED + VERIFICATION_REQUIRED -> Known.VERIFICATION_REQUIRED + else -> throw LithicInvalidDataException("Unknown IssuerDecision: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): IssuerDecision = 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 IssuerDecision && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The channel through which the tokenization was made. */ + class TokenizationChannel + @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 DIGITAL_WALLET = of("DIGITAL_WALLET") + + @JvmField val MERCHANT = of("MERCHANT") + + @JvmStatic fun of(value: String) = TokenizationChannel(JsonField.of(value)) + } + + /** An enum containing [TokenizationChannel]'s known values. */ + enum class Known { + DIGITAL_WALLET, + MERCHANT, + } + + /** + * An enum containing [TokenizationChannel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TokenizationChannel] 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 { + DIGITAL_WALLET, + MERCHANT, + /** + * An enum member indicating that [TokenizationChannel] 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) { + DIGITAL_WALLET -> Value.DIGITAL_WALLET + MERCHANT -> Value.MERCHANT + 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) { + DIGITAL_WALLET -> Known.DIGITAL_WALLET + MERCHANT -> Known.MERCHANT + else -> throw LithicInvalidDataException("Unknown TokenizationChannel: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenizationChannel = 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 TokenizationChannel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The source of the tokenization. */ + class TokenizationSource + @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 ACCOUNT_ON_FILE = of("ACCOUNT_ON_FILE") + + @JvmField val CONTACTLESS_TAP = of("CONTACTLESS_TAP") + + @JvmField val MANUAL_PROVISION = of("MANUAL_PROVISION") + + @JvmField val PUSH_PROVISION = of("PUSH_PROVISION") + + @JvmField val TOKEN = of("TOKEN") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = TokenizationSource(JsonField.of(value)) + } + + /** An enum containing [TokenizationSource]'s known values. */ + enum class Known { + ACCOUNT_ON_FILE, + CONTACTLESS_TAP, + MANUAL_PROVISION, + PUSH_PROVISION, + TOKEN, + UNKNOWN, + } + + /** + * An enum containing [TokenizationSource]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TokenizationSource] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_ON_FILE, + CONTACTLESS_TAP, + MANUAL_PROVISION, + PUSH_PROVISION, + TOKEN, + UNKNOWN, + /** + * An enum member indicating that [TokenizationSource] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_ON_FILE -> Value.ACCOUNT_ON_FILE + CONTACTLESS_TAP -> Value.CONTACTLESS_TAP + MANUAL_PROVISION -> Value.MANUAL_PROVISION + PUSH_PROVISION -> Value.PUSH_PROVISION + TOKEN -> Value.TOKEN + 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) { + ACCOUNT_ON_FILE -> Known.ACCOUNT_ON_FILE + CONTACTLESS_TAP -> Known.CONTACTLESS_TAP + MANUAL_PROVISION -> Known.MANUAL_PROVISION + PUSH_PROVISION -> Known.PUSH_PROVISION + TOKEN -> Known.TOKEN + UNKNOWN -> Known.UNKNOWN + else -> throw LithicInvalidDataException("Unknown TokenizationSource: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { LithicInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TokenizationSource = 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 TokenizationSource && 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 TokenizationDecisioningRequestWebhookEvent && + accountToken == other.accountToken && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + issuerDecision == other.issuerDecision && + tokenizationChannel == other.tokenizationChannel && + tokenizationToken == other.tokenizationToken && + walletDecisioningInfo == other.walletDecisioningInfo && + device == other.device && + digitalWalletTokenMetadata == other.digitalWalletTokenMetadata && + tokenizationSource == other.tokenizationSource && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + cardToken, + created, + eventType, + issuerDecision, + tokenizationChannel, + tokenizationToken, + walletDecisioningInfo, + device, + digitalWalletTokenMetadata, + tokenizationSource, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationDecisioningRequestWebhookEvent{accountToken=$accountToken, cardToken=$cardToken, created=$created, eventType=$eventType, issuerDecision=$issuerDecision, tokenizationChannel=$tokenizationChannel, tokenizationToken=$tokenizationToken, walletDecisioningInfo=$walletDecisioningInfo, device=$device, digitalWalletTokenMetadata=$digitalWalletTokenMetadata, tokenizationSource=$tokenizationSource, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationResultWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationResultWebhookEvent.kt new file mode 100644 index 000000000..28235b5c3 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationResultWebhookEvent.kt @@ -0,0 +1,1263 @@ +// 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 + +class TokenizationResultWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val tokenizationResultDetails: JsonField, + private val tokenizationToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_result_details") + @ExcludeMissing + tokenizationResultDetails: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + ) : this( + accountToken, + cardToken, + created, + eventType, + tokenizationResultDetails, + tokenizationToken, + mutableMapOf(), + ) + + /** + * Account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountToken(): String = accountToken.getRequired("account_token") + + /** + * Card token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Created date + * + * @throws LithicInvalidDataException if 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") + + /** + * 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") + + /** + * The result of the tokenization request. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationResultDetails(): TokenizationResultDetails = + tokenizationResultDetails.getRequired("tokenization_result_details") + + /** + * Tokenization token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [tokenizationResultDetails]. + * + * Unlike [tokenizationResultDetails], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_result_details") + @ExcludeMissing + fun _tokenizationResultDetails(): JsonField = + tokenizationResultDetails + + /** + * Returns the raw JSON value of [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + @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 + * [TokenizationResultWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .tokenizationResultDetails() + * .tokenizationToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationResultWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var tokenizationResultDetails: JsonField? = null + private var tokenizationToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenizationResultWebhookEvent: TokenizationResultWebhookEvent) = apply { + accountToken = tokenizationResultWebhookEvent.accountToken + cardToken = tokenizationResultWebhookEvent.cardToken + created = tokenizationResultWebhookEvent.created + eventType = tokenizationResultWebhookEvent.eventType + tokenizationResultDetails = tokenizationResultWebhookEvent.tokenizationResultDetails + tokenizationToken = tokenizationResultWebhookEvent.tokenizationToken + additionalProperties = + tokenizationResultWebhookEvent.additionalProperties.toMutableMap() + } + + /** Account token */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Card token */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Created date */ + 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 } + + /** 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 } + + /** The result of the tokenization request. */ + fun tokenizationResultDetails(tokenizationResultDetails: TokenizationResultDetails) = + tokenizationResultDetails(JsonField.of(tokenizationResultDetails)) + + /** + * Sets [Builder.tokenizationResultDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationResultDetails] with a well-typed + * [TokenizationResultDetails] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun tokenizationResultDetails( + tokenizationResultDetails: JsonField + ) = apply { this.tokenizationResultDetails = tokenizationResultDetails } + + /** Tokenization token */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + 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 [TokenizationResultWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .tokenizationResultDetails() + * .tokenizationToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationResultWebhookEvent = + TokenizationResultWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("tokenizationResultDetails", tokenizationResultDetails), + checkRequired("tokenizationToken", tokenizationToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationResultWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + cardToken() + created() + eventType().validate() + tokenizationResultDetails().validate() + tokenizationToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (tokenizationResultDetails.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + /** 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 TOKENIZATION_RESULT = of("tokenization.result") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + TOKENIZATION_RESULT + } + + /** + * 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 { + TOKENIZATION_RESULT, + /** + * 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) { + TOKENIZATION_RESULT -> Value.TOKENIZATION_RESULT + 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) { + TOKENIZATION_RESULT -> Known.TOKENIZATION_RESULT + 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 + + 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() + } + + /** The result of the tokenization request. */ + class TokenizationResultDetails + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val issuerDecision: JsonField, + private val tokenizationDeclineReasons: JsonField>, + private val customerDecision: JsonField, + private val ruleResults: JsonField>, + private val tokenActivatedDateTime: JsonField, + private val tokenizationTfaReasons: JsonField>, + private val walletDecision: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("issuer_decision") + @ExcludeMissing + issuerDecision: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_decline_reasons") + @ExcludeMissing + tokenizationDeclineReasons: JsonField> = + JsonMissing.of(), + @JsonProperty("customer_decision") + @ExcludeMissing + customerDecision: JsonField = JsonMissing.of(), + @JsonProperty("rule_results") + @ExcludeMissing + ruleResults: JsonField> = JsonMissing.of(), + @JsonProperty("token_activated_date_time") + @ExcludeMissing + tokenActivatedDateTime: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_tfa_reasons") + @ExcludeMissing + tokenizationTfaReasons: JsonField> = JsonMissing.of(), + @JsonProperty("wallet_decision") + @ExcludeMissing + walletDecision: JsonField = JsonMissing.of(), + ) : this( + issuerDecision, + tokenizationDeclineReasons, + customerDecision, + ruleResults, + tokenActivatedDateTime, + tokenizationTfaReasons, + walletDecision, + mutableMapOf(), + ) + + /** + * Lithic's tokenization decision. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun issuerDecision(): String = issuerDecision.getRequired("issuer_decision") + + /** + * List of reasons why the tokenization was declined + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationDeclineReasons(): List = + tokenizationDeclineReasons.getRequired("tokenization_decline_reasons") + + /** + * The customer's tokenization decision if applicable. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerDecision(): Optional = customerDecision.getOptional("customer_decision") + + /** + * Results from rules that were evaluated for this tokenization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ruleResults(): Optional> = + ruleResults.getOptional("rule_results") + + /** + * An RFC 3339 timestamp indicating when the tokenization succeeded. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenActivatedDateTime(): Optional = + tokenActivatedDateTime.getOptional("token_activated_date_time") + + /** + * List of reasons why two-factor authentication was required + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenizationTfaReasons(): Optional> = + tokenizationTfaReasons.getOptional("tokenization_tfa_reasons") + + /** + * The wallet's recommended decision. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun walletDecision(): Optional = walletDecision.getOptional("wallet_decision") + + /** + * Returns the raw JSON value of [issuerDecision]. + * + * Unlike [issuerDecision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("issuer_decision") + @ExcludeMissing + fun _issuerDecision(): JsonField = issuerDecision + + /** + * Returns the raw JSON value of [tokenizationDeclineReasons]. + * + * Unlike [tokenizationDeclineReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_decline_reasons") + @ExcludeMissing + fun _tokenizationDeclineReasons(): JsonField> = + tokenizationDeclineReasons + + /** + * Returns the raw JSON value of [customerDecision]. + * + * Unlike [customerDecision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_decision") + @ExcludeMissing + fun _customerDecision(): JsonField = customerDecision + + /** + * Returns the raw JSON value of [ruleResults]. + * + * Unlike [ruleResults], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_results") + @ExcludeMissing + fun _ruleResults(): JsonField> = ruleResults + + /** + * Returns the raw JSON value of [tokenActivatedDateTime]. + * + * Unlike [tokenActivatedDateTime], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("token_activated_date_time") + @ExcludeMissing + fun _tokenActivatedDateTime(): JsonField = tokenActivatedDateTime + + /** + * Returns the raw JSON value of [tokenizationTfaReasons]. + * + * Unlike [tokenizationTfaReasons], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tokenization_tfa_reasons") + @ExcludeMissing + fun _tokenizationTfaReasons(): JsonField> = + tokenizationTfaReasons + + /** + * Returns the raw JSON value of [walletDecision]. + * + * Unlike [walletDecision], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wallet_decision") + @ExcludeMissing + fun _walletDecision(): JsonField = walletDecision + + @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 + * [TokenizationResultDetails]. + * + * The following fields are required: + * ```java + * .issuerDecision() + * .tokenizationDeclineReasons() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationResultDetails]. */ + class Builder internal constructor() { + + private var issuerDecision: JsonField? = null + private var tokenizationDeclineReasons: + JsonField>? = + null + private var customerDecision: JsonField = JsonMissing.of() + private var ruleResults: JsonField>? = null + private var tokenActivatedDateTime: JsonField = JsonMissing.of() + private var tokenizationTfaReasons: JsonField>? = + null + private var walletDecision: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenizationResultDetails: TokenizationResultDetails) = apply { + issuerDecision = tokenizationResultDetails.issuerDecision + tokenizationDeclineReasons = + tokenizationResultDetails.tokenizationDeclineReasons.map { it.toMutableList() } + customerDecision = tokenizationResultDetails.customerDecision + ruleResults = tokenizationResultDetails.ruleResults.map { it.toMutableList() } + tokenActivatedDateTime = tokenizationResultDetails.tokenActivatedDateTime + tokenizationTfaReasons = + tokenizationResultDetails.tokenizationTfaReasons.map { it.toMutableList() } + walletDecision = tokenizationResultDetails.walletDecision + additionalProperties = tokenizationResultDetails.additionalProperties.toMutableMap() + } + + /** Lithic's tokenization decision. */ + fun issuerDecision(issuerDecision: String) = + issuerDecision(JsonField.of(issuerDecision)) + + /** + * Sets [Builder.issuerDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerDecision] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun issuerDecision(issuerDecision: JsonField) = apply { + this.issuerDecision = issuerDecision + } + + /** List of reasons why the tokenization was declined */ + fun tokenizationDeclineReasons( + tokenizationDeclineReasons: List + ) = tokenizationDeclineReasons(JsonField.of(tokenizationDeclineReasons)) + + /** + * Sets [Builder.tokenizationDeclineReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationDeclineReasons] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun tokenizationDeclineReasons( + tokenizationDeclineReasons: JsonField> + ) = apply { + this.tokenizationDeclineReasons = + tokenizationDeclineReasons.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationDeclineReason] to [tokenizationDeclineReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTokenizationDeclineReason(tokenizationDeclineReason: TokenizationDeclineReason) = + apply { + tokenizationDeclineReasons = + (tokenizationDeclineReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("tokenizationDeclineReasons", it) + .add(tokenizationDeclineReason) + } + } + + /** The customer's tokenization decision if applicable. */ + fun customerDecision(customerDecision: String?) = + customerDecision(JsonField.ofNullable(customerDecision)) + + /** + * Alias for calling [Builder.customerDecision] with `customerDecision.orElse(null)`. + */ + fun customerDecision(customerDecision: Optional) = + customerDecision(customerDecision.getOrNull()) + + /** + * Sets [Builder.customerDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.customerDecision] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerDecision(customerDecision: JsonField) = apply { + this.customerDecision = customerDecision + } + + /** Results from rules that were evaluated for this tokenization */ + fun ruleResults(ruleResults: List) = + ruleResults(JsonField.of(ruleResults)) + + /** + * Sets [Builder.ruleResults] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleResults] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun ruleResults(ruleResults: JsonField>) = apply { + this.ruleResults = ruleResults.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationRuleResult] to [ruleResults]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRuleResult(ruleResult: TokenizationRuleResult) = apply { + ruleResults = + (ruleResults ?: JsonField.of(mutableListOf())).also { + checkKnown("ruleResults", it).add(ruleResult) + } + } + + /** An RFC 3339 timestamp indicating when the tokenization succeeded. */ + fun tokenActivatedDateTime(tokenActivatedDateTime: OffsetDateTime?) = + tokenActivatedDateTime(JsonField.ofNullable(tokenActivatedDateTime)) + + /** + * Alias for calling [Builder.tokenActivatedDateTime] with + * `tokenActivatedDateTime.orElse(null)`. + */ + fun tokenActivatedDateTime(tokenActivatedDateTime: Optional) = + tokenActivatedDateTime(tokenActivatedDateTime.getOrNull()) + + /** + * Sets [Builder.tokenActivatedDateTime] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenActivatedDateTime] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tokenActivatedDateTime(tokenActivatedDateTime: JsonField) = apply { + this.tokenActivatedDateTime = tokenActivatedDateTime + } + + /** List of reasons why two-factor authentication was required */ + fun tokenizationTfaReasons(tokenizationTfaReasons: List) = + tokenizationTfaReasons(JsonField.of(tokenizationTfaReasons)) + + /** + * Sets [Builder.tokenizationTfaReasons] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationTfaReasons] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun tokenizationTfaReasons( + tokenizationTfaReasons: JsonField> + ) = apply { + this.tokenizationTfaReasons = tokenizationTfaReasons.map { it.toMutableList() } + } + + /** + * Adds a single [TokenizationTfaReason] to [tokenizationTfaReasons]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTokenizationTfaReason(tokenizationTfaReason: TokenizationTfaReason) = apply { + tokenizationTfaReasons = + (tokenizationTfaReasons ?: JsonField.of(mutableListOf())).also { + checkKnown("tokenizationTfaReasons", it).add(tokenizationTfaReason) + } + } + + /** The wallet's recommended decision. */ + fun walletDecision(walletDecision: String?) = + walletDecision(JsonField.ofNullable(walletDecision)) + + /** Alias for calling [Builder.walletDecision] with `walletDecision.orElse(null)`. */ + fun walletDecision(walletDecision: Optional) = + walletDecision(walletDecision.getOrNull()) + + /** + * Sets [Builder.walletDecision] to an arbitrary JSON value. + * + * You should usually call [Builder.walletDecision] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun walletDecision(walletDecision: JsonField) = apply { + this.walletDecision = walletDecision + } + + 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 [TokenizationResultDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .issuerDecision() + * .tokenizationDeclineReasons() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationResultDetails = + TokenizationResultDetails( + checkRequired("issuerDecision", issuerDecision), + checkRequired("tokenizationDeclineReasons", tokenizationDeclineReasons).map { + it.toImmutable() + }, + customerDecision, + (ruleResults ?: JsonMissing.of()).map { it.toImmutable() }, + tokenActivatedDateTime, + (tokenizationTfaReasons ?: JsonMissing.of()).map { it.toImmutable() }, + walletDecision, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationResultDetails = apply { + if (validated) { + return@apply + } + + issuerDecision() + tokenizationDeclineReasons().forEach { it.validate() } + customerDecision() + ruleResults().ifPresent { it.forEach { it.validate() } } + tokenActivatedDateTime() + tokenizationTfaReasons().ifPresent { it.forEach { it.validate() } } + walletDecision() + 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 (issuerDecision.asKnown().isPresent) 1 else 0) + + (tokenizationDeclineReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (customerDecision.asKnown().isPresent) 1 else 0) + + (ruleResults.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (tokenActivatedDateTime.asKnown().isPresent) 1 else 0) + + (tokenizationTfaReasons.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (walletDecision.asKnown().isPresent) 1 else 0) + + class TokenizationDeclineReason + @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 ACCOUNT_SCORE_1 = of("ACCOUNT_SCORE_1") + + @JvmField + val ALL_WALLET_DECLINE_REASONS_PRESENT = of("ALL_WALLET_DECLINE_REASONS_PRESENT") + + @JvmField val CARD_EXPIRY_MONTH_MISMATCH = of("CARD_EXPIRY_MONTH_MISMATCH") + + @JvmField val CARD_EXPIRY_YEAR_MISMATCH = of("CARD_EXPIRY_YEAR_MISMATCH") + + @JvmField val CARD_INVALID_STATE = of("CARD_INVALID_STATE") + + @JvmField val CUSTOMER_RED_PATH = of("CUSTOMER_RED_PATH") + + @JvmField val CVC_MISMATCH = of("CVC_MISMATCH") + + @JvmField val DEVICE_SCORE_1 = of("DEVICE_SCORE_1") + + @JvmField val GENERIC_DECLINE = of("GENERIC_DECLINE") + + @JvmField val INVALID_CUSTOMER_RESPONSE = of("INVALID_CUSTOMER_RESPONSE") + + @JvmField val NETWORK_FAILURE = of("NETWORK_FAILURE") + + @JvmField + val WALLET_RECOMMENDED_DECISION_RED = of("WALLET_RECOMMENDED_DECISION_RED") + + @JvmStatic fun of(value: String) = TokenizationDeclineReason(JsonField.of(value)) + } + + /** An enum containing [TokenizationDeclineReason]'s known values. */ + enum class Known { + ACCOUNT_SCORE_1, + ALL_WALLET_DECLINE_REASONS_PRESENT, + CARD_EXPIRY_MONTH_MISMATCH, + CARD_EXPIRY_YEAR_MISMATCH, + CARD_INVALID_STATE, + CUSTOMER_RED_PATH, + CVC_MISMATCH, + DEVICE_SCORE_1, + GENERIC_DECLINE, + INVALID_CUSTOMER_RESPONSE, + NETWORK_FAILURE, + WALLET_RECOMMENDED_DECISION_RED, + } + + /** + * An enum containing [TokenizationDeclineReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [TokenizationDeclineReason] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_SCORE_1, + ALL_WALLET_DECLINE_REASONS_PRESENT, + CARD_EXPIRY_MONTH_MISMATCH, + CARD_EXPIRY_YEAR_MISMATCH, + CARD_INVALID_STATE, + CUSTOMER_RED_PATH, + CVC_MISMATCH, + DEVICE_SCORE_1, + GENERIC_DECLINE, + INVALID_CUSTOMER_RESPONSE, + NETWORK_FAILURE, + WALLET_RECOMMENDED_DECISION_RED, + /** + * An enum member indicating that [TokenizationDeclineReason] was instantiated with + * an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_SCORE_1 -> Value.ACCOUNT_SCORE_1 + ALL_WALLET_DECLINE_REASONS_PRESENT -> Value.ALL_WALLET_DECLINE_REASONS_PRESENT + CARD_EXPIRY_MONTH_MISMATCH -> Value.CARD_EXPIRY_MONTH_MISMATCH + CARD_EXPIRY_YEAR_MISMATCH -> Value.CARD_EXPIRY_YEAR_MISMATCH + CARD_INVALID_STATE -> Value.CARD_INVALID_STATE + CUSTOMER_RED_PATH -> Value.CUSTOMER_RED_PATH + CVC_MISMATCH -> Value.CVC_MISMATCH + DEVICE_SCORE_1 -> Value.DEVICE_SCORE_1 + GENERIC_DECLINE -> Value.GENERIC_DECLINE + INVALID_CUSTOMER_RESPONSE -> Value.INVALID_CUSTOMER_RESPONSE + NETWORK_FAILURE -> Value.NETWORK_FAILURE + WALLET_RECOMMENDED_DECISION_RED -> Value.WALLET_RECOMMENDED_DECISION_RED + 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) { + ACCOUNT_SCORE_1 -> Known.ACCOUNT_SCORE_1 + ALL_WALLET_DECLINE_REASONS_PRESENT -> Known.ALL_WALLET_DECLINE_REASONS_PRESENT + CARD_EXPIRY_MONTH_MISMATCH -> Known.CARD_EXPIRY_MONTH_MISMATCH + CARD_EXPIRY_YEAR_MISMATCH -> Known.CARD_EXPIRY_YEAR_MISMATCH + CARD_INVALID_STATE -> Known.CARD_INVALID_STATE + CUSTOMER_RED_PATH -> Known.CUSTOMER_RED_PATH + CVC_MISMATCH -> Known.CVC_MISMATCH + DEVICE_SCORE_1 -> Known.DEVICE_SCORE_1 + GENERIC_DECLINE -> Known.GENERIC_DECLINE + INVALID_CUSTOMER_RESPONSE -> Known.INVALID_CUSTOMER_RESPONSE + NETWORK_FAILURE -> Known.NETWORK_FAILURE + WALLET_RECOMMENDED_DECISION_RED -> Known.WALLET_RECOMMENDED_DECISION_RED + else -> + throw LithicInvalidDataException( + "Unknown TokenizationDeclineReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TokenizationDeclineReason = 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 TokenizationDeclineReason && 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 TokenizationResultDetails && + issuerDecision == other.issuerDecision && + tokenizationDeclineReasons == other.tokenizationDeclineReasons && + customerDecision == other.customerDecision && + ruleResults == other.ruleResults && + tokenActivatedDateTime == other.tokenActivatedDateTime && + tokenizationTfaReasons == other.tokenizationTfaReasons && + walletDecision == other.walletDecision && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + issuerDecision, + tokenizationDeclineReasons, + customerDecision, + ruleResults, + tokenActivatedDateTime, + tokenizationTfaReasons, + walletDecision, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationResultDetails{issuerDecision=$issuerDecision, tokenizationDeclineReasons=$tokenizationDeclineReasons, customerDecision=$customerDecision, ruleResults=$ruleResults, tokenActivatedDateTime=$tokenActivatedDateTime, tokenizationTfaReasons=$tokenizationTfaReasons, walletDecision=$walletDecision, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenizationResultWebhookEvent && + accountToken == other.accountToken && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + tokenizationResultDetails == other.tokenizationResultDetails && + tokenizationToken == other.tokenizationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + cardToken, + created, + eventType, + tokenizationResultDetails, + tokenizationToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationResultWebhookEvent{accountToken=$accountToken, cardToken=$cardToken, created=$created, eventType=$eventType, tokenizationResultDetails=$tokenizationResultDetails, tokenizationToken=$tokenizationToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.kt new file mode 100644 index 000000000..f269e5a88 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.kt @@ -0,0 +1,882 @@ +// 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 TokenizationTwoFactorAuthenticationCodeSentWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val activationMethod: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val tokenizationToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("activation_method") + @ExcludeMissing + activationMethod: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + ) : this( + accountToken, + activationMethod, + cardToken, + created, + eventType, + tokenizationToken, + mutableMapOf(), + ) + + /** + * Unique identifier for the user tokenizing a 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun activationMethod(): ActivationMethod = activationMethod.getRequired("activation_method") + + /** + * Unique identifier for the card being tokenized + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Indicate when the request was received from Mastercard or Visa + * + * @throws LithicInvalidDataException if 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") + + /** + * 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") + + /** + * Unique identifier for the tokenization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [activationMethod]. + * + * Unlike [activationMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("activation_method") + @ExcludeMissing + fun _activationMethod(): JsonField = activationMethod + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + @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 + * [TokenizationTwoFactorAuthenticationCodeSentWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .activationMethod() + * .cardToken() + * .created() + * .eventType() + * .tokenizationToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationTwoFactorAuthenticationCodeSentWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var activationMethod: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var tokenizationToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + tokenizationTwoFactorAuthenticationCodeSentWebhookEvent: + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ) = apply { + accountToken = tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.accountToken + activationMethod = + tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.activationMethod + cardToken = tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.cardToken + created = tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.created + eventType = tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.eventType + tokenizationToken = + tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.tokenizationToken + additionalProperties = + tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.additionalProperties + .toMutableMap() + } + + /** Unique identifier for the user tokenizing a card */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + fun activationMethod(activationMethod: ActivationMethod) = + activationMethod(JsonField.of(activationMethod)) + + /** + * Sets [Builder.activationMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.activationMethod] with a well-typed [ActivationMethod] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun activationMethod(activationMethod: JsonField) = apply { + this.activationMethod = activationMethod + } + + /** Unique identifier for the card being tokenized */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Indicate when the request was received from Mastercard or Visa */ + 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 } + + /** 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 } + + /** Unique identifier for the tokenization */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + 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 + * [TokenizationTwoFactorAuthenticationCodeSentWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .activationMethod() + * .cardToken() + * .created() + * .eventType() + * .tokenizationToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("activationMethod", activationMethod), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("tokenizationToken", tokenizationToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationTwoFactorAuthenticationCodeSentWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + activationMethod().validate() + cardToken() + created() + eventType().validate() + tokenizationToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (activationMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + class ActivationMethod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(type, value, mutableMapOf()) + + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_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 type(): Type = type.getRequired("type") + + /** + * The location to which the authentication code was sent. The format depends on the + * ActivationMethod.Type field. If Type is Email, the Value will be the email address. If + * the Type is Sms, the Value will be the phone 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 value(): String = value.getRequired("value") + + /** + * 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 [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [ActivationMethod]. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActivationMethod]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(activationMethod: ActivationMethod) = apply { + type = activationMethod.type + value = activationMethod.value + additionalProperties = activationMethod.additionalProperties.toMutableMap() + } + + /** + * The communication method that the user has selected to use to receive the + * authentication code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * The location to which the authentication code was sent. The format depends on the + * ActivationMethod.Type field. If Type is Email, the Value will be the email address. + * If the Type is Sms, the Value will be the phone number. + */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + 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 [ActivationMethod]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ActivationMethod = + ActivationMethod( + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ActivationMethod = apply { + if (validated) { + return@apply + } + + type().validate() + value() + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + 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 EMAIL_TO_CARDHOLDER_ADDRESS = of("EMAIL_TO_CARDHOLDER_ADDRESS") + + @JvmField val TEXT_TO_CARDHOLDER_NUMBER = of("TEXT_TO_CARDHOLDER_NUMBER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + EMAIL_TO_CARDHOLDER_ADDRESS, + TEXT_TO_CARDHOLDER_NUMBER, + } + + /** + * 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 { + EMAIL_TO_CARDHOLDER_ADDRESS, + TEXT_TO_CARDHOLDER_NUMBER, + /** 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) { + EMAIL_TO_CARDHOLDER_ADDRESS -> Value.EMAIL_TO_CARDHOLDER_ADDRESS + TEXT_TO_CARDHOLDER_NUMBER -> Value.TEXT_TO_CARDHOLDER_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) { + EMAIL_TO_CARDHOLDER_ADDRESS -> Known.EMAIL_TO_CARDHOLDER_ADDRESS + TEXT_TO_CARDHOLDER_NUMBER -> Known.TEXT_TO_CARDHOLDER_NUMBER + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 ActivationMethod && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActivationMethod{type=$type, value=$value, 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 TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT = + of("tokenization.two_factor_authentication_code_sent") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + } + + /** + * 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 { + TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT, + /** + * 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) { + TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT -> + Value.TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + 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) { + TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT -> + Known.TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + 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 + + 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 TokenizationTwoFactorAuthenticationCodeSentWebhookEvent && + accountToken == other.accountToken && + activationMethod == other.activationMethod && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + tokenizationToken == other.tokenizationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + activationMethod, + cardToken, + created, + eventType, + tokenizationToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationTwoFactorAuthenticationCodeSentWebhookEvent{accountToken=$accountToken, activationMethod=$activationMethod, cardToken=$cardToken, created=$created, eventType=$eventType, tokenizationToken=$tokenizationToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeWebhookEvent.kt new file mode 100644 index 000000000..7036fab1b --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeWebhookEvent.kt @@ -0,0 +1,928 @@ +// 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 TokenizationTwoFactorAuthenticationCodeWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val activationMethod: JsonField, + private val authenticationCode: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val tokenizationToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("activation_method") + @ExcludeMissing + activationMethod: JsonField = JsonMissing.of(), + @JsonProperty("authentication_code") + @ExcludeMissing + authenticationCode: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("tokenization_token") + @ExcludeMissing + tokenizationToken: JsonField = JsonMissing.of(), + ) : this( + accountToken, + activationMethod, + authenticationCode, + cardToken, + created, + eventType, + tokenizationToken, + mutableMapOf(), + ) + + /** + * Unique identifier for the user tokenizing a 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 accountToken(): String = accountToken.getRequired("account_token") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun activationMethod(): ActivationMethod = activationMethod.getRequired("activation_method") + + /** + * Authentication code to provide to the user tokenizing a 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 authenticationCode(): String = authenticationCode.getRequired("authentication_code") + + /** + * Unique identifier for the card being tokenized + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Indicate when the request was received from Mastercard or Visa + * + * @throws LithicInvalidDataException if 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") + + /** + * 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") + + /** + * Unique identifier for the tokenization + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenizationToken(): String = tokenizationToken.getRequired("tokenization_token") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [activationMethod]. + * + * Unlike [activationMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("activation_method") + @ExcludeMissing + fun _activationMethod(): JsonField = activationMethod + + /** + * Returns the raw JSON value of [authenticationCode]. + * + * Unlike [authenticationCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authentication_code") + @ExcludeMissing + fun _authenticationCode(): JsonField = authenticationCode + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [tokenizationToken]. + * + * Unlike [tokenizationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tokenization_token") + @ExcludeMissing + fun _tokenizationToken(): JsonField = tokenizationToken + + @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 + * [TokenizationTwoFactorAuthenticationCodeWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .activationMethod() + * .authenticationCode() + * .cardToken() + * .created() + * .eventType() + * .tokenizationToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationTwoFactorAuthenticationCodeWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var activationMethod: JsonField? = null + private var authenticationCode: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var tokenizationToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + tokenizationTwoFactorAuthenticationCodeWebhookEvent: + TokenizationTwoFactorAuthenticationCodeWebhookEvent + ) = apply { + accountToken = tokenizationTwoFactorAuthenticationCodeWebhookEvent.accountToken + activationMethod = tokenizationTwoFactorAuthenticationCodeWebhookEvent.activationMethod + authenticationCode = + tokenizationTwoFactorAuthenticationCodeWebhookEvent.authenticationCode + cardToken = tokenizationTwoFactorAuthenticationCodeWebhookEvent.cardToken + created = tokenizationTwoFactorAuthenticationCodeWebhookEvent.created + eventType = tokenizationTwoFactorAuthenticationCodeWebhookEvent.eventType + tokenizationToken = + tokenizationTwoFactorAuthenticationCodeWebhookEvent.tokenizationToken + additionalProperties = + tokenizationTwoFactorAuthenticationCodeWebhookEvent.additionalProperties + .toMutableMap() + } + + /** Unique identifier for the user tokenizing a card */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + fun activationMethod(activationMethod: ActivationMethod) = + activationMethod(JsonField.of(activationMethod)) + + /** + * Sets [Builder.activationMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.activationMethod] with a well-typed [ActivationMethod] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun activationMethod(activationMethod: JsonField) = apply { + this.activationMethod = activationMethod + } + + /** Authentication code to provide to the user tokenizing a card. */ + fun authenticationCode(authenticationCode: String) = + authenticationCode(JsonField.of(authenticationCode)) + + /** + * Sets [Builder.authenticationCode] to an arbitrary JSON value. + * + * You should usually call [Builder.authenticationCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authenticationCode(authenticationCode: JsonField) = apply { + this.authenticationCode = authenticationCode + } + + /** Unique identifier for the card being tokenized */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Indicate when the request was received from Mastercard or Visa */ + 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 } + + /** 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 } + + /** Unique identifier for the tokenization */ + fun tokenizationToken(tokenizationToken: String) = + tokenizationToken(JsonField.of(tokenizationToken)) + + /** + * Sets [Builder.tokenizationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenizationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenizationToken(tokenizationToken: JsonField) = apply { + this.tokenizationToken = tokenizationToken + } + + 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 [TokenizationTwoFactorAuthenticationCodeWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .activationMethod() + * .authenticationCode() + * .cardToken() + * .created() + * .eventType() + * .tokenizationToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationTwoFactorAuthenticationCodeWebhookEvent = + TokenizationTwoFactorAuthenticationCodeWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("activationMethod", activationMethod), + checkRequired("authenticationCode", authenticationCode), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("tokenizationToken", tokenizationToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationTwoFactorAuthenticationCodeWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + activationMethod().validate() + authenticationCode() + cardToken() + created() + eventType().validate() + tokenizationToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountToken.asKnown().isPresent) 1 else 0) + + (activationMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (authenticationCode.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (if (tokenizationToken.asKnown().isPresent) 1 else 0) + + class ActivationMethod + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(type, value, mutableMapOf()) + + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_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 type(): Type = type.getRequired("type") + + /** + * The location where the user wants to receive the authentication code. The format depends + * on the ActivationMethod.Type field. If Type is Email, the Value will be the email + * address. If the Type is Sms, the Value will be the phone 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 value(): String = value.getRequired("value") + + /** + * 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 [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @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 [ActivationMethod]. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ActivationMethod]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(activationMethod: ActivationMethod) = apply { + type = activationMethod.type + value = activationMethod.value + additionalProperties = activationMethod.additionalProperties.toMutableMap() + } + + /** + * The communication method that the user has selected to use to receive the + * authentication code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * The location where the user wants to receive the authentication code. The format + * depends on the ActivationMethod.Type field. If Type is Email, the Value will be the + * email address. If the Type is Sms, the Value will be the phone number. + */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + 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 [ActivationMethod]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ActivationMethod = + ActivationMethod( + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ActivationMethod = apply { + if (validated) { + return@apply + } + + type().validate() + value() + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** + * The communication method that the user has selected to use to receive the authentication + * code. Supported Values: Sms = "TEXT_TO_CARDHOLDER_NUMBER". Email = + * "EMAIL_TO_CARDHOLDER_ADDRESS" + */ + 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 EMAIL_TO_CARDHOLDER_ADDRESS = of("EMAIL_TO_CARDHOLDER_ADDRESS") + + @JvmField val TEXT_TO_CARDHOLDER_NUMBER = of("TEXT_TO_CARDHOLDER_NUMBER") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + EMAIL_TO_CARDHOLDER_ADDRESS, + TEXT_TO_CARDHOLDER_NUMBER, + } + + /** + * 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 { + EMAIL_TO_CARDHOLDER_ADDRESS, + TEXT_TO_CARDHOLDER_NUMBER, + /** 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) { + EMAIL_TO_CARDHOLDER_ADDRESS -> Value.EMAIL_TO_CARDHOLDER_ADDRESS + TEXT_TO_CARDHOLDER_NUMBER -> Value.TEXT_TO_CARDHOLDER_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) { + EMAIL_TO_CARDHOLDER_ADDRESS -> Known.EMAIL_TO_CARDHOLDER_ADDRESS + TEXT_TO_CARDHOLDER_NUMBER -> Known.TEXT_TO_CARDHOLDER_NUMBER + else -> throw LithicInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws LithicInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + LithicInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + 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 ActivationMethod && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ActivationMethod{type=$type, value=$value, 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 TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE = + of("tokenization.two_factor_authentication_code") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + } + + /** + * 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 { + TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE, + /** + * 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) { + TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE -> + Value.TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + 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) { + TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE -> + Known.TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + 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 + + 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 TokenizationTwoFactorAuthenticationCodeWebhookEvent && + accountToken == other.accountToken && + activationMethod == other.activationMethod && + authenticationCode == other.authenticationCode && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + tokenizationToken == other.tokenizationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + activationMethod, + authenticationCode, + cardToken, + created, + eventType, + tokenizationToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationTwoFactorAuthenticationCodeWebhookEvent{accountToken=$accountToken, activationMethod=$activationMethod, authenticationCode=$authenticationCode, cardToken=$cardToken, created=$created, eventType=$eventType, tokenizationToken=$tokenizationToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdatedWebhookEvent.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdatedWebhookEvent.kt new file mode 100644 index 000000000..fa7b65cbb --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TokenizationUpdatedWebhookEvent.kt @@ -0,0 +1,474 @@ +// 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 TokenizationUpdatedWebhookEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountToken: JsonField, + private val cardToken: JsonField, + private val created: JsonField, + private val eventType: JsonField, + private val tokenization: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_token") + @ExcludeMissing + accountToken: JsonField = JsonMissing.of(), + @JsonProperty("card_token") @ExcludeMissing cardToken: JsonField = JsonMissing.of(), + @JsonProperty("created") + @ExcludeMissing + created: JsonField = JsonMissing.of(), + @JsonProperty("event_type") + @ExcludeMissing + eventType: JsonField = JsonMissing.of(), + @JsonProperty("tokenization") + @ExcludeMissing + tokenization: JsonField = JsonMissing.of(), + ) : this(accountToken, cardToken, created, eventType, tokenization, mutableMapOf()) + + /** + * Account token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accountToken(): String = accountToken.getRequired("account_token") + + /** + * Card token + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardToken(): String = cardToken.getRequired("card_token") + + /** + * Created date + * + * @throws LithicInvalidDataException if 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") + + /** + * 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") + + /** + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tokenization(): Tokenization = tokenization.getRequired("tokenization") + + /** + * Returns the raw JSON value of [accountToken]. + * + * Unlike [accountToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_token") + @ExcludeMissing + fun _accountToken(): JsonField = accountToken + + /** + * Returns the raw JSON value of [cardToken]. + * + * Unlike [cardToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_token") @ExcludeMissing fun _cardToken(): JsonField = cardToken + + /** + * Returns the raw JSON value of [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 [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 [tokenization]. + * + * Unlike [tokenization], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tokenization") + @ExcludeMissing + fun _tokenization(): JsonField = tokenization + + @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 + * [TokenizationUpdatedWebhookEvent]. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .tokenization() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenizationUpdatedWebhookEvent]. */ + class Builder internal constructor() { + + private var accountToken: JsonField? = null + private var cardToken: JsonField? = null + private var created: JsonField? = null + private var eventType: JsonField? = null + private var tokenization: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenizationUpdatedWebhookEvent: TokenizationUpdatedWebhookEvent) = + apply { + accountToken = tokenizationUpdatedWebhookEvent.accountToken + cardToken = tokenizationUpdatedWebhookEvent.cardToken + created = tokenizationUpdatedWebhookEvent.created + eventType = tokenizationUpdatedWebhookEvent.eventType + tokenization = tokenizationUpdatedWebhookEvent.tokenization + additionalProperties = + tokenizationUpdatedWebhookEvent.additionalProperties.toMutableMap() + } + + /** Account token */ + fun accountToken(accountToken: String) = accountToken(JsonField.of(accountToken)) + + /** + * Sets [Builder.accountToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accountToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountToken(accountToken: JsonField) = apply { + this.accountToken = accountToken + } + + /** Card token */ + fun cardToken(cardToken: String) = cardToken(JsonField.of(cardToken)) + + /** + * Sets [Builder.cardToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cardToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardToken(cardToken: JsonField) = apply { this.cardToken = cardToken } + + /** Created date */ + 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 } + + /** 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 tokenization(tokenization: Tokenization) = tokenization(JsonField.of(tokenization)) + + /** + * Sets [Builder.tokenization] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenization] with a well-typed [Tokenization] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tokenization(tokenization: JsonField) = apply { + this.tokenization = tokenization + } + + 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 [TokenizationUpdatedWebhookEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountToken() + * .cardToken() + * .created() + * .eventType() + * .tokenization() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenizationUpdatedWebhookEvent = + TokenizationUpdatedWebhookEvent( + checkRequired("accountToken", accountToken), + checkRequired("cardToken", cardToken), + checkRequired("created", created), + checkRequired("eventType", eventType), + checkRequired("tokenization", tokenization), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenizationUpdatedWebhookEvent = apply { + if (validated) { + return@apply + } + + accountToken() + cardToken() + created() + eventType().validate() + tokenization().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 (accountToken.asKnown().isPresent) 1 else 0) + + (if (cardToken.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (eventType.asKnown().getOrNull()?.validity() ?: 0) + + (tokenization.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 TOKENIZATION_UPDATED = of("tokenization.updated") + + @JvmStatic fun of(value: String) = EventType(JsonField.of(value)) + } + + /** An enum containing [EventType]'s known values. */ + enum class Known { + TOKENIZATION_UPDATED + } + + /** + * 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 { + TOKENIZATION_UPDATED, + /** + * 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) { + TOKENIZATION_UPDATED -> Value.TOKENIZATION_UPDATED + 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) { + TOKENIZATION_UPDATED -> Known.TOKENIZATION_UPDATED + 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 + + 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 TokenizationUpdatedWebhookEvent && + accountToken == other.accountToken && + cardToken == other.cardToken && + created == other.created && + eventType == other.eventType && + tokenization == other.tokenization && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountToken, + cardToken, + created, + eventType, + tokenization, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenizationUpdatedWebhookEvent{accountToken=$accountToken, cardToken=$cardToken, created=$created, eventType=$eventType, tokenization=$tokenization, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/WebhookServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/WebhookServiceAsync.kt index 92c5360a0..407346b24 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/WebhookServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/WebhookServiceAsync.kt @@ -2,12 +2,57 @@ package com.lithic.api.services.async +import com.lithic.api.core.ClientOptions import com.lithic.api.core.JsonValue import com.lithic.api.core.http.Headers +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.ParsedWebhookEvent +import java.util.function.Consumer interface WebhookServiceAsync { + /** + * 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): WebhookServiceAsync + fun unwrap(payload: String, headers: Headers, secret: String?): JsonValue fun verifySignature(payload: String, headers: Headers, secret: String?) + + /** + * Parses a webhook event and verifies the signtature. + * + * @throws LithicInvalidDataException if the body could not be parsed. + */ + fun parse(body: String, headers: Headers, secret: String?): ParsedWebhookEvent + + /** + * Parses a webhook event without validating the signature. + * + * @throws LithicInvalidDataException if the body could not be parsed. + */ + fun parseUnsafe(body: String): ParsedWebhookEvent + + /** + * A view of [WebhookServiceAsync] 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 + ): WebhookServiceAsync.WithRawResponse + } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/WebhookServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/WebhookServiceAsyncImpl.kt index be48f8577..f283ca688 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/WebhookServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/WebhookServiceAsyncImpl.kt @@ -5,18 +5,24 @@ package com.lithic.api.services.async import com.fasterxml.jackson.core.JsonProcessingException import com.lithic.api.core.ClientOptions import com.lithic.api.core.JsonValue -import com.lithic.api.core.getRequiredHeader import com.lithic.api.core.http.Headers import com.lithic.api.errors.LithicException -import java.security.MessageDigest -import java.time.Duration -import java.time.Instant -import java.util.Base64 -import javax.crypto.Mac -import javax.crypto.spec.SecretKeySpec -import kotlin.jvm.optionals.getOrNull +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.ParsedWebhookEvent +import com.lithic.api.services.blocking.WebhookServiceImpl +import java.util.function.Consumer -class WebhookServiceAsyncImpl(private val clientOptions: ClientOptions) : WebhookServiceAsync { +class WebhookServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookServiceAsync { + + private val withRawResponse: WebhookServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): WebhookServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WebhookServiceAsync = + WebhookServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) override fun unwrap(payload: String, headers: Headers, secret: String?): JsonValue { verifySignature(payload, headers, secret) @@ -28,59 +34,33 @@ class WebhookServiceAsyncImpl(private val clientOptions: ClientOptions) : Webhoo } override fun verifySignature(payload: String, headers: Headers, secret: String?) { - val webhookSecret = - secret - ?: clientOptions.webhookSecret().getOrNull() - ?: throw LithicException( - "The webhook secret must either be set using the env var, LITHIC_WEBHOOK_SECRET, on the client class, or passed to this method" - ) - - val whsecret = - try { - Base64.getDecoder().decode(webhookSecret.removePrefix("whsec_")) - } catch (e: RuntimeException) { - throw LithicException("Invalid webhook secret") - } - - val msgId = headers.getRequiredHeader("webhook-id") - val msgSignature = headers.getRequiredHeader("webhook-signature") - val msgTimestamp = headers.getRequiredHeader("webhook-timestamp") - - val timestamp = - try { - Instant.ofEpochSecond(msgTimestamp.toLong()) - } catch (e: RuntimeException) { - throw LithicException("Invalid signature headers", e) - } - val now = Instant.now(clientOptions.clock) - - if (timestamp.isBefore(now.minus(Duration.ofMinutes(5)))) { - throw LithicException("Webhook timestamp too old") - } - if (timestamp.isAfter(now.plus(Duration.ofMinutes(5)))) { - throw LithicException("Webhook timestamp too new") - } - - val mac = Mac.getInstance("HmacSHA256") - mac.init(SecretKeySpec(whsecret, "HmacSHA256")) - val expectedSignature = - mac.doFinal("$msgId.${timestamp.epochSecond}.$payload".toByteArray()) + WebhookServiceImpl(clientOptions).verifySignature(payload, headers, secret) + } - msgSignature.splitToSequence(" ").forEach { - val parts = it.split(",") - if (parts.size != 2) { - return@forEach - } + /** + * Parses a webhook event and verifies the signtature. + * + * @throws LithicInvalidDataException if the body could not be parsed. + */ + override fun parse(body: String, headers: Headers, secret: String?): ParsedWebhookEvent = + WebhookServiceImpl(clientOptions).parse(body, headers, secret) - if (parts[0] != "v1") { - return@forEach - } + /** + * Parses a webhook event without validating the signature. + * + * @throws LithicInvalidDataException if the body could not be parsed. + */ + override fun parseUnsafe(body: String): ParsedWebhookEvent = + WebhookServiceImpl(clientOptions).parseUnsafe(body) - if (MessageDigest.isEqual(Base64.getDecoder().decode(parts[1]), expectedSignature)) { - return - } - } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookServiceAsync.WithRawResponse { - throw LithicException("None of the given webhook signatures match the expected signature") + override fun withOptions( + modifier: Consumer + ): WebhookServiceAsync.WithRawResponse = + WebhookServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/WebhookService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/WebhookService.kt index 92aa8ace7..17e80d0dd 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/WebhookService.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/WebhookService.kt @@ -2,12 +2,53 @@ package com.lithic.api.services.blocking +import com.lithic.api.core.ClientOptions import com.lithic.api.core.JsonValue import com.lithic.api.core.http.Headers +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.ParsedWebhookEvent +import java.util.function.Consumer interface WebhookService { + /** + * 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): WebhookService + fun unwrap(payload: String, headers: Headers, secret: String?): JsonValue fun verifySignature(payload: String, headers: Headers, secret: String?) + + /** + * Parses a webhook event and verifies the signtature. + * + * @throws LithicInvalidDataException if the body could not be parsed. + */ + fun parse(body: String, headers: Headers, secret: String?): ParsedWebhookEvent + + /** + * Parses a webhook event without validating the signature. + * + * @throws LithicInvalidDataException if the body could not be parsed. + */ + fun parseUnsafe(body: String): ParsedWebhookEvent + + /** A view of [WebhookService] 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): WebhookService.WithRawResponse + } } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/WebhookServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/WebhookServiceImpl.kt index 1ee4df4c9..9b569841e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/WebhookServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/WebhookServiceImpl.kt @@ -3,20 +3,34 @@ package com.lithic.api.services.blocking import com.fasterxml.jackson.core.JsonProcessingException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.lithic.api.core.ClientOptions import com.lithic.api.core.JsonValue import com.lithic.api.core.getRequiredHeader import com.lithic.api.core.http.Headers import com.lithic.api.errors.LithicException +import com.lithic.api.errors.LithicInvalidDataException +import com.lithic.api.models.ParsedWebhookEvent import java.security.MessageDigest import java.time.Duration import java.time.Instant import java.util.Base64 +import java.util.function.Consumer import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec import kotlin.jvm.optionals.getOrNull -class WebhookServiceImpl(private val clientOptions: ClientOptions) : WebhookService { +class WebhookServiceImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookService { + + private val withRawResponse: WebhookService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): WebhookService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WebhookService = + WebhookServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) override fun unwrap(payload: String, headers: Headers, secret: String?): JsonValue { verifySignature(payload, headers, secret) @@ -83,4 +97,41 @@ class WebhookServiceImpl(private val clientOptions: ClientOptions) : WebhookServ throw LithicException("None of the given webhook signatures match the expected signature") } + + /** + * Unwraps a webhook event from its JSON representation. + * + * @throws LithicInvalidDataException if the body could not be parsed. + */ + override fun parse(body: String, headers: Headers, secret: String?): ParsedWebhookEvent { + verifySignature(body, headers, secret) + return try { + clientOptions.jsonMapper.readValue(body, jacksonTypeRef()) + } catch (e: Exception) { + throw LithicInvalidDataException("Error parsing body", e) + } + } + + /** + * Unwraps a webhook event from its JSON representation without verifying the signature. + * + * @throws LithicInvalidDataException if the body could not be parsed. + */ + override fun parseUnsafe(body: String): ParsedWebhookEvent = + try { + clientOptions.jsonMapper.readValue(body, jacksonTypeRef()) + } catch (e: Exception) { + throw LithicInvalidDataException("Error parsing body", e) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): WebhookService.WithRawResponse = + WebhookServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreatedWebhookEventTest.kt new file mode 100644 index 000000000..9cebd743e --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderCreatedWebhookEventTest.kt @@ -0,0 +1,84 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccountHolderCreatedWebhookEventTest { + + @Test + fun create() { + val accountHolderCreatedWebhookEvent = + AccountHolderCreatedWebhookEvent.builder() + .eventType(AccountHolderCreatedWebhookEvent.EventType.ACCOUNT_HOLDER_CREATED) + .token("00000000-0000-0000-0000-000000000001") + .accountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addRequiredDocument( + RequiredDocument.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addStatusReason("string") + .addValidDocument("string") + .build() + ) + .status(AccountHolderCreatedWebhookEvent.Status.ACCEPTED) + .addStatusReason("string") + .build() + + assertThat(accountHolderCreatedWebhookEvent.eventType()) + .isEqualTo(AccountHolderCreatedWebhookEvent.EventType.ACCOUNT_HOLDER_CREATED) + assertThat(accountHolderCreatedWebhookEvent.token()) + .contains("00000000-0000-0000-0000-000000000001") + assertThat(accountHolderCreatedWebhookEvent.accountToken()) + .contains("00000000-0000-0000-0000-000000000001") + assertThat(accountHolderCreatedWebhookEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(accountHolderCreatedWebhookEvent.requiredDocuments().getOrNull()) + .containsExactly( + RequiredDocument.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addStatusReason("string") + .addValidDocument("string") + .build() + ) + assertThat(accountHolderCreatedWebhookEvent.status()) + .contains(AccountHolderCreatedWebhookEvent.Status.ACCEPTED) + assertThat(accountHolderCreatedWebhookEvent.statusReason().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accountHolderCreatedWebhookEvent = + AccountHolderCreatedWebhookEvent.builder() + .eventType(AccountHolderCreatedWebhookEvent.EventType.ACCOUNT_HOLDER_CREATED) + .token("00000000-0000-0000-0000-000000000001") + .accountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addRequiredDocument( + RequiredDocument.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addStatusReason("string") + .addValidDocument("string") + .build() + ) + .status(AccountHolderCreatedWebhookEvent.Status.ACCEPTED) + .addStatusReason("string") + .build() + + val roundtrippedAccountHolderCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountHolderCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountHolderCreatedWebhookEvent) + .isEqualTo(accountHolderCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderDocumentUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderDocumentUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..8ad2721c1 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderDocumentUpdatedWebhookEventTest.kt @@ -0,0 +1,130 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccountHolderDocumentUpdatedWebhookEventTest { + + @Test + fun create() { + val accountHolderDocumentUpdatedWebhookEvent = + AccountHolderDocumentUpdatedWebhookEvent.builder() + .eventType( + AccountHolderDocumentUpdatedWebhookEvent.EventType + .ACCOUNT_HOLDER_DOCUMENT_UPDATED + ) + .token("9175a05c-a9da-4082-8e14-9296427ebba7") + .accountHolderToken("2b52494a-ae73-4ab1-97e8-2dd1d51d18b0") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .documentType(AccountHolderDocumentUpdatedWebhookEvent.DocumentType.DRIVERS_LICENSE) + .entityToken("c5f2d594-d957-4781-8877-fbea31f5944a") + .addRequiredDocumentUpload( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAcceptedEntityStatusReason("string") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .imageType( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .ImageType + .FRONT + ) + .addRejectedEntityStatusReason("string") + .status( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .DocumentUploadStatus + .ACCEPTED + ) + .addStatusReason("string") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + assertThat(accountHolderDocumentUpdatedWebhookEvent.eventType()) + .isEqualTo( + AccountHolderDocumentUpdatedWebhookEvent.EventType.ACCOUNT_HOLDER_DOCUMENT_UPDATED + ) + assertThat(accountHolderDocumentUpdatedWebhookEvent.token()) + .contains("9175a05c-a9da-4082-8e14-9296427ebba7") + assertThat(accountHolderDocumentUpdatedWebhookEvent.accountHolderToken()) + .contains("2b52494a-ae73-4ab1-97e8-2dd1d51d18b0") + assertThat(accountHolderDocumentUpdatedWebhookEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(accountHolderDocumentUpdatedWebhookEvent.documentType()) + .contains(AccountHolderDocumentUpdatedWebhookEvent.DocumentType.DRIVERS_LICENSE) + assertThat(accountHolderDocumentUpdatedWebhookEvent.entityToken()) + .contains("c5f2d594-d957-4781-8877-fbea31f5944a") + assertThat(accountHolderDocumentUpdatedWebhookEvent.requiredDocumentUploads().getOrNull()) + .containsExactly( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAcceptedEntityStatusReason("string") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .imageType( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload.ImageType + .FRONT + ) + .addRejectedEntityStatusReason("string") + .status( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .DocumentUploadStatus + .ACCEPTED + ) + .addStatusReason("string") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accountHolderDocumentUpdatedWebhookEvent = + AccountHolderDocumentUpdatedWebhookEvent.builder() + .eventType( + AccountHolderDocumentUpdatedWebhookEvent.EventType + .ACCOUNT_HOLDER_DOCUMENT_UPDATED + ) + .token("9175a05c-a9da-4082-8e14-9296427ebba7") + .accountHolderToken("2b52494a-ae73-4ab1-97e8-2dd1d51d18b0") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .documentType(AccountHolderDocumentUpdatedWebhookEvent.DocumentType.DRIVERS_LICENSE) + .entityToken("c5f2d594-d957-4781-8877-fbea31f5944a") + .addRequiredDocumentUpload( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAcceptedEntityStatusReason("string") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .imageType( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .ImageType + .FRONT + ) + .addRejectedEntityStatusReason("string") + .status( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .DocumentUploadStatus + .ACCEPTED + ) + .addStatusReason("string") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedAccountHolderDocumentUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountHolderDocumentUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountHolderDocumentUpdatedWebhookEvent) + .isEqualTo(accountHolderDocumentUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..648947d4c --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderUpdatedWebhookEventTest.kt @@ -0,0 +1,417 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class AccountHolderUpdatedWebhookEventTest { + + @Test + fun ofKybPayload() { + val kybPayload = + AccountHolderUpdatedWebhookEvent.KybPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .updateRequest( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest.builder() + .addBeneficialOwnerEntity( + KybBusinessEntity.builder() + .address( + KybBusinessEntity.Address.builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .addPhoneNumber("+15555555555") + .dbaBusinessName("dba_business_name") + .parentCompany("parent_company") + .build() + ) + .addBeneficialOwnerIndividual( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest.Individual + .builder() + .address( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest + .Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + KybBusinessEntity.builder() + .address( + KybBusinessEntity.Address.builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .addPhoneNumber("+15555555555") + .dbaBusinessName("dba_business_name") + .parentCompany("parent_company") + .build() + ) + .controlPerson( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest.Individual + .builder() + .address( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest + .Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .build() + ) + .eventType( + AccountHolderUpdatedWebhookEvent.KybPayload.EventType.ACCOUNT_HOLDER_UPDATED + ) + .externalId("external_id") + .natureOfBusiness("Software company selling solutions to the restaurant industry") + .websiteUrl("www.mybusiness.com") + .build() + + val accountHolderUpdatedWebhookEvent = + AccountHolderUpdatedWebhookEvent.ofKybPayload(kybPayload) + + assertThat(accountHolderUpdatedWebhookEvent.kybPayload()).contains(kybPayload) + assertThat(accountHolderUpdatedWebhookEvent.kycPayload()).isEmpty + assertThat(accountHolderUpdatedWebhookEvent.legacyPayload()).isEmpty + } + + @Test + fun ofKybPayloadRoundtrip() { + val jsonMapper = jsonMapper() + val accountHolderUpdatedWebhookEvent = + AccountHolderUpdatedWebhookEvent.ofKybPayload( + AccountHolderUpdatedWebhookEvent.KybPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .updateRequest( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest.builder() + .addBeneficialOwnerEntity( + KybBusinessEntity.builder() + .address( + KybBusinessEntity.Address.builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .addPhoneNumber("+15555555555") + .dbaBusinessName("dba_business_name") + .parentCompany("parent_company") + .build() + ) + .addBeneficialOwnerIndividual( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest.Individual + .builder() + .address( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest + .Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + KybBusinessEntity.builder() + .address( + KybBusinessEntity.Address.builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .addPhoneNumber("+15555555555") + .dbaBusinessName("dba_business_name") + .parentCompany("parent_company") + .build() + ) + .controlPerson( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest.Individual + .builder() + .address( + AccountHolderUpdatedWebhookEvent.KybPayload.UpdateRequest + .Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .build() + ) + .eventType( + AccountHolderUpdatedWebhookEvent.KybPayload.EventType.ACCOUNT_HOLDER_UPDATED + ) + .externalId("external_id") + .natureOfBusiness( + "Software company selling solutions to the restaurant industry" + ) + .websiteUrl("www.mybusiness.com") + .build() + ) + + val roundtrippedAccountHolderUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountHolderUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountHolderUpdatedWebhookEvent) + .isEqualTo(accountHolderUpdatedWebhookEvent) + } + + @Test + fun ofKycPayload() { + val kycPayload = + AccountHolderUpdatedWebhookEvent.KycPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .updateRequest( + AccountHolderUpdatedWebhookEvent.KycPayload.UpdateRequest.builder() + .individual( + AccountHolderUpdatedWebhookEvent.KycPayload.UpdateRequest.Individual + .builder() + .address( + AccountHolderUpdatedWebhookEvent.KycPayload.UpdateRequest + .Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .build() + ) + .eventType( + AccountHolderUpdatedWebhookEvent.KycPayload.EventType.ACCOUNT_HOLDER_UPDATED + ) + .externalId("external_id") + .build() + + val accountHolderUpdatedWebhookEvent = + AccountHolderUpdatedWebhookEvent.ofKycPayload(kycPayload) + + assertThat(accountHolderUpdatedWebhookEvent.kybPayload()).isEmpty + assertThat(accountHolderUpdatedWebhookEvent.kycPayload()).contains(kycPayload) + assertThat(accountHolderUpdatedWebhookEvent.legacyPayload()).isEmpty + } + + @Test + fun ofKycPayloadRoundtrip() { + val jsonMapper = jsonMapper() + val accountHolderUpdatedWebhookEvent = + AccountHolderUpdatedWebhookEvent.ofKycPayload( + AccountHolderUpdatedWebhookEvent.KycPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .updateRequest( + AccountHolderUpdatedWebhookEvent.KycPayload.UpdateRequest.builder() + .individual( + AccountHolderUpdatedWebhookEvent.KycPayload.UpdateRequest.Individual + .builder() + .address( + AccountHolderUpdatedWebhookEvent.KycPayload.UpdateRequest + .Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .build() + ) + .eventType( + AccountHolderUpdatedWebhookEvent.KycPayload.EventType.ACCOUNT_HOLDER_UPDATED + ) + .externalId("external_id") + .build() + ) + + val roundtrippedAccountHolderUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountHolderUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountHolderUpdatedWebhookEvent) + .isEqualTo(accountHolderUpdatedWebhookEvent) + } + + @Test + fun ofLegacyPayload() { + val legacyPayload = + AccountHolderUpdatedWebhookEvent.LegacyPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .businessAccountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("johnny@lithic.com") + .eventType( + AccountHolderUpdatedWebhookEvent.LegacyPayload.EventType.ACCOUNT_HOLDER_UPDATED + ) + .externalId("00000000-0000-0000-0000-000000000001") + .firstName("Johnny") + .lastName("Appleseed") + .legalBusinessName("Lithic") + .phoneNumber("+15555555555") + .build() + + val accountHolderUpdatedWebhookEvent = + AccountHolderUpdatedWebhookEvent.ofLegacyPayload(legacyPayload) + + assertThat(accountHolderUpdatedWebhookEvent.kybPayload()).isEmpty + assertThat(accountHolderUpdatedWebhookEvent.kycPayload()).isEmpty + assertThat(accountHolderUpdatedWebhookEvent.legacyPayload()).contains(legacyPayload) + } + + @Test + fun ofLegacyPayloadRoundtrip() { + val jsonMapper = jsonMapper() + val accountHolderUpdatedWebhookEvent = + AccountHolderUpdatedWebhookEvent.ofLegacyPayload( + AccountHolderUpdatedWebhookEvent.LegacyPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .businessAccountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("johnny@lithic.com") + .eventType( + AccountHolderUpdatedWebhookEvent.LegacyPayload.EventType + .ACCOUNT_HOLDER_UPDATED + ) + .externalId("00000000-0000-0000-0000-000000000001") + .firstName("Johnny") + .lastName("Appleseed") + .legalBusinessName("Lithic") + .phoneNumber("+15555555555") + .build() + ) + + val roundtrippedAccountHolderUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountHolderUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountHolderUpdatedWebhookEvent) + .isEqualTo(accountHolderUpdatedWebhookEvent) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val accountHolderUpdatedWebhookEvent = + jsonMapper() + .convertValue(testCase.value, jacksonTypeRef()) + + val e = + assertThrows { accountHolderUpdatedWebhookEvent.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderVerificationWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderVerificationWebhookEventTest.kt new file mode 100644 index 000000000..38f7d6647 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AccountHolderVerificationWebhookEventTest.kt @@ -0,0 +1,66 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccountHolderVerificationWebhookEventTest { + + @Test + fun create() { + val accountHolderVerificationWebhookEvent = + AccountHolderVerificationWebhookEvent.builder() + .eventType( + AccountHolderVerificationWebhookEvent.EventType.ACCOUNT_HOLDER_VERIFICATION + ) + .token("00000000-0000-0000-0000-000000000001") + .accountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(AccountHolderVerificationWebhookEvent.Status.ACCEPTED) + .addStatusReason("string") + .build() + + assertThat(accountHolderVerificationWebhookEvent.eventType()) + .isEqualTo(AccountHolderVerificationWebhookEvent.EventType.ACCOUNT_HOLDER_VERIFICATION) + assertThat(accountHolderVerificationWebhookEvent.token()) + .contains("00000000-0000-0000-0000-000000000001") + assertThat(accountHolderVerificationWebhookEvent.accountToken()) + .contains("00000000-0000-0000-0000-000000000001") + assertThat(accountHolderVerificationWebhookEvent.created()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(accountHolderVerificationWebhookEvent.status()) + .contains(AccountHolderVerificationWebhookEvent.Status.ACCEPTED) + assertThat(accountHolderVerificationWebhookEvent.statusReasons().getOrNull()) + .containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accountHolderVerificationWebhookEvent = + AccountHolderVerificationWebhookEvent.builder() + .eventType( + AccountHolderVerificationWebhookEvent.EventType.ACCOUNT_HOLDER_VERIFICATION + ) + .token("00000000-0000-0000-0000-000000000001") + .accountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(AccountHolderVerificationWebhookEvent.Status.ACCEPTED) + .addStatusReason("string") + .build() + + val roundtrippedAccountHolderVerificationWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accountHolderVerificationWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccountHolderVerificationWebhookEvent) + .isEqualTo(accountHolderVerificationWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AsaRequestWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AsaRequestWebhookEventTest.kt new file mode 100644 index 000000000..75c2f78fe --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AsaRequestWebhookEventTest.kt @@ -0,0 +1,487 @@ +// 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 AsaRequestWebhookEventTest { + + @Test + fun create() { + val asaRequestWebhookEvent = + AsaRequestWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .authorizationAmount(0L) + .avs( + AsaRequestWebhookEvent.Avs.builder() + .address("address") + .addressOnFileMatch(AsaRequestWebhookEvent.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + AsaRequestWebhookEvent.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hostname("hostname") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + AsaRequestWebhookEvent.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(AsaRequestWebhookEvent.AsaRequestCard.State.CLOSED) + .type(AsaRequestWebhookEvent.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .settledAmount(0L) + .status(AsaRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(AsaRequestWebhookEvent.TransactionInitiator.CARDHOLDER) + .accountType(AsaRequestWebhookEvent.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( + AsaRequestWebhookEvent.AsaRequestFleetInfo.builder() + .fleetPromptCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + AsaRequestWebhookEvent.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(AsaRequestWebhookEvent.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(AsaRequestWebhookEvent.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + AsaRequestWebhookEvent.AsaNetworkSpecificData.builder() + .mastercard( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + AsaRequestWebhookEvent.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + AsaRequestWebhookEvent.Pos.builder() + .entryMode( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.builder() + .card( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Card.PRESENT + ) + .cardholder( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.Operator + .ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.PinCapability.CAPABLE + ) + .type(AsaRequestWebhookEvent.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId(" r 0K9tW") + .build() + ) + .build() + ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(asaRequestWebhookEvent.token()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(asaRequestWebhookEvent.acquirerFee()).isEqualTo(0L) + assertThat(asaRequestWebhookEvent.amount()).isEqualTo(0L) + assertThat(asaRequestWebhookEvent.authorizationAmount()).isEqualTo(0L) + assertThat(asaRequestWebhookEvent.avs()) + .isEqualTo( + AsaRequestWebhookEvent.Avs.builder() + .address("address") + .addressOnFileMatch(AsaRequestWebhookEvent.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + assertThat(asaRequestWebhookEvent.card()) + .isEqualTo( + AsaRequestWebhookEvent.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hostname("hostname") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + AsaRequestWebhookEvent.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(AsaRequestWebhookEvent.AsaRequestCard.State.CLOSED) + .type(AsaRequestWebhookEvent.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + assertThat(asaRequestWebhookEvent.cardholderCurrency()).isEqualTo("cardholder_currency") + assertThat(asaRequestWebhookEvent.cashAmount()).isEqualTo(0L) + assertThat(asaRequestWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(asaRequestWebhookEvent.merchant()) + .isEqualTo( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + assertThat(asaRequestWebhookEvent.merchantAmount()).isEqualTo(0L) + assertThat(asaRequestWebhookEvent.merchantCurrency()).isEqualTo("USD") + assertThat(asaRequestWebhookEvent.settledAmount()).isEqualTo(0L) + assertThat(asaRequestWebhookEvent.status()) + .isEqualTo(AsaRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) + assertThat(asaRequestWebhookEvent.transactionInitiator()) + .isEqualTo(AsaRequestWebhookEvent.TransactionInitiator.CARDHOLDER) + assertThat(asaRequestWebhookEvent.accountType()) + .contains(AsaRequestWebhookEvent.AccountType.CHECKING) + assertThat(asaRequestWebhookEvent.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(asaRequestWebhookEvent.cashback()).contains(0L) + assertThat(asaRequestWebhookEvent.conversionRate()).contains(0.0) + assertThat(asaRequestWebhookEvent.eventToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(asaRequestWebhookEvent.fleetInfo()) + .contains( + AsaRequestWebhookEvent.AsaRequestFleetInfo.builder() + .fleetPromptCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + assertThat(asaRequestWebhookEvent.latestChallenge()) + .contains( + AsaRequestWebhookEvent.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(AsaRequestWebhookEvent.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(asaRequestWebhookEvent.network()).contains(AsaRequestWebhookEvent.Network.AMEX) + assertThat(asaRequestWebhookEvent.networkRiskScore()).contains(0L) + assertThat(asaRequestWebhookEvent.networkSpecificData()) + .contains( + AsaRequestWebhookEvent.AsaNetworkSpecificData.builder() + .mastercard( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + AsaRequestWebhookEvent.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + assertThat(asaRequestWebhookEvent.pos()) + .contains( + AsaRequestWebhookEvent.Pos.builder() + .entryMode( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.builder() + .card(AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Card.PRESENT) + .cardholder( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan(AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY) + .pinEntered(true) + .build() + ) + .terminal( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.Operator.ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.PinCapability.CAPABLE + ) + .type(AsaRequestWebhookEvent.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId(" r 0K9tW") + .build() + ) + .build() + ) + assertThat(asaRequestWebhookEvent.tokenInfo()) + .contains(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + assertThat(asaRequestWebhookEvent.ttl()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val asaRequestWebhookEvent = + AsaRequestWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .authorizationAmount(0L) + .avs( + AsaRequestWebhookEvent.Avs.builder() + .address("address") + .addressOnFileMatch(AsaRequestWebhookEvent.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + AsaRequestWebhookEvent.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hostname("hostname") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + AsaRequestWebhookEvent.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(AsaRequestWebhookEvent.AsaRequestCard.State.CLOSED) + .type(AsaRequestWebhookEvent.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .settledAmount(0L) + .status(AsaRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(AsaRequestWebhookEvent.TransactionInitiator.CARDHOLDER) + .accountType(AsaRequestWebhookEvent.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( + AsaRequestWebhookEvent.AsaRequestFleetInfo.builder() + .fleetPromptCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + AsaRequestWebhookEvent.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(AsaRequestWebhookEvent.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(AsaRequestWebhookEvent.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + AsaRequestWebhookEvent.AsaNetworkSpecificData.builder() + .mastercard( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + AsaRequestWebhookEvent.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + AsaRequestWebhookEvent.Pos.builder() + .entryMode( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.builder() + .card( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Card.PRESENT + ) + .cardholder( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.Operator + .ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.PinCapability.CAPABLE + ) + .type(AsaRequestWebhookEvent.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId(" r 0K9tW") + .build() + ) + .build() + ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedAsaRequestWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(asaRequestWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAsaRequestWebhookEvent).isEqualTo(asaRequestWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRulesBacktestReportCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRulesBacktestReportCreatedWebhookEventTest.kt new file mode 100644 index 000000000..3b2be4c8f --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRulesBacktestReportCreatedWebhookEventTest.kt @@ -0,0 +1,185 @@ +// 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 AuthRulesBacktestReportCreatedWebhookEventTest { + + @Test + fun create() { + val authRulesBacktestReportCreatedWebhookEvent = + AuthRulesBacktestReportCreatedWebhookEvent.builder() + .backtestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .results( + BacktestResults.Results.builder() + .currentVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .version(0L) + .build() + ) + .draftVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .version(0L) + .build() + ) + .build() + ) + .simulationParameters( + BacktestResults.SimulationParameters.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType( + AuthRulesBacktestReportCreatedWebhookEvent.EventType + .AUTH_RULES_BACKTEST_REPORT_CREATED + ) + .build() + + assertThat(authRulesBacktestReportCreatedWebhookEvent.backtestToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(authRulesBacktestReportCreatedWebhookEvent.results()) + .isEqualTo( + BacktestResults.Results.builder() + .currentVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .version(0L) + .build() + ) + .draftVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .version(0L) + .build() + ) + .build() + ) + assertThat(authRulesBacktestReportCreatedWebhookEvent.simulationParameters()) + .isEqualTo( + BacktestResults.SimulationParameters.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(authRulesBacktestReportCreatedWebhookEvent.eventType()) + .isEqualTo( + AuthRulesBacktestReportCreatedWebhookEvent.EventType + .AUTH_RULES_BACKTEST_REPORT_CREATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val authRulesBacktestReportCreatedWebhookEvent = + AuthRulesBacktestReportCreatedWebhookEvent.builder() + .backtestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .results( + BacktestResults.Results.builder() + .currentVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .version(0L) + .build() + ) + .draftVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .version(0L) + .build() + ) + .build() + ) + .simulationParameters( + BacktestResults.SimulationParameters.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType( + AuthRulesBacktestReportCreatedWebhookEvent.EventType + .AUTH_RULES_BACKTEST_REPORT_CREATED + ) + .build() + + val roundtrippedAuthRulesBacktestReportCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(authRulesBacktestReportCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAuthRulesBacktestReportCreatedWebhookEvent) + .isEqualTo(authRulesBacktestReportCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BalanceUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BalanceUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..2f0b2e94c --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BalanceUpdatedWebhookEventTest.kt @@ -0,0 +1,83 @@ +// 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 BalanceUpdatedWebhookEventTest { + + @Test + fun create() { + val balanceUpdatedWebhookEvent = + BalanceUpdatedWebhookEvent.builder() + .addData( + FinancialAccountBalance.builder() + .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .availableAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .totalAmount(0L) + .type(FinancialAccountBalance.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType(BalanceUpdatedWebhookEvent.EventType.BALANCE_UPDATED) + .build() + + assertThat(balanceUpdatedWebhookEvent.data()) + .containsExactly( + FinancialAccountBalance.builder() + .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .availableAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .totalAmount(0L) + .type(FinancialAccountBalance.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(balanceUpdatedWebhookEvent.eventType()) + .isEqualTo(BalanceUpdatedWebhookEvent.EventType.BALANCE_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val balanceUpdatedWebhookEvent = + BalanceUpdatedWebhookEvent.builder() + .addData( + FinancialAccountBalance.builder() + .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .availableAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .totalAmount(0L) + .type(FinancialAccountBalance.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType(BalanceUpdatedWebhookEvent.EventType.BALANCE_UPDATED) + .build() + + val roundtrippedBalanceUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(balanceUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBalanceUpdatedWebhookEvent).isEqualTo(balanceUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferTransactionCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferTransactionCreatedWebhookEventTest.kt new file mode 100644 index 000000000..2401a2940 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferTransactionCreatedWebhookEventTest.kt @@ -0,0 +1,195 @@ +// 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 BookTransferTransactionCreatedWebhookEventTest { + + @Test + fun create() { + val bookTransferTransactionCreatedWebhookEvent = + BookTransferTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_BALANCE_INQUIRY + ) + .build() + ) + .family(BookTransferResponse.Family.TRANSFER) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result(BookTransferResponse.TransactionResult.APPROVED) + .settledAmount(500L) + .status(BookTransferResponse.TransactionStatus.PENDING) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .eventType( + BookTransferTransactionCreatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_CREATED + ) + .build() + + assertThat(bookTransferTransactionCreatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bookTransferTransactionCreatedWebhookEvent.category()) + .isEqualTo(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + assertThat(bookTransferTransactionCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bookTransferTransactionCreatedWebhookEvent.currency()).isEqualTo("USD") + assertThat(bookTransferTransactionCreatedWebhookEvent.events()) + .containsExactly( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults.APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType.ATM_BALANCE_INQUIRY + ) + .build() + ) + assertThat(bookTransferTransactionCreatedWebhookEvent.family()) + .isEqualTo(BookTransferResponse.Family.TRANSFER) + assertThat(bookTransferTransactionCreatedWebhookEvent.fromFinancialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bookTransferTransactionCreatedWebhookEvent.pendingAmount()).isEqualTo(1000L) + assertThat(bookTransferTransactionCreatedWebhookEvent.result()) + .isEqualTo(BookTransferResponse.TransactionResult.APPROVED) + assertThat(bookTransferTransactionCreatedWebhookEvent.settledAmount()).isEqualTo(500L) + assertThat(bookTransferTransactionCreatedWebhookEvent.status()) + .isEqualTo(BookTransferResponse.TransactionStatus.PENDING) + assertThat(bookTransferTransactionCreatedWebhookEvent.toFinancialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bookTransferTransactionCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bookTransferTransactionCreatedWebhookEvent.externalId()).contains("external_id") + assertThat(bookTransferTransactionCreatedWebhookEvent.externalResource()) + .contains( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + assertThat(bookTransferTransactionCreatedWebhookEvent.transactionSeries()) + .contains( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + assertThat(bookTransferTransactionCreatedWebhookEvent.eventType()) + .isEqualTo( + BookTransferTransactionCreatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_CREATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bookTransferTransactionCreatedWebhookEvent = + BookTransferTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_BALANCE_INQUIRY + ) + .build() + ) + .family(BookTransferResponse.Family.TRANSFER) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result(BookTransferResponse.TransactionResult.APPROVED) + .settledAmount(500L) + .status(BookTransferResponse.TransactionStatus.PENDING) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .eventType( + BookTransferTransactionCreatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_CREATED + ) + .build() + + val roundtrippedBookTransferTransactionCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bookTransferTransactionCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBookTransferTransactionCreatedWebhookEvent) + .isEqualTo(bookTransferTransactionCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferTransactionUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferTransactionUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..ab0dcd736 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BookTransferTransactionUpdatedWebhookEventTest.kt @@ -0,0 +1,195 @@ +// 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 BookTransferTransactionUpdatedWebhookEventTest { + + @Test + fun create() { + val bookTransferTransactionUpdatedWebhookEvent = + BookTransferTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_BALANCE_INQUIRY + ) + .build() + ) + .family(BookTransferResponse.Family.TRANSFER) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result(BookTransferResponse.TransactionResult.APPROVED) + .settledAmount(500L) + .status(BookTransferResponse.TransactionStatus.PENDING) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .eventType( + BookTransferTransactionUpdatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_UPDATED + ) + .build() + + assertThat(bookTransferTransactionUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bookTransferTransactionUpdatedWebhookEvent.category()) + .isEqualTo(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + assertThat(bookTransferTransactionUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bookTransferTransactionUpdatedWebhookEvent.currency()).isEqualTo("USD") + assertThat(bookTransferTransactionUpdatedWebhookEvent.events()) + .containsExactly( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults.APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType.ATM_BALANCE_INQUIRY + ) + .build() + ) + assertThat(bookTransferTransactionUpdatedWebhookEvent.family()) + .isEqualTo(BookTransferResponse.Family.TRANSFER) + assertThat(bookTransferTransactionUpdatedWebhookEvent.fromFinancialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bookTransferTransactionUpdatedWebhookEvent.pendingAmount()).isEqualTo(1000L) + assertThat(bookTransferTransactionUpdatedWebhookEvent.result()) + .isEqualTo(BookTransferResponse.TransactionResult.APPROVED) + assertThat(bookTransferTransactionUpdatedWebhookEvent.settledAmount()).isEqualTo(500L) + assertThat(bookTransferTransactionUpdatedWebhookEvent.status()) + .isEqualTo(BookTransferResponse.TransactionStatus.PENDING) + assertThat(bookTransferTransactionUpdatedWebhookEvent.toFinancialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(bookTransferTransactionUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(bookTransferTransactionUpdatedWebhookEvent.externalId()).contains("external_id") + assertThat(bookTransferTransactionUpdatedWebhookEvent.externalResource()) + .contains( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + assertThat(bookTransferTransactionUpdatedWebhookEvent.transactionSeries()) + .contains( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + assertThat(bookTransferTransactionUpdatedWebhookEvent.eventType()) + .isEqualTo( + BookTransferTransactionUpdatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_UPDATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bookTransferTransactionUpdatedWebhookEvent = + BookTransferTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_BALANCE_INQUIRY + ) + .build() + ) + .family(BookTransferResponse.Family.TRANSFER) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result(BookTransferResponse.TransactionResult.APPROVED) + .settledAmount(500L) + .status(BookTransferResponse.TransactionStatus.PENDING) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .eventType( + BookTransferTransactionUpdatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_UPDATED + ) + .build() + + val roundtrippedBookTransferTransactionUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bookTransferTransactionUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBookTransferTransactionUpdatedWebhookEvent) + .isEqualTo(bookTransferTransactionUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardConvertedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardConvertedWebhookEventTest.kt new file mode 100644 index 000000000..933b3b982 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardConvertedWebhookEventTest.kt @@ -0,0 +1,43 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardConvertedWebhookEventTest { + + @Test + fun create() { + val cardConvertedWebhookEvent = + CardConvertedWebhookEvent.builder() + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardConvertedWebhookEvent.EventType.CARD_CONVERTED) + .build() + + assertThat(cardConvertedWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(cardConvertedWebhookEvent.eventType()) + .isEqualTo(CardConvertedWebhookEvent.EventType.CARD_CONVERTED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardConvertedWebhookEvent = + CardConvertedWebhookEvent.builder() + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardConvertedWebhookEvent.EventType.CARD_CONVERTED) + .build() + + val roundtrippedCardConvertedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardConvertedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardConvertedWebhookEvent).isEqualTo(cardConvertedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreatedWebhookEventTest.kt new file mode 100644 index 000000000..9429334d9 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardCreatedWebhookEventTest.kt @@ -0,0 +1,47 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardCreatedWebhookEventTest { + + @Test + fun create() { + val cardCreatedWebhookEvent = + CardCreatedWebhookEvent.builder() + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardCreatedWebhookEvent.EventType.CARD_CREATED) + .replacementFor("00000000-0000-0000-0000-000000000000") + .build() + + assertThat(cardCreatedWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(cardCreatedWebhookEvent.eventType()) + .isEqualTo(CardCreatedWebhookEvent.EventType.CARD_CREATED) + assertThat(cardCreatedWebhookEvent.replacementFor()) + .contains("00000000-0000-0000-0000-000000000000") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardCreatedWebhookEvent = + CardCreatedWebhookEvent.builder() + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardCreatedWebhookEvent.EventType.CARD_CREATED) + .replacementFor("00000000-0000-0000-0000-000000000000") + .build() + + val roundtrippedCardCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardCreatedWebhookEvent).isEqualTo(cardCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardReissuedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardReissuedWebhookEventTest.kt new file mode 100644 index 000000000..4b7704ba5 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardReissuedWebhookEventTest.kt @@ -0,0 +1,43 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardReissuedWebhookEventTest { + + @Test + fun create() { + val cardReissuedWebhookEvent = + CardReissuedWebhookEvent.builder() + .eventType(CardReissuedWebhookEvent.EventType.CARD_REISSUED) + .cardToken("00000000-0000-0000-0000-000000000001") + .build() + + assertThat(cardReissuedWebhookEvent.eventType()) + .isEqualTo(CardReissuedWebhookEvent.EventType.CARD_REISSUED) + assertThat(cardReissuedWebhookEvent.cardToken()) + .contains("00000000-0000-0000-0000-000000000001") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardReissuedWebhookEvent = + CardReissuedWebhookEvent.builder() + .eventType(CardReissuedWebhookEvent.EventType.CARD_REISSUED) + .cardToken("00000000-0000-0000-0000-000000000001") + .build() + + val roundtrippedCardReissuedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardReissuedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardReissuedWebhookEvent).isEqualTo(cardReissuedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardRenewedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardRenewedWebhookEventTest.kt new file mode 100644 index 000000000..313556baa --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardRenewedWebhookEventTest.kt @@ -0,0 +1,55 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardRenewedWebhookEventTest { + + @Test + fun create() { + val cardRenewedWebhookEvent = + CardRenewedWebhookEvent.builder() + .eventType(CardRenewedWebhookEvent.EventType.CARD_RENEWED) + .cardToken("00000000-0000-0000-0000-000000000001") + .expMonth("01") + .expYear("2030") + .previousExpMonth("01") + .previousExpYear("2024") + .build() + + assertThat(cardRenewedWebhookEvent.eventType()) + .isEqualTo(CardRenewedWebhookEvent.EventType.CARD_RENEWED) + assertThat(cardRenewedWebhookEvent.cardToken()) + .contains("00000000-0000-0000-0000-000000000001") + assertThat(cardRenewedWebhookEvent.expMonth()).contains("01") + assertThat(cardRenewedWebhookEvent.expYear()).contains("2030") + assertThat(cardRenewedWebhookEvent.previousExpMonth()).contains("01") + assertThat(cardRenewedWebhookEvent.previousExpYear()).contains("2024") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardRenewedWebhookEvent = + CardRenewedWebhookEvent.builder() + .eventType(CardRenewedWebhookEvent.EventType.CARD_RENEWED) + .cardToken("00000000-0000-0000-0000-000000000001") + .expMonth("01") + .expYear("2030") + .previousExpMonth("01") + .previousExpYear("2024") + .build() + + val roundtrippedCardRenewedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardRenewedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardRenewedWebhookEvent).isEqualTo(cardRenewedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardShippedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardShippedWebhookEventTest.kt new file mode 100644 index 000000000..6c5596ba0 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardShippedWebhookEventTest.kt @@ -0,0 +1,58 @@ +// 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 org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardShippedWebhookEventTest { + + @Test + fun create() { + val cardShippedWebhookEvent = + CardShippedWebhookEvent.builder() + .bulkOrderToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardShippedWebhookEvent.EventType.CARD_SHIPPED) + .shippingMethod( + CardShippedWebhookEvent.ShippingMethod.USPS_WITHOUT_TRACKING_ENVELOPE + ) + .trackingNumber("1Z9999999999999999") + .build() + + assertThat(cardShippedWebhookEvent.bulkOrderToken()) + .contains("00000000-0000-0000-0000-000000000002") + assertThat(cardShippedWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(cardShippedWebhookEvent.eventType()) + .isEqualTo(CardShippedWebhookEvent.EventType.CARD_SHIPPED) + assertThat(cardShippedWebhookEvent.shippingMethod()) + .isEqualTo(CardShippedWebhookEvent.ShippingMethod.USPS_WITHOUT_TRACKING_ENVELOPE) + assertThat(cardShippedWebhookEvent.trackingNumber()).contains("1Z9999999999999999") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardShippedWebhookEvent = + CardShippedWebhookEvent.builder() + .bulkOrderToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardShippedWebhookEvent.EventType.CARD_SHIPPED) + .shippingMethod( + CardShippedWebhookEvent.ShippingMethod.USPS_WITHOUT_TRACKING_ENVELOPE + ) + .trackingNumber("1Z9999999999999999") + .build() + + val roundtrippedCardShippedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardShippedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardShippedWebhookEvent).isEqualTo(cardShippedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionEnhancedDataCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionEnhancedDataCreatedWebhookEventTest.kt new file mode 100644 index 000000000..2a1b571d5 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionEnhancedDataCreatedWebhookEventTest.kt @@ -0,0 +1,207 @@ +// 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.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTransactionEnhancedDataCreatedWebhookEventTest { + + @Test + fun create() { + val cardTransactionEnhancedDataCreatedWebhookEvent = + CardTransactionEnhancedDataCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .common( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt( + EnhancedData.CommonData.TaxData.TaxExemptIndicator.TAX_INCLUDED + ) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFleet( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure( + EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS + ) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType( + CardTransactionEnhancedDataCreatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_CREATED + ) + .build() + + assertThat(cardTransactionEnhancedDataCreatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardTransactionEnhancedDataCreatedWebhookEvent.common()) + .isEqualTo( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt(EnhancedData.CommonData.TaxData.TaxExemptIndicator.TAX_INCLUDED) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + assertThat(cardTransactionEnhancedDataCreatedWebhookEvent.eventToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardTransactionEnhancedDataCreatedWebhookEvent.fleet()) + .containsExactly( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure(EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + assertThat(cardTransactionEnhancedDataCreatedWebhookEvent.transactionToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardTransactionEnhancedDataCreatedWebhookEvent.eventType()) + .isEqualTo( + CardTransactionEnhancedDataCreatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_CREATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardTransactionEnhancedDataCreatedWebhookEvent = + CardTransactionEnhancedDataCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .common( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt( + EnhancedData.CommonData.TaxData.TaxExemptIndicator.TAX_INCLUDED + ) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFleet( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure( + EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS + ) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType( + CardTransactionEnhancedDataCreatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_CREATED + ) + .build() + + val roundtrippedCardTransactionEnhancedDataCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardTransactionEnhancedDataCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardTransactionEnhancedDataCreatedWebhookEvent) + .isEqualTo(cardTransactionEnhancedDataCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionEnhancedDataUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionEnhancedDataUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..c377868f0 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionEnhancedDataUpdatedWebhookEventTest.kt @@ -0,0 +1,207 @@ +// 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.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTransactionEnhancedDataUpdatedWebhookEventTest { + + @Test + fun create() { + val cardTransactionEnhancedDataUpdatedWebhookEvent = + CardTransactionEnhancedDataUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .common( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt( + EnhancedData.CommonData.TaxData.TaxExemptIndicator.TAX_INCLUDED + ) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFleet( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure( + EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS + ) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType( + CardTransactionEnhancedDataUpdatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_UPDATED + ) + .build() + + assertThat(cardTransactionEnhancedDataUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardTransactionEnhancedDataUpdatedWebhookEvent.common()) + .isEqualTo( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt(EnhancedData.CommonData.TaxData.TaxExemptIndicator.TAX_INCLUDED) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + assertThat(cardTransactionEnhancedDataUpdatedWebhookEvent.eventToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardTransactionEnhancedDataUpdatedWebhookEvent.fleet()) + .containsExactly( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure(EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + assertThat(cardTransactionEnhancedDataUpdatedWebhookEvent.transactionToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(cardTransactionEnhancedDataUpdatedWebhookEvent.eventType()) + .isEqualTo( + CardTransactionEnhancedDataUpdatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_UPDATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardTransactionEnhancedDataUpdatedWebhookEvent = + CardTransactionEnhancedDataUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .common( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt( + EnhancedData.CommonData.TaxData.TaxExemptIndicator.TAX_INCLUDED + ) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFleet( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure( + EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS + ) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType( + CardTransactionEnhancedDataUpdatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_UPDATED + ) + .build() + + val roundtrippedCardTransactionEnhancedDataUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardTransactionEnhancedDataUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardTransactionEnhancedDataUpdatedWebhookEvent) + .isEqualTo(cardTransactionEnhancedDataUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..abfc1db79 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/CardTransactionUpdatedWebhookEventTest.kt @@ -0,0 +1,684 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardTransactionUpdatedWebhookEventTest { + + @Test + fun create() { + val cardTransactionUpdatedWebhookEvent = + CardTransactionUpdatedWebhookEvent.builder() + .token("c30c2182-1e69-4e0d-b40f-eec0d2a19123") + .accountToken("db3942f0-0627-4887-a190-1ea83b46d091") + .acquirerFee(0L) + .acquirerReferenceNumber(null) + .amount(1800L) + .amounts( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(-1800L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(1800L) + .authorizationCode("071471") + .avs( + Transaction.Avs.builder() + .address("123 Evergreen Terrace") + .zipcode("95006") + .build() + ) + .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) + .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .financialAccountToken("a3b113e8-01fe-42d3-b900-b9adf3f15496") + .merchant( + Merchant.builder() + .acceptorId("452322000053360") + .acquiringInstitutionId("333301802529120") + .city("gosq.com") + .country("USA") + .descriptor("SQ *SOMA EATS") + .mcc("5812") + .state("CA") + .build() + ) + .merchantAmount(1800L) + .merchantAuthorizationAmount(1800L) + .merchantCurrency("USD") + .network(Transaction.Network.MASTERCARD) + .networkRiskScore(5L) + .pos( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder(Transaction.Pos.PosEntryMode.Cardholder.NOT_PRESENT) + .pan(Transaction.Pos.PosEntryMode.Pan.ECOMMERCE) + .pinEntered(false) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(false) + .cardRetentionCapable(false) + .onPremise(false) + .operator(Transaction.Pos.PosTerminal.Operator.UNKNOWN) + .partialApprovalCapable(false) + .pinCapability( + Transaction.Pos.PosTerminal.PinCapability.NOT_CAPABLE + ) + .type(Transaction.Pos.PosTerminal.Type.UNKNOWN) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + .result(Transaction.DeclineResult.APPROVED) + .settledAmount(0L) + .status(Transaction.Status.PENDING) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addEvent( + Transaction.TransactionEvent.builder() + .token("bbbf1e86-322d-11ee-9779-00505685a123") + .amount(1800L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts.Cardholder + .builder() + .amount(1800L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts.Merchant + .builder() + .amount(1800L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts.Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber(null) + .retrievalReferenceNumber("064386558597") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard.builder() + .banknetReferenceNumber("U1HSCJ") + .originalBanknetReferenceNumber(null) + .originalSwitchSerialNumber(null) + .switchSerialNumber(null) + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result( + Transaction.TransactionEvent.RuleResult.DetailedResult.APPROVED + ) + .build() + ) + .type(Transaction.TransactionEvent.Type.AUTHORIZATION) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + .eventType(CardTransactionUpdatedWebhookEvent.EventType.CARD_TRANSACTION_UPDATED) + .build() + + assertThat(cardTransactionUpdatedWebhookEvent.token()) + .isEqualTo("c30c2182-1e69-4e0d-b40f-eec0d2a19123") + assertThat(cardTransactionUpdatedWebhookEvent.accountToken()) + .isEqualTo("db3942f0-0627-4887-a190-1ea83b46d091") + assertThat(cardTransactionUpdatedWebhookEvent.acquirerFee()).contains(0L) + assertThat(cardTransactionUpdatedWebhookEvent.acquirerReferenceNumber()).isEmpty + assertThat(cardTransactionUpdatedWebhookEvent.amount()).isEqualTo(1800L) + assertThat(cardTransactionUpdatedWebhookEvent.amounts()) + .isEqualTo( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(-1800L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + assertThat(cardTransactionUpdatedWebhookEvent.authorizationAmount()).contains(1800L) + assertThat(cardTransactionUpdatedWebhookEvent.authorizationCode()).contains("071471") + assertThat(cardTransactionUpdatedWebhookEvent.avs()) + .contains( + Transaction.Avs.builder().address("123 Evergreen Terrace").zipcode("95006").build() + ) + assertThat(cardTransactionUpdatedWebhookEvent.cardToken()) + .isEqualTo("aac502f9-aecc-458a-954e-4bcf6edb6123") + assertThat(cardTransactionUpdatedWebhookEvent.cardholderAuthentication()) + .contains( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) + .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") + .build() + ) + assertThat(cardTransactionUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + assertThat(cardTransactionUpdatedWebhookEvent.financialAccountToken()) + .contains("a3b113e8-01fe-42d3-b900-b9adf3f15496") + assertThat(cardTransactionUpdatedWebhookEvent.merchant()) + .isEqualTo( + Merchant.builder() + .acceptorId("452322000053360") + .acquiringInstitutionId("333301802529120") + .city("gosq.com") + .country("USA") + .descriptor("SQ *SOMA EATS") + .mcc("5812") + .state("CA") + .build() + ) + assertThat(cardTransactionUpdatedWebhookEvent.merchantAmount()).contains(1800L) + assertThat(cardTransactionUpdatedWebhookEvent.merchantAuthorizationAmount()).contains(1800L) + assertThat(cardTransactionUpdatedWebhookEvent.merchantCurrency()).isEqualTo("USD") + assertThat(cardTransactionUpdatedWebhookEvent.network()) + .contains(Transaction.Network.MASTERCARD) + assertThat(cardTransactionUpdatedWebhookEvent.networkRiskScore()).contains(5L) + assertThat(cardTransactionUpdatedWebhookEvent.pos()) + .isEqualTo( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder(Transaction.Pos.PosEntryMode.Cardholder.NOT_PRESENT) + .pan(Transaction.Pos.PosEntryMode.Pan.ECOMMERCE) + .pinEntered(false) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(false) + .cardRetentionCapable(false) + .onPremise(false) + .operator(Transaction.Pos.PosTerminal.Operator.UNKNOWN) + .partialApprovalCapable(false) + .pinCapability(Transaction.Pos.PosTerminal.PinCapability.NOT_CAPABLE) + .type(Transaction.Pos.PosTerminal.Type.UNKNOWN) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + assertThat(cardTransactionUpdatedWebhookEvent.result()) + .isEqualTo(Transaction.DeclineResult.APPROVED) + assertThat(cardTransactionUpdatedWebhookEvent.settledAmount()).isEqualTo(0L) + assertThat(cardTransactionUpdatedWebhookEvent.status()) + .isEqualTo(Transaction.Status.PENDING) + assertThat(cardTransactionUpdatedWebhookEvent.tokenInfo()) + .contains(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + assertThat(cardTransactionUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + assertThat(cardTransactionUpdatedWebhookEvent.events().getOrNull()) + .containsExactly( + Transaction.TransactionEvent.builder() + .token("bbbf1e86-322d-11ee-9779-00505685a123") + .amount(1800L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts.Cardholder + .builder() + .amount(1800L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts.Merchant + .builder() + .amount(1800L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts.Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber(null) + .retrievalReferenceNumber("064386558597") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard.builder() + .banknetReferenceNumber("U1HSCJ") + .originalBanknetReferenceNumber(null) + .originalSwitchSerialNumber(null) + .switchSerialNumber(null) + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(Transaction.TransactionEvent.RuleResult.DetailedResult.APPROVED) + .build() + ) + .type(Transaction.TransactionEvent.Type.AUTHORIZATION) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + assertThat(cardTransactionUpdatedWebhookEvent.eventType()) + .isEqualTo(CardTransactionUpdatedWebhookEvent.EventType.CARD_TRANSACTION_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardTransactionUpdatedWebhookEvent = + CardTransactionUpdatedWebhookEvent.builder() + .token("c30c2182-1e69-4e0d-b40f-eec0d2a19123") + .accountToken("db3942f0-0627-4887-a190-1ea83b46d091") + .acquirerFee(0L) + .acquirerReferenceNumber(null) + .amount(1800L) + .amounts( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(-1800L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(1800L) + .authorizationCode("071471") + .avs( + Transaction.Avs.builder() + .address("123 Evergreen Terrace") + .zipcode("95006") + .build() + ) + .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) + .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .financialAccountToken("a3b113e8-01fe-42d3-b900-b9adf3f15496") + .merchant( + Merchant.builder() + .acceptorId("452322000053360") + .acquiringInstitutionId("333301802529120") + .city("gosq.com") + .country("USA") + .descriptor("SQ *SOMA EATS") + .mcc("5812") + .state("CA") + .build() + ) + .merchantAmount(1800L) + .merchantAuthorizationAmount(1800L) + .merchantCurrency("USD") + .network(Transaction.Network.MASTERCARD) + .networkRiskScore(5L) + .pos( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder(Transaction.Pos.PosEntryMode.Cardholder.NOT_PRESENT) + .pan(Transaction.Pos.PosEntryMode.Pan.ECOMMERCE) + .pinEntered(false) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(false) + .cardRetentionCapable(false) + .onPremise(false) + .operator(Transaction.Pos.PosTerminal.Operator.UNKNOWN) + .partialApprovalCapable(false) + .pinCapability( + Transaction.Pos.PosTerminal.PinCapability.NOT_CAPABLE + ) + .type(Transaction.Pos.PosTerminal.Type.UNKNOWN) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + .result(Transaction.DeclineResult.APPROVED) + .settledAmount(0L) + .status(Transaction.Status.PENDING) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addEvent( + Transaction.TransactionEvent.builder() + .token("bbbf1e86-322d-11ee-9779-00505685a123") + .amount(1800L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts.Cardholder + .builder() + .amount(1800L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts.Merchant + .builder() + .amount(1800L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts.Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber(null) + .retrievalReferenceNumber("064386558597") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard.builder() + .banknetReferenceNumber("U1HSCJ") + .originalBanknetReferenceNumber(null) + .originalSwitchSerialNumber(null) + .switchSerialNumber(null) + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result( + Transaction.TransactionEvent.RuleResult.DetailedResult.APPROVED + ) + .build() + ) + .type(Transaction.TransactionEvent.Type.AUTHORIZATION) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + .eventType(CardTransactionUpdatedWebhookEvent.EventType.CARD_TRANSACTION_UPDATED) + .build() + + val roundtrippedCardTransactionUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardTransactionUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardTransactionUpdatedWebhookEvent) + .isEqualTo(cardTransactionUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationApprovalRequestWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationApprovalRequestWebhookEventTest.kt new file mode 100644 index 000000000..e8d47b559 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationApprovalRequestWebhookEventTest.kt @@ -0,0 +1,302 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DigitalWalletTokenizationApprovalRequestWebhookEventTest { + + @Test + fun create() { + val digitalWalletTokenizationApprovalRequestWebhookEvent = + DigitalWalletTokenizationApprovalRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerTokenizationDecision( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .builder() + .outcome( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + .eventType( + DigitalWalletTokenizationApprovalRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision( + DigitalWalletTokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED + ) + .tokenizationChannel( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationChannel + .DIGITAL_WALLET + ) + .tokenizationToken("tokenization_token") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .tokenizationSource( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationSource + .PUSH_PROVISION + ) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .build() + + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat( + digitalWalletTokenizationApprovalRequestWebhookEvent.customerTokenizationDecision() + ) + .contains( + DigitalWalletTokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision + .builder() + .outcome( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.eventType()) + .isEqualTo( + DigitalWalletTokenizationApprovalRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.issuerDecision()) + .isEqualTo(DigitalWalletTokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED) + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.tokenizationChannel()) + .isEqualTo( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationChannel + .DIGITAL_WALLET + ) + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.tokenizationToken()) + .isEqualTo("tokenization_token") + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.walletDecisioningInfo()) + .isEqualTo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.device()) + .contains( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + assertThat( + digitalWalletTokenizationApprovalRequestWebhookEvent.digitalWalletTokenMetadata() + ) + .contains( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.ruleResults().getOrNull()) + .containsExactly( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + assertThat( + digitalWalletTokenizationApprovalRequestWebhookEvent + .tokenizationDeclineReasons() + .getOrNull() + ) + .containsExactly(TokenizationDeclineReason.ACCOUNT_SCORE_1) + assertThat(digitalWalletTokenizationApprovalRequestWebhookEvent.tokenizationSource()) + .contains( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationSource + .PUSH_PROVISION + ) + assertThat( + digitalWalletTokenizationApprovalRequestWebhookEvent + .tokenizationTfaReasons() + .getOrNull() + ) + .containsExactly(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val digitalWalletTokenizationApprovalRequestWebhookEvent = + DigitalWalletTokenizationApprovalRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerTokenizationDecision( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .builder() + .outcome( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + .eventType( + DigitalWalletTokenizationApprovalRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision( + DigitalWalletTokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED + ) + .tokenizationChannel( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationChannel + .DIGITAL_WALLET + ) + .tokenizationToken("tokenization_token") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .tokenizationSource( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationSource + .PUSH_PROVISION + ) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .build() + + val roundtrippedDigitalWalletTokenizationApprovalRequestWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(digitalWalletTokenizationApprovalRequestWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDigitalWalletTokenizationApprovalRequestWebhookEvent) + .isEqualTo(digitalWalletTokenizationApprovalRequestWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationResultWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationResultWebhookEventTest.kt new file mode 100644 index 000000000..8a74c75a0 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationResultWebhookEventTest.kt @@ -0,0 +1,148 @@ +// 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 DigitalWalletTokenizationResultWebhookEventTest { + + @Test + fun create() { + val digitalWalletTokenizationResultWebhookEvent = + DigitalWalletTokenizationResultWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationResultWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_RESULT + ) + .tokenizationResultDetails( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + assertThat(digitalWalletTokenizationResultWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(digitalWalletTokenizationResultWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(digitalWalletTokenizationResultWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + assertThat(digitalWalletTokenizationResultWebhookEvent.eventType()) + .isEqualTo( + DigitalWalletTokenizationResultWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_RESULT + ) + assertThat(digitalWalletTokenizationResultWebhookEvent.tokenizationResultDetails()) + .isEqualTo( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + assertThat(digitalWalletTokenizationResultWebhookEvent.tokenizationToken()) + .isEqualTo("00000000-0000-0000-0000-000000000003") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val digitalWalletTokenizationResultWebhookEvent = + DigitalWalletTokenizationResultWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationResultWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_RESULT + ) + .tokenizationResultDetails( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val roundtrippedDigitalWalletTokenizationResultWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(digitalWalletTokenizationResultWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDigitalWalletTokenizationResultWebhookEvent) + .isEqualTo(digitalWalletTokenizationResultWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEventTest.kt new file mode 100644 index 000000000..2524b0a4e --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEventTest.kt @@ -0,0 +1,118 @@ +// 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 DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEventTest { + + @Test + fun create() { + val digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + assertThat( + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.accountToken() + ) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat( + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .activationMethod() + ) + .isEqualTo( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + assertThat(digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + assertThat(digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.eventType()) + .isEqualTo( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + assertThat( + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .tokenizationToken() + ) + .isEqualTo("00000000-0000-0000-0000-000000000003") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val roundtrippedDigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ), + jacksonTypeRef< + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + >(), + ) + + assertThat(roundtrippedDigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent) + .isEqualTo(digitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEventTest.kt new file mode 100644 index 000000000..f214cc227 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEventTest.kt @@ -0,0 +1,118 @@ +// 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 DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEventTest { + + @Test + fun create() { + val digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent = + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .authenticationCode("123456") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + assertThat(digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat( + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.activationMethod() + ) + .isEqualTo( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + assertThat( + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .authenticationCode() + ) + .isEqualTo("123456") + assertThat(digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + assertThat(digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.eventType()) + .isEqualTo( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + assertThat( + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.tokenizationToken() + ) + .isEqualTo("00000000-0000-0000-0000-000000000003") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent = + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .authenticationCode("123456") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val roundtrippedDigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent) + .isEqualTo(digitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..f30c15a0c --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DigitalWalletTokenizationUpdatedWebhookEventTest.kt @@ -0,0 +1,182 @@ +// 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 DigitalWalletTokenizationUpdatedWebhookEventTest { + + @Test + fun create() { + val digitalWalletTokenizationUpdatedWebhookEvent = + DigitalWalletTokenizationUpdatedWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationUpdatedWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_UPDATED + ) + .tokenization( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason( + TokenizationDeclineReason.ACCOUNT_SCORE_1 + ) + .addTokenizationTfaReason( + TokenizationTfaReason.WALLET_RECOMMENDED_TFA + ) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + .build() + + assertThat(digitalWalletTokenizationUpdatedWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(digitalWalletTokenizationUpdatedWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(digitalWalletTokenizationUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + assertThat(digitalWalletTokenizationUpdatedWebhookEvent.eventType()) + .isEqualTo( + DigitalWalletTokenizationUpdatedWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_UPDATED + ) + assertThat(digitalWalletTokenizationUpdatedWebhookEvent.tokenization()) + .isEqualTo( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val digitalWalletTokenizationUpdatedWebhookEvent = + DigitalWalletTokenizationUpdatedWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationUpdatedWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_UPDATED + ) + .tokenization( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason( + TokenizationDeclineReason.ACCOUNT_SCORE_1 + ) + .addTokenizationTfaReason( + TokenizationTfaReason.WALLET_RECOMMENDED_TFA + ) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + .build() + + val roundtrippedDigitalWalletTokenizationUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(digitalWalletTokenizationUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDigitalWalletTokenizationUpdatedWebhookEvent) + .isEqualTo(digitalWalletTokenizationUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeEvidenceUploadFailedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeEvidenceUploadFailedWebhookEventTest.kt new file mode 100644 index 000000000..a52cc3ff8 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeEvidenceUploadFailedWebhookEventTest.kt @@ -0,0 +1,72 @@ +// 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 DisputeEvidenceUploadFailedWebhookEventTest { + + @Test + fun create() { + val disputeEvidenceUploadFailedWebhookEvent = + DisputeEvidenceUploadFailedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .uploadStatus(DisputeEvidence.UploadStatus.DELETED) + .downloadUrl("download_url") + .filename("filename") + .uploadUrl("upload_url") + .eventType( + DisputeEvidenceUploadFailedWebhookEvent.EventType.DISPUTE_EVIDENCE_UPLOAD_FAILED + ) + .build() + + assertThat(disputeEvidenceUploadFailedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeEvidenceUploadFailedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeEvidenceUploadFailedWebhookEvent.disputeToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeEvidenceUploadFailedWebhookEvent.uploadStatus()) + .isEqualTo(DisputeEvidence.UploadStatus.DELETED) + assertThat(disputeEvidenceUploadFailedWebhookEvent.downloadUrl()).contains("download_url") + assertThat(disputeEvidenceUploadFailedWebhookEvent.filename()).contains("filename") + assertThat(disputeEvidenceUploadFailedWebhookEvent.uploadUrl()).contains("upload_url") + assertThat(disputeEvidenceUploadFailedWebhookEvent.eventType()) + .isEqualTo( + DisputeEvidenceUploadFailedWebhookEvent.EventType.DISPUTE_EVIDENCE_UPLOAD_FAILED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val disputeEvidenceUploadFailedWebhookEvent = + DisputeEvidenceUploadFailedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .uploadStatus(DisputeEvidence.UploadStatus.DELETED) + .downloadUrl("download_url") + .filename("filename") + .uploadUrl("upload_url") + .eventType( + DisputeEvidenceUploadFailedWebhookEvent.EventType.DISPUTE_EVIDENCE_UPLOAD_FAILED + ) + .build() + + val roundtrippedDisputeEvidenceUploadFailedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(disputeEvidenceUploadFailedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDisputeEvidenceUploadFailedWebhookEvent) + .isEqualTo(disputeEvidenceUploadFailedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeTransactionCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeTransactionCreatedWebhookEventTest.kt new file mode 100644 index 000000000..5fe301bfe --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeTransactionCreatedWebhookEventTest.kt @@ -0,0 +1,218 @@ +// 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 DisputeTransactionCreatedWebhookEventTest { + + @Test + fun create() { + val disputeTransactionCreatedWebhookEvent = + DisputeTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .caseId("case_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .disposition(DisputeV2.Disposition.WON) + .addEvent( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition(DisputeV2.Event.Data.WorkflowEventData.Disposition.WON) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + .liabilityAllocation( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .network(DisputeV2.Network.VISA) + .status(DisputeV2.Status.OPEN) + .transactionSeries( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + DisputeTransactionCreatedWebhookEvent.EventType.DISPUTE_TRANSACTION_CREATED + ) + .build() + + assertThat(disputeTransactionCreatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeTransactionCreatedWebhookEvent.accountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeTransactionCreatedWebhookEvent.cardToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeTransactionCreatedWebhookEvent.caseId()).contains("case_id") + assertThat(disputeTransactionCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeTransactionCreatedWebhookEvent.currency()).isEqualTo("USD") + assertThat(disputeTransactionCreatedWebhookEvent.disposition()) + .contains(DisputeV2.Disposition.WON) + assertThat(disputeTransactionCreatedWebhookEvent.events()) + .containsExactly( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition(DisputeV2.Event.Data.WorkflowEventData.Disposition.WON) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + assertThat(disputeTransactionCreatedWebhookEvent.liabilityAllocation()) + .isEqualTo( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + assertThat(disputeTransactionCreatedWebhookEvent.merchant()) + .isEqualTo( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + assertThat(disputeTransactionCreatedWebhookEvent.network()) + .isEqualTo(DisputeV2.Network.VISA) + assertThat(disputeTransactionCreatedWebhookEvent.status()).contains(DisputeV2.Status.OPEN) + assertThat(disputeTransactionCreatedWebhookEvent.transactionSeries()) + .contains( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + assertThat(disputeTransactionCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeTransactionCreatedWebhookEvent.eventType()) + .isEqualTo(DisputeTransactionCreatedWebhookEvent.EventType.DISPUTE_TRANSACTION_CREATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val disputeTransactionCreatedWebhookEvent = + DisputeTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .caseId("case_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .disposition(DisputeV2.Disposition.WON) + .addEvent( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition(DisputeV2.Event.Data.WorkflowEventData.Disposition.WON) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + .liabilityAllocation( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .network(DisputeV2.Network.VISA) + .status(DisputeV2.Status.OPEN) + .transactionSeries( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + DisputeTransactionCreatedWebhookEvent.EventType.DISPUTE_TRANSACTION_CREATED + ) + .build() + + val roundtrippedDisputeTransactionCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(disputeTransactionCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDisputeTransactionCreatedWebhookEvent) + .isEqualTo(disputeTransactionCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeTransactionUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeTransactionUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..c080d6411 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeTransactionUpdatedWebhookEventTest.kt @@ -0,0 +1,218 @@ +// 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 DisputeTransactionUpdatedWebhookEventTest { + + @Test + fun create() { + val disputeTransactionUpdatedWebhookEvent = + DisputeTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .caseId("case_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .disposition(DisputeV2.Disposition.WON) + .addEvent( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition(DisputeV2.Event.Data.WorkflowEventData.Disposition.WON) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + .liabilityAllocation( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .network(DisputeV2.Network.VISA) + .status(DisputeV2.Status.OPEN) + .transactionSeries( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + DisputeTransactionUpdatedWebhookEvent.EventType.DISPUTE_TRANSACTION_UPDATED + ) + .build() + + assertThat(disputeTransactionUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeTransactionUpdatedWebhookEvent.accountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeTransactionUpdatedWebhookEvent.cardToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeTransactionUpdatedWebhookEvent.caseId()).contains("case_id") + assertThat(disputeTransactionUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeTransactionUpdatedWebhookEvent.currency()).isEqualTo("USD") + assertThat(disputeTransactionUpdatedWebhookEvent.disposition()) + .contains(DisputeV2.Disposition.WON) + assertThat(disputeTransactionUpdatedWebhookEvent.events()) + .containsExactly( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition(DisputeV2.Event.Data.WorkflowEventData.Disposition.WON) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + assertThat(disputeTransactionUpdatedWebhookEvent.liabilityAllocation()) + .isEqualTo( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + assertThat(disputeTransactionUpdatedWebhookEvent.merchant()) + .isEqualTo( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + assertThat(disputeTransactionUpdatedWebhookEvent.network()) + .isEqualTo(DisputeV2.Network.VISA) + assertThat(disputeTransactionUpdatedWebhookEvent.status()).contains(DisputeV2.Status.OPEN) + assertThat(disputeTransactionUpdatedWebhookEvent.transactionSeries()) + .contains( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + assertThat(disputeTransactionUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeTransactionUpdatedWebhookEvent.eventType()) + .isEqualTo(DisputeTransactionUpdatedWebhookEvent.EventType.DISPUTE_TRANSACTION_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val disputeTransactionUpdatedWebhookEvent = + DisputeTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .caseId("case_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .disposition(DisputeV2.Disposition.WON) + .addEvent( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition(DisputeV2.Event.Data.WorkflowEventData.Disposition.WON) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + .liabilityAllocation( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .network(DisputeV2.Network.VISA) + .status(DisputeV2.Status.OPEN) + .transactionSeries( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + DisputeTransactionUpdatedWebhookEvent.EventType.DISPUTE_TRANSACTION_UPDATED + ) + .build() + + val roundtrippedDisputeTransactionUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(disputeTransactionUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDisputeTransactionUpdatedWebhookEvent) + .isEqualTo(disputeTransactionUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..e97626cac --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/DisputeUpdatedWebhookEventTest.kt @@ -0,0 +1,107 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DisputeUpdatedWebhookEventTest { + + @Test + fun create() { + val disputeUpdatedWebhookEvent = + DisputeUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .arbitrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerFiledDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerNote("customer_note") + .addNetworkClaimId("string") + .networkFiledDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkReasonCode("network_reason_code") + .prearbitrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .primaryClaimId("primary_claim_id") + .reason(Dispute.Reason.ATM_CASH_MISDISPENSE) + .representmentDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resolutionDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resolutionNote("resolution_note") + .resolutionReason(Dispute.ResolutionReason.CASE_LOST) + .status(Dispute.Status.ARBITRATION) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType(DisputeUpdatedWebhookEvent.EventType.DISPUTE_UPDATED) + .build() + + assertThat(disputeUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeUpdatedWebhookEvent.amount()).isEqualTo(0L) + assertThat(disputeUpdatedWebhookEvent.arbitrationDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeUpdatedWebhookEvent.customerFiledDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeUpdatedWebhookEvent.customerNote()).contains("customer_note") + assertThat(disputeUpdatedWebhookEvent.networkClaimIds().getOrNull()) + .containsExactly("string") + assertThat(disputeUpdatedWebhookEvent.networkFiledDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeUpdatedWebhookEvent.networkReasonCode()).contains("network_reason_code") + assertThat(disputeUpdatedWebhookEvent.prearbitrationDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeUpdatedWebhookEvent.primaryClaimId()).contains("primary_claim_id") + assertThat(disputeUpdatedWebhookEvent.reason()) + .isEqualTo(Dispute.Reason.ATM_CASH_MISDISPENSE) + assertThat(disputeUpdatedWebhookEvent.representmentDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeUpdatedWebhookEvent.resolutionDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(disputeUpdatedWebhookEvent.resolutionNote()).contains("resolution_note") + assertThat(disputeUpdatedWebhookEvent.resolutionReason()) + .contains(Dispute.ResolutionReason.CASE_LOST) + assertThat(disputeUpdatedWebhookEvent.status()).isEqualTo(Dispute.Status.ARBITRATION) + assertThat(disputeUpdatedWebhookEvent.transactionToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(disputeUpdatedWebhookEvent.eventType()) + .isEqualTo(DisputeUpdatedWebhookEvent.EventType.DISPUTE_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val disputeUpdatedWebhookEvent = + DisputeUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .arbitrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerFiledDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerNote("customer_note") + .addNetworkClaimId("string") + .networkFiledDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkReasonCode("network_reason_code") + .prearbitrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .primaryClaimId("primary_claim_id") + .reason(Dispute.Reason.ATM_CASH_MISDISPENSE) + .representmentDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resolutionDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resolutionNote("resolution_note") + .resolutionReason(Dispute.ResolutionReason.CASE_LOST) + .status(Dispute.Status.ARBITRATION) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType(DisputeUpdatedWebhookEvent.EventType.DISPUTE_UPDATED) + .build() + + val roundtrippedDisputeUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(disputeUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDisputeUpdatedWebhookEvent).isEqualTo(disputeUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountCreatedWebhookEventTest.kt new file mode 100644 index 000000000..6ef90db1a --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountCreatedWebhookEventTest.kt @@ -0,0 +1,156 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExternalBankAccountCreatedWebhookEventTest { + + @Test + fun create() { + val externalBankAccountCreatedWebhookEvent = + ExternalBankAccountCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .country("country") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastFour("last_four") + .owner("owner") + .ownerType(OwnerType.INDIVIDUAL) + .routingNumber("routing_number") + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) + .verificationAttempts(0L) + .verificationMethod(VerificationMethod.MANUAL) + .verificationState(ExternalBankAccount.VerificationState.PENDING) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + .companyId("company_id") + .dob(LocalDate.parse("2019-12-27")) + .doingBusinessAs("doing_business_as") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .userDefinedId("user_defined_id") + .verificationFailedReason("verification_failed_reason") + .eventType( + ExternalBankAccountCreatedWebhookEvent.EventType.EXTERNAL_BANK_ACCOUNT_CREATED + ) + .build() + + assertThat(externalBankAccountCreatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalBankAccountCreatedWebhookEvent.country()).isEqualTo("country") + assertThat(externalBankAccountCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(externalBankAccountCreatedWebhookEvent.currency()).isEqualTo("currency") + assertThat(externalBankAccountCreatedWebhookEvent.lastFour()).isEqualTo("last_four") + assertThat(externalBankAccountCreatedWebhookEvent.owner()).isEqualTo("owner") + assertThat(externalBankAccountCreatedWebhookEvent.ownerType()) + .isEqualTo(OwnerType.INDIVIDUAL) + assertThat(externalBankAccountCreatedWebhookEvent.routingNumber()) + .isEqualTo("routing_number") + assertThat(externalBankAccountCreatedWebhookEvent.state()) + .isEqualTo(ExternalBankAccount.State.ENABLED) + assertThat(externalBankAccountCreatedWebhookEvent.type()) + .isEqualTo(ExternalBankAccount.AccountType.CHECKING) + assertThat(externalBankAccountCreatedWebhookEvent.verificationAttempts()).isEqualTo(0L) + assertThat(externalBankAccountCreatedWebhookEvent.verificationMethod()) + .isEqualTo(VerificationMethod.MANUAL) + assertThat(externalBankAccountCreatedWebhookEvent.verificationState()) + .isEqualTo(ExternalBankAccount.VerificationState.PENDING) + assertThat(externalBankAccountCreatedWebhookEvent.accountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalBankAccountCreatedWebhookEvent.address()) + .contains( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + assertThat(externalBankAccountCreatedWebhookEvent.companyId()).contains("company_id") + assertThat(externalBankAccountCreatedWebhookEvent.dob()) + .contains(LocalDate.parse("2019-12-27")) + assertThat(externalBankAccountCreatedWebhookEvent.doingBusinessAs()) + .contains("doing_business_as") + assertThat(externalBankAccountCreatedWebhookEvent.financialAccountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalBankAccountCreatedWebhookEvent.name()).contains("name") + assertThat(externalBankAccountCreatedWebhookEvent.userDefinedId()) + .contains("user_defined_id") + assertThat(externalBankAccountCreatedWebhookEvent.verificationFailedReason()) + .contains("verification_failed_reason") + assertThat(externalBankAccountCreatedWebhookEvent.eventType()) + .isEqualTo( + ExternalBankAccountCreatedWebhookEvent.EventType.EXTERNAL_BANK_ACCOUNT_CREATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val externalBankAccountCreatedWebhookEvent = + ExternalBankAccountCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .country("country") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastFour("last_four") + .owner("owner") + .ownerType(OwnerType.INDIVIDUAL) + .routingNumber("routing_number") + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) + .verificationAttempts(0L) + .verificationMethod(VerificationMethod.MANUAL) + .verificationState(ExternalBankAccount.VerificationState.PENDING) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + .companyId("company_id") + .dob(LocalDate.parse("2019-12-27")) + .doingBusinessAs("doing_business_as") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .userDefinedId("user_defined_id") + .verificationFailedReason("verification_failed_reason") + .eventType( + ExternalBankAccountCreatedWebhookEvent.EventType.EXTERNAL_BANK_ACCOUNT_CREATED + ) + .build() + + val roundtrippedExternalBankAccountCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(externalBankAccountCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExternalBankAccountCreatedWebhookEvent) + .isEqualTo(externalBankAccountCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..420d170e8 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalBankAccountUpdatedWebhookEventTest.kt @@ -0,0 +1,156 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExternalBankAccountUpdatedWebhookEventTest { + + @Test + fun create() { + val externalBankAccountUpdatedWebhookEvent = + ExternalBankAccountUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .country("country") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastFour("last_four") + .owner("owner") + .ownerType(OwnerType.INDIVIDUAL) + .routingNumber("routing_number") + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) + .verificationAttempts(0L) + .verificationMethod(VerificationMethod.MANUAL) + .verificationState(ExternalBankAccount.VerificationState.PENDING) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + .companyId("company_id") + .dob(LocalDate.parse("2019-12-27")) + .doingBusinessAs("doing_business_as") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .userDefinedId("user_defined_id") + .verificationFailedReason("verification_failed_reason") + .eventType( + ExternalBankAccountUpdatedWebhookEvent.EventType.EXTERNAL_BANK_ACCOUNT_UPDATED + ) + .build() + + assertThat(externalBankAccountUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalBankAccountUpdatedWebhookEvent.country()).isEqualTo("country") + assertThat(externalBankAccountUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(externalBankAccountUpdatedWebhookEvent.currency()).isEqualTo("currency") + assertThat(externalBankAccountUpdatedWebhookEvent.lastFour()).isEqualTo("last_four") + assertThat(externalBankAccountUpdatedWebhookEvent.owner()).isEqualTo("owner") + assertThat(externalBankAccountUpdatedWebhookEvent.ownerType()) + .isEqualTo(OwnerType.INDIVIDUAL) + assertThat(externalBankAccountUpdatedWebhookEvent.routingNumber()) + .isEqualTo("routing_number") + assertThat(externalBankAccountUpdatedWebhookEvent.state()) + .isEqualTo(ExternalBankAccount.State.ENABLED) + assertThat(externalBankAccountUpdatedWebhookEvent.type()) + .isEqualTo(ExternalBankAccount.AccountType.CHECKING) + assertThat(externalBankAccountUpdatedWebhookEvent.verificationAttempts()).isEqualTo(0L) + assertThat(externalBankAccountUpdatedWebhookEvent.verificationMethod()) + .isEqualTo(VerificationMethod.MANUAL) + assertThat(externalBankAccountUpdatedWebhookEvent.verificationState()) + .isEqualTo(ExternalBankAccount.VerificationState.PENDING) + assertThat(externalBankAccountUpdatedWebhookEvent.accountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalBankAccountUpdatedWebhookEvent.address()) + .contains( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + assertThat(externalBankAccountUpdatedWebhookEvent.companyId()).contains("company_id") + assertThat(externalBankAccountUpdatedWebhookEvent.dob()) + .contains(LocalDate.parse("2019-12-27")) + assertThat(externalBankAccountUpdatedWebhookEvent.doingBusinessAs()) + .contains("doing_business_as") + assertThat(externalBankAccountUpdatedWebhookEvent.financialAccountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalBankAccountUpdatedWebhookEvent.name()).contains("name") + assertThat(externalBankAccountUpdatedWebhookEvent.userDefinedId()) + .contains("user_defined_id") + assertThat(externalBankAccountUpdatedWebhookEvent.verificationFailedReason()) + .contains("verification_failed_reason") + assertThat(externalBankAccountUpdatedWebhookEvent.eventType()) + .isEqualTo( + ExternalBankAccountUpdatedWebhookEvent.EventType.EXTERNAL_BANK_ACCOUNT_UPDATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val externalBankAccountUpdatedWebhookEvent = + ExternalBankAccountUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .country("country") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastFour("last_four") + .owner("owner") + .ownerType(OwnerType.INDIVIDUAL) + .routingNumber("routing_number") + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) + .verificationAttempts(0L) + .verificationMethod(VerificationMethod.MANUAL) + .verificationState(ExternalBankAccount.VerificationState.PENDING) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + .companyId("company_id") + .dob(LocalDate.parse("2019-12-27")) + .doingBusinessAs("doing_business_as") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .userDefinedId("user_defined_id") + .verificationFailedReason("verification_failed_reason") + .eventType( + ExternalBankAccountUpdatedWebhookEvent.EventType.EXTERNAL_BANK_ACCOUNT_UPDATED + ) + .build() + + val roundtrippedExternalBankAccountUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(externalBankAccountUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExternalBankAccountUpdatedWebhookEvent) + .isEqualTo(externalBankAccountUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCreatedWebhookEventTest.kt new file mode 100644 index 000000000..e7b266238 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentCreatedWebhookEventTest.kt @@ -0,0 +1,143 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExternalPaymentCreatedWebhookEventTest { + + @Test + fun create() { + val externalPaymentCreatedWebhookEvent = + ExternalPaymentCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .family(ExternalPayment.Family.EXTERNAL_PAYMENT) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .eventType(ExternalPaymentCreatedWebhookEvent.EventType.EXTERNAL_PAYMENT_CREATED) + .build() + + assertThat(externalPaymentCreatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalPaymentCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(externalPaymentCreatedWebhookEvent.status()) + .isEqualTo(ExternalPayment.TransactionStatus.PENDING) + assertThat(externalPaymentCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(externalPaymentCreatedWebhookEvent.category()) + .contains(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + assertThat(externalPaymentCreatedWebhookEvent.currency()).contains("currency") + assertThat(externalPaymentCreatedWebhookEvent.events().getOrNull()) + .containsExactly( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + assertThat(externalPaymentCreatedWebhookEvent.family()) + .contains(ExternalPayment.Family.EXTERNAL_PAYMENT) + assertThat(externalPaymentCreatedWebhookEvent.financialAccountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalPaymentCreatedWebhookEvent.paymentType()) + .contains(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + assertThat(externalPaymentCreatedWebhookEvent.pendingAmount()).contains(0L) + assertThat(externalPaymentCreatedWebhookEvent.result()) + .contains(ExternalPayment.TransactionResult.APPROVED) + assertThat(externalPaymentCreatedWebhookEvent.settledAmount()).contains(0L) + assertThat(externalPaymentCreatedWebhookEvent.userDefinedId()).contains("user_defined_id") + assertThat(externalPaymentCreatedWebhookEvent.eventType()) + .isEqualTo(ExternalPaymentCreatedWebhookEvent.EventType.EXTERNAL_PAYMENT_CREATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val externalPaymentCreatedWebhookEvent = + ExternalPaymentCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .family(ExternalPayment.Family.EXTERNAL_PAYMENT) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .eventType(ExternalPaymentCreatedWebhookEvent.EventType.EXTERNAL_PAYMENT_CREATED) + .build() + + val roundtrippedExternalPaymentCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(externalPaymentCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExternalPaymentCreatedWebhookEvent) + .isEqualTo(externalPaymentCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..bd4f19bdd --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ExternalPaymentUpdatedWebhookEventTest.kt @@ -0,0 +1,143 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExternalPaymentUpdatedWebhookEventTest { + + @Test + fun create() { + val externalPaymentUpdatedWebhookEvent = + ExternalPaymentUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .family(ExternalPayment.Family.EXTERNAL_PAYMENT) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .eventType(ExternalPaymentUpdatedWebhookEvent.EventType.EXTERNAL_PAYMENT_UPDATED) + .build() + + assertThat(externalPaymentUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalPaymentUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(externalPaymentUpdatedWebhookEvent.status()) + .isEqualTo(ExternalPayment.TransactionStatus.PENDING) + assertThat(externalPaymentUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(externalPaymentUpdatedWebhookEvent.category()) + .contains(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + assertThat(externalPaymentUpdatedWebhookEvent.currency()).contains("currency") + assertThat(externalPaymentUpdatedWebhookEvent.events().getOrNull()) + .containsExactly( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + assertThat(externalPaymentUpdatedWebhookEvent.family()) + .contains(ExternalPayment.Family.EXTERNAL_PAYMENT) + assertThat(externalPaymentUpdatedWebhookEvent.financialAccountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(externalPaymentUpdatedWebhookEvent.paymentType()) + .contains(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + assertThat(externalPaymentUpdatedWebhookEvent.pendingAmount()).contains(0L) + assertThat(externalPaymentUpdatedWebhookEvent.result()) + .contains(ExternalPayment.TransactionResult.APPROVED) + assertThat(externalPaymentUpdatedWebhookEvent.settledAmount()).contains(0L) + assertThat(externalPaymentUpdatedWebhookEvent.userDefinedId()).contains("user_defined_id") + assertThat(externalPaymentUpdatedWebhookEvent.eventType()) + .isEqualTo(ExternalPaymentUpdatedWebhookEvent.EventType.EXTERNAL_PAYMENT_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val externalPaymentUpdatedWebhookEvent = + ExternalPaymentUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .family(ExternalPayment.Family.EXTERNAL_PAYMENT) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .eventType(ExternalPaymentUpdatedWebhookEvent.EventType.EXTERNAL_PAYMENT_UPDATED) + .build() + + val roundtrippedExternalPaymentUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(externalPaymentUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedExternalPaymentUpdatedWebhookEvent) + .isEqualTo(externalPaymentUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreatedWebhookEventTest.kt new file mode 100644 index 000000000..d3858fbf0 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreatedWebhookEventTest.kt @@ -0,0 +1,127 @@ +// 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 FinancialAccountCreatedWebhookEventTest { + + @Test + fun create() { + val financialAccountCreatedWebhookEvent = + FinancialAccountCreatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + .isForBenefitOf(true) + .nickname("nickname") + .status(FinancialAccount.FinancialAccountStatus.OPEN) + .type(FinancialAccount.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accountNumber("account_number") + .routingNumber("routing_number") + .substatus(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + .eventType(FinancialAccountCreatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_CREATED) + .build() + + assertThat(financialAccountCreatedWebhookEvent.token()) + .isEqualTo("b68b7424-aa69-4cbc-a946-30d90181b621") + assertThat(financialAccountCreatedWebhookEvent.accountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(financialAccountCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(financialAccountCreatedWebhookEvent.creditConfiguration()) + .contains( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + assertThat(financialAccountCreatedWebhookEvent.isForBenefitOf()).isEqualTo(true) + assertThat(financialAccountCreatedWebhookEvent.nickname()).contains("nickname") + assertThat(financialAccountCreatedWebhookEvent.status()) + .isEqualTo(FinancialAccount.FinancialAccountStatus.OPEN) + assertThat(financialAccountCreatedWebhookEvent.type()) + .isEqualTo(FinancialAccount.Type.ISSUING) + assertThat(financialAccountCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(financialAccountCreatedWebhookEvent.accountNumber()).contains("account_number") + assertThat(financialAccountCreatedWebhookEvent.routingNumber()).contains("routing_number") + assertThat(financialAccountCreatedWebhookEvent.substatus()) + .contains(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + assertThat(financialAccountCreatedWebhookEvent.eventType()) + .isEqualTo(FinancialAccountCreatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_CREATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val financialAccountCreatedWebhookEvent = + FinancialAccountCreatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + .isForBenefitOf(true) + .nickname("nickname") + .status(FinancialAccount.FinancialAccountStatus.OPEN) + .type(FinancialAccount.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accountNumber("account_number") + .routingNumber("routing_number") + .substatus(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + .eventType(FinancialAccountCreatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_CREATED) + .build() + + val roundtrippedFinancialAccountCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(financialAccountCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFinancialAccountCreatedWebhookEvent) + .isEqualTo(financialAccountCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..8f12e1fdd --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountUpdatedWebhookEventTest.kt @@ -0,0 +1,127 @@ +// 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 FinancialAccountUpdatedWebhookEventTest { + + @Test + fun create() { + val financialAccountUpdatedWebhookEvent = + FinancialAccountUpdatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + .isForBenefitOf(true) + .nickname("nickname") + .status(FinancialAccount.FinancialAccountStatus.OPEN) + .type(FinancialAccount.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accountNumber("account_number") + .routingNumber("routing_number") + .substatus(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + .eventType(FinancialAccountUpdatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_UPDATED) + .build() + + assertThat(financialAccountUpdatedWebhookEvent.token()) + .isEqualTo("b68b7424-aa69-4cbc-a946-30d90181b621") + assertThat(financialAccountUpdatedWebhookEvent.accountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(financialAccountUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(financialAccountUpdatedWebhookEvent.creditConfiguration()) + .contains( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + assertThat(financialAccountUpdatedWebhookEvent.isForBenefitOf()).isEqualTo(true) + assertThat(financialAccountUpdatedWebhookEvent.nickname()).contains("nickname") + assertThat(financialAccountUpdatedWebhookEvent.status()) + .isEqualTo(FinancialAccount.FinancialAccountStatus.OPEN) + assertThat(financialAccountUpdatedWebhookEvent.type()) + .isEqualTo(FinancialAccount.Type.ISSUING) + assertThat(financialAccountUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(financialAccountUpdatedWebhookEvent.accountNumber()).contains("account_number") + assertThat(financialAccountUpdatedWebhookEvent.routingNumber()).contains("routing_number") + assertThat(financialAccountUpdatedWebhookEvent.substatus()) + .contains(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + assertThat(financialAccountUpdatedWebhookEvent.eventType()) + .isEqualTo(FinancialAccountUpdatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val financialAccountUpdatedWebhookEvent = + FinancialAccountUpdatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + .isForBenefitOf(true) + .nickname("nickname") + .status(FinancialAccount.FinancialAccountStatus.OPEN) + .type(FinancialAccount.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accountNumber("account_number") + .routingNumber("routing_number") + .substatus(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + .eventType(FinancialAccountUpdatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_UPDATED) + .build() + + val roundtrippedFinancialAccountUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(financialAccountUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFinancialAccountUpdatedWebhookEvent) + .isEqualTo(financialAccountUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventCreatedWebhookEventTest.kt new file mode 100644 index 000000000..957022df8 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FundingEventCreatedWebhookEventTest.kt @@ -0,0 +1,89 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FundingEventCreatedWebhookEventTest { + + @Test + fun create() { + val fundingEventCreatedWebhookEvent = + FundingEventCreatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) + .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") + .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .addNetworkSettlementSummary( + FundingEvent.FundingEventSettlement.builder() + .networkSettlementDate(LocalDate.parse("2024-01-01")) + .settledGrossAmount(0L) + .build() + ) + .previousHighWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .eventType(FundingEventCreatedWebhookEvent.EventType.FUNDING_EVENT_CREATED) + .build() + + assertThat(fundingEventCreatedWebhookEvent.token()) + .isEqualTo("b68b7424-aa69-4cbc-a946-30d90181b621") + assertThat(fundingEventCreatedWebhookEvent.collectionResourceType()) + .isEqualTo(FundingEvent.CollectionResourceType.PAYMENT) + assertThat(fundingEventCreatedWebhookEvent.collectionTokens()) + .containsExactly("b68b7424-aa69-4cbc-a946-30d90181b621") + assertThat(fundingEventCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + assertThat(fundingEventCreatedWebhookEvent.highWatermark()) + .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + assertThat(fundingEventCreatedWebhookEvent.networkSettlementSummary()) + .containsExactly( + FundingEvent.FundingEventSettlement.builder() + .networkSettlementDate(LocalDate.parse("2024-01-01")) + .settledGrossAmount(0L) + .build() + ) + assertThat(fundingEventCreatedWebhookEvent.previousHighWatermark()) + .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + assertThat(fundingEventCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + assertThat(fundingEventCreatedWebhookEvent.eventType()) + .isEqualTo(FundingEventCreatedWebhookEvent.EventType.FUNDING_EVENT_CREATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fundingEventCreatedWebhookEvent = + FundingEventCreatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) + .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") + .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .addNetworkSettlementSummary( + FundingEvent.FundingEventSettlement.builder() + .networkSettlementDate(LocalDate.parse("2024-01-01")) + .settledGrossAmount(0L) + .build() + ) + .previousHighWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .eventType(FundingEventCreatedWebhookEvent.EventType.FUNDING_EVENT_CREATED) + .build() + + val roundtrippedFundingEventCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fundingEventCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFundingEventCreatedWebhookEvent) + .isEqualTo(fundingEventCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionCreatedWebhookEventTest.kt new file mode 100644 index 000000000..a35c0e34f --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionCreatedWebhookEventTest.kt @@ -0,0 +1,115 @@ +// 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 InternalTransactionCreatedWebhookEventTest { + + @Test + fun create() { + val internalTransactionCreatedWebhookEvent = + InternalTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED + ) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + InternalTransactionCreatedWebhookEvent.EventType.INTERNAL_TRANSACTION_CREATED + ) + .build() + + assertThat(internalTransactionCreatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(internalTransactionCreatedWebhookEvent.category()) + .isEqualTo(InternalTransaction.Category.INTERNAL) + assertThat(internalTransactionCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(internalTransactionCreatedWebhookEvent.currency()).isEqualTo("currency") + assertThat(internalTransactionCreatedWebhookEvent.descriptor()).isEqualTo("descriptor") + assertThat(internalTransactionCreatedWebhookEvent.events()) + .containsExactly( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result(InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + assertThat(internalTransactionCreatedWebhookEvent.pendingAmount()).isEqualTo(0L) + assertThat(internalTransactionCreatedWebhookEvent.result()) + .isEqualTo(InternalTransaction.TransactionResult.APPROVED) + assertThat(internalTransactionCreatedWebhookEvent.settledAmount()).isEqualTo(0L) + assertThat(internalTransactionCreatedWebhookEvent.status()) + .isEqualTo(InternalTransaction.TransactionStatus.PENDING) + assertThat(internalTransactionCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(internalTransactionCreatedWebhookEvent.eventType()) + .isEqualTo( + InternalTransactionCreatedWebhookEvent.EventType.INTERNAL_TRANSACTION_CREATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val internalTransactionCreatedWebhookEvent = + InternalTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED + ) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + InternalTransactionCreatedWebhookEvent.EventType.INTERNAL_TRANSACTION_CREATED + ) + .build() + + val roundtrippedInternalTransactionCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(internalTransactionCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInternalTransactionCreatedWebhookEvent) + .isEqualTo(internalTransactionCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..20bf3ec4c --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/InternalTransactionUpdatedWebhookEventTest.kt @@ -0,0 +1,115 @@ +// 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 InternalTransactionUpdatedWebhookEventTest { + + @Test + fun create() { + val internalTransactionUpdatedWebhookEvent = + InternalTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED + ) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + InternalTransactionUpdatedWebhookEvent.EventType.INTERNAL_TRANSACTION_UPDATED + ) + .build() + + assertThat(internalTransactionUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(internalTransactionUpdatedWebhookEvent.category()) + .isEqualTo(InternalTransaction.Category.INTERNAL) + assertThat(internalTransactionUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(internalTransactionUpdatedWebhookEvent.currency()).isEqualTo("currency") + assertThat(internalTransactionUpdatedWebhookEvent.descriptor()).isEqualTo("descriptor") + assertThat(internalTransactionUpdatedWebhookEvent.events()) + .containsExactly( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result(InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + assertThat(internalTransactionUpdatedWebhookEvent.pendingAmount()).isEqualTo(0L) + assertThat(internalTransactionUpdatedWebhookEvent.result()) + .isEqualTo(InternalTransaction.TransactionResult.APPROVED) + assertThat(internalTransactionUpdatedWebhookEvent.settledAmount()).isEqualTo(0L) + assertThat(internalTransactionUpdatedWebhookEvent.status()) + .isEqualTo(InternalTransaction.TransactionStatus.PENDING) + assertThat(internalTransactionUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(internalTransactionUpdatedWebhookEvent.eventType()) + .isEqualTo( + InternalTransactionUpdatedWebhookEvent.EventType.INTERNAL_TRANSACTION_UPDATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val internalTransactionUpdatedWebhookEvent = + InternalTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED + ) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + InternalTransactionUpdatedWebhookEvent.EventType.INTERNAL_TRANSACTION_UPDATED + ) + .build() + + val roundtrippedInternalTransactionUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(internalTransactionUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInternalTransactionUpdatedWebhookEvent) + .isEqualTo(internalTransactionUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/LoanTapeCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/LoanTapeCreatedWebhookEventTest.kt new file mode 100644 index 000000000..8c4711e32 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/LoanTapeCreatedWebhookEventTest.kt @@ -0,0 +1,458 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LoanTapeCreatedWebhookEventTest { + + @Test + fun create() { + val loanTapeCreatedWebhookEvent = + LoanTapeCreatedWebhookEvent.builder() + .token("token") + .accountStanding( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + .availableCredit(0L) + .balances( + LoanTape.Balances.builder() + .due(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .nextStatementDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastStatementsDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .date(LocalDate.parse("2019-12-27")) + .dayTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .endingBalance(0L) + .excessCredits(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .interestDetails( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .minimumPaymentBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .paymentAllocation( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .previousStatementBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .startingBalance(0L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .tier("tier") + .eventType(LoanTapeCreatedWebhookEvent.EventType.LOAN_TAPE_CREATED) + .build() + + assertThat(loanTapeCreatedWebhookEvent.token()).isEqualTo("token") + assertThat(loanTapeCreatedWebhookEvent.accountStanding()) + .isEqualTo( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + assertThat(loanTapeCreatedWebhookEvent.availableCredit()).isEqualTo(0L) + assertThat(loanTapeCreatedWebhookEvent.balances()) + .isEqualTo( + LoanTape.Balances.builder() + .due(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .nextStatementDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastDue(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .pastStatementsDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .build() + ) + assertThat(loanTapeCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(loanTapeCreatedWebhookEvent.creditLimit()).isEqualTo(0L) + assertThat(loanTapeCreatedWebhookEvent.creditProductToken()) + .isEqualTo("credit_product_token") + assertThat(loanTapeCreatedWebhookEvent.date()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(loanTapeCreatedWebhookEvent.dayTotals()) + .isEqualTo( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + assertThat(loanTapeCreatedWebhookEvent.endingBalance()).isEqualTo(0L) + assertThat(loanTapeCreatedWebhookEvent.excessCredits()).isEqualTo(0L) + assertThat(loanTapeCreatedWebhookEvent.financialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(loanTapeCreatedWebhookEvent.interestDetails()) + .contains( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + assertThat(loanTapeCreatedWebhookEvent.minimumPaymentBalance()) + .isEqualTo(LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build()) + assertThat(loanTapeCreatedWebhookEvent.paymentAllocation()) + .isEqualTo(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + assertThat(loanTapeCreatedWebhookEvent.periodTotals()) + .isEqualTo( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + assertThat(loanTapeCreatedWebhookEvent.previousStatementBalance()) + .isEqualTo(LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build()) + assertThat(loanTapeCreatedWebhookEvent.startingBalance()).isEqualTo(0L) + assertThat(loanTapeCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(loanTapeCreatedWebhookEvent.version()).isEqualTo(0L) + assertThat(loanTapeCreatedWebhookEvent.ytdTotals()) + .isEqualTo( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + assertThat(loanTapeCreatedWebhookEvent.tier()).contains("tier") + assertThat(loanTapeCreatedWebhookEvent.eventType()) + .isEqualTo(LoanTapeCreatedWebhookEvent.EventType.LOAN_TAPE_CREATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val loanTapeCreatedWebhookEvent = + LoanTapeCreatedWebhookEvent.builder() + .token("token") + .accountStanding( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + .availableCredit(0L) + .balances( + LoanTape.Balances.builder() + .due(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .nextStatementDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastStatementsDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .date(LocalDate.parse("2019-12-27")) + .dayTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .endingBalance(0L) + .excessCredits(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .interestDetails( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .minimumPaymentBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .paymentAllocation( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .previousStatementBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .startingBalance(0L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .tier("tier") + .eventType(LoanTapeCreatedWebhookEvent.EventType.LOAN_TAPE_CREATED) + .build() + + val roundtrippedLoanTapeCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(loanTapeCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLoanTapeCreatedWebhookEvent).isEqualTo(loanTapeCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/LoanTapeUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/LoanTapeUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..957437d7a --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/LoanTapeUpdatedWebhookEventTest.kt @@ -0,0 +1,458 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LoanTapeUpdatedWebhookEventTest { + + @Test + fun create() { + val loanTapeUpdatedWebhookEvent = + LoanTapeUpdatedWebhookEvent.builder() + .token("token") + .accountStanding( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + .availableCredit(0L) + .balances( + LoanTape.Balances.builder() + .due(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .nextStatementDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastStatementsDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .date(LocalDate.parse("2019-12-27")) + .dayTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .endingBalance(0L) + .excessCredits(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .interestDetails( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .minimumPaymentBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .paymentAllocation( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .previousStatementBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .startingBalance(0L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .tier("tier") + .eventType(LoanTapeUpdatedWebhookEvent.EventType.LOAN_TAPE_UPDATED) + .build() + + assertThat(loanTapeUpdatedWebhookEvent.token()).isEqualTo("token") + assertThat(loanTapeUpdatedWebhookEvent.accountStanding()) + .isEqualTo( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + assertThat(loanTapeUpdatedWebhookEvent.availableCredit()).isEqualTo(0L) + assertThat(loanTapeUpdatedWebhookEvent.balances()) + .isEqualTo( + LoanTape.Balances.builder() + .due(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .nextStatementDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastDue(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .pastStatementsDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .build() + ) + assertThat(loanTapeUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(loanTapeUpdatedWebhookEvent.creditLimit()).isEqualTo(0L) + assertThat(loanTapeUpdatedWebhookEvent.creditProductToken()) + .isEqualTo("credit_product_token") + assertThat(loanTapeUpdatedWebhookEvent.date()).isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(loanTapeUpdatedWebhookEvent.dayTotals()) + .isEqualTo( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + assertThat(loanTapeUpdatedWebhookEvent.endingBalance()).isEqualTo(0L) + assertThat(loanTapeUpdatedWebhookEvent.excessCredits()).isEqualTo(0L) + assertThat(loanTapeUpdatedWebhookEvent.financialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(loanTapeUpdatedWebhookEvent.interestDetails()) + .contains( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + assertThat(loanTapeUpdatedWebhookEvent.minimumPaymentBalance()) + .isEqualTo(LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build()) + assertThat(loanTapeUpdatedWebhookEvent.paymentAllocation()) + .isEqualTo(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + assertThat(loanTapeUpdatedWebhookEvent.periodTotals()) + .isEqualTo( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + assertThat(loanTapeUpdatedWebhookEvent.previousStatementBalance()) + .isEqualTo(LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build()) + assertThat(loanTapeUpdatedWebhookEvent.startingBalance()).isEqualTo(0L) + assertThat(loanTapeUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(loanTapeUpdatedWebhookEvent.version()).isEqualTo(0L) + assertThat(loanTapeUpdatedWebhookEvent.ytdTotals()) + .isEqualTo( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + assertThat(loanTapeUpdatedWebhookEvent.tier()).contains("tier") + assertThat(loanTapeUpdatedWebhookEvent.eventType()) + .isEqualTo(LoanTapeUpdatedWebhookEvent.EventType.LOAN_TAPE_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val loanTapeUpdatedWebhookEvent = + LoanTapeUpdatedWebhookEvent.builder() + .token("token") + .accountStanding( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + .availableCredit(0L) + .balances( + LoanTape.Balances.builder() + .due(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .nextStatementDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastStatementsDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .date(LocalDate.parse("2019-12-27")) + .dayTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .endingBalance(0L) + .excessCredits(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .interestDetails( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .minimumPaymentBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .paymentAllocation( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .previousStatementBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .startingBalance(0L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .tier("tier") + .eventType(LoanTapeUpdatedWebhookEvent.EventType.LOAN_TAPE_UPDATED) + .build() + + val roundtrippedLoanTapeUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(loanTapeUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLoanTapeUpdatedWebhookEvent).isEqualTo(loanTapeUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationCreatedWebhookEventTest.kt new file mode 100644 index 000000000..9ab666a03 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationCreatedWebhookEventTest.kt @@ -0,0 +1,214 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ManagementOperationCreatedWebhookEventTest { + + @Test + fun create() { + val managementOperationCreatedWebhookEvent = + ManagementOperationCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .family(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .eventType( + ManagementOperationCreatedWebhookEvent.EventType.MANAGEMENT_OPERATION_CREATED + ) + .build() + + assertThat(managementOperationCreatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(managementOperationCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(managementOperationCreatedWebhookEvent.status()) + .isEqualTo(ManagementOperationTransaction.TransactionStatus.PENDING) + assertThat(managementOperationCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(managementOperationCreatedWebhookEvent.category()) + .contains(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + assertThat(managementOperationCreatedWebhookEvent.currency()).contains("currency") + assertThat(managementOperationCreatedWebhookEvent.direction()) + .contains(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + assertThat(managementOperationCreatedWebhookEvent.events().getOrNull()) + .containsExactly( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent.TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + assertThat(managementOperationCreatedWebhookEvent.externalResource()) + .contains( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + assertThat(managementOperationCreatedWebhookEvent.family()) + .contains(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + assertThat(managementOperationCreatedWebhookEvent.financialAccountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(managementOperationCreatedWebhookEvent.pendingAmount()).contains(0L) + assertThat(managementOperationCreatedWebhookEvent.result()) + .contains(ManagementOperationTransaction.TransactionResult.APPROVED) + assertThat(managementOperationCreatedWebhookEvent.settledAmount()).contains(0L) + assertThat(managementOperationCreatedWebhookEvent.transactionSeries()) + .contains( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + assertThat(managementOperationCreatedWebhookEvent.userDefinedId()) + .contains("user_defined_id") + assertThat(managementOperationCreatedWebhookEvent.eventType()) + .isEqualTo( + ManagementOperationCreatedWebhookEvent.EventType.MANAGEMENT_OPERATION_CREATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val managementOperationCreatedWebhookEvent = + ManagementOperationCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .family(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .eventType( + ManagementOperationCreatedWebhookEvent.EventType.MANAGEMENT_OPERATION_CREATED + ) + .build() + + val roundtrippedManagementOperationCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(managementOperationCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedManagementOperationCreatedWebhookEvent) + .isEqualTo(managementOperationCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..2e27a3fc6 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ManagementOperationUpdatedWebhookEventTest.kt @@ -0,0 +1,214 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ManagementOperationUpdatedWebhookEventTest { + + @Test + fun create() { + val managementOperationUpdatedWebhookEvent = + ManagementOperationUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .family(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .eventType( + ManagementOperationUpdatedWebhookEvent.EventType.MANAGEMENT_OPERATION_UPDATED + ) + .build() + + assertThat(managementOperationUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(managementOperationUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(managementOperationUpdatedWebhookEvent.status()) + .isEqualTo(ManagementOperationTransaction.TransactionStatus.PENDING) + assertThat(managementOperationUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(managementOperationUpdatedWebhookEvent.category()) + .contains(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + assertThat(managementOperationUpdatedWebhookEvent.currency()).contains("currency") + assertThat(managementOperationUpdatedWebhookEvent.direction()) + .contains(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + assertThat(managementOperationUpdatedWebhookEvent.events().getOrNull()) + .containsExactly( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent.TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + assertThat(managementOperationUpdatedWebhookEvent.externalResource()) + .contains( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + assertThat(managementOperationUpdatedWebhookEvent.family()) + .contains(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + assertThat(managementOperationUpdatedWebhookEvent.financialAccountToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(managementOperationUpdatedWebhookEvent.pendingAmount()).contains(0L) + assertThat(managementOperationUpdatedWebhookEvent.result()) + .contains(ManagementOperationTransaction.TransactionResult.APPROVED) + assertThat(managementOperationUpdatedWebhookEvent.settledAmount()).contains(0L) + assertThat(managementOperationUpdatedWebhookEvent.transactionSeries()) + .contains( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + assertThat(managementOperationUpdatedWebhookEvent.userDefinedId()) + .contains("user_defined_id") + assertThat(managementOperationUpdatedWebhookEvent.eventType()) + .isEqualTo( + ManagementOperationUpdatedWebhookEvent.EventType.MANAGEMENT_OPERATION_UPDATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val managementOperationUpdatedWebhookEvent = + ManagementOperationUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .family(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .eventType( + ManagementOperationUpdatedWebhookEvent.EventType.MANAGEMENT_OPERATION_UPDATED + ) + .build() + + val roundtrippedManagementOperationUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(managementOperationUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedManagementOperationUpdatedWebhookEvent) + .isEqualTo(managementOperationUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalCreatedWebhookEventTest.kt new file mode 100644 index 000000000..13c002018 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalCreatedWebhookEventTest.kt @@ -0,0 +1,105 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NetworkTotalCreatedWebhookEventTest { + + @Test + fun create() { + val networkTotalCreatedWebhookEvent = + NetworkTotalCreatedWebhookEvent.builder() + .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + .amounts( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .currency("CAD") + .institutionId("1000000000") + .isComplete(true) + .network(NetworkTotal.Network.VISA) + .reportDate(LocalDate.parse("2025-02-25")) + .settlementInstitutionId("1000000001") + .settlementService("015") + .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .cycle(0L) + .eventType(NetworkTotalCreatedWebhookEvent.EventType.NETWORK_TOTAL_CREATED) + .build() + + assertThat(networkTotalCreatedWebhookEvent.token()) + .isEqualTo("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + assertThat(networkTotalCreatedWebhookEvent.amounts()) + .isEqualTo( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + assertThat(networkTotalCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + assertThat(networkTotalCreatedWebhookEvent.currency()).isEqualTo("CAD") + assertThat(networkTotalCreatedWebhookEvent.institutionId()).isEqualTo("1000000000") + assertThat(networkTotalCreatedWebhookEvent.isComplete()).isEqualTo(true) + assertThat(networkTotalCreatedWebhookEvent.network()).isEqualTo(NetworkTotal.Network.VISA) + assertThat(networkTotalCreatedWebhookEvent.reportDate()) + .isEqualTo(LocalDate.parse("2025-02-25")) + assertThat(networkTotalCreatedWebhookEvent.settlementInstitutionId()) + .isEqualTo("1000000001") + assertThat(networkTotalCreatedWebhookEvent.settlementService()).isEqualTo("015") + assertThat(networkTotalCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + assertThat(networkTotalCreatedWebhookEvent.cycle()).contains(0L) + assertThat(networkTotalCreatedWebhookEvent.eventType()) + .isEqualTo(NetworkTotalCreatedWebhookEvent.EventType.NETWORK_TOTAL_CREATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val networkTotalCreatedWebhookEvent = + NetworkTotalCreatedWebhookEvent.builder() + .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + .amounts( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .currency("CAD") + .institutionId("1000000000") + .isComplete(true) + .network(NetworkTotal.Network.VISA) + .reportDate(LocalDate.parse("2025-02-25")) + .settlementInstitutionId("1000000001") + .settlementService("015") + .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .cycle(0L) + .eventType(NetworkTotalCreatedWebhookEvent.EventType.NETWORK_TOTAL_CREATED) + .build() + + val roundtrippedNetworkTotalCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(networkTotalCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNetworkTotalCreatedWebhookEvent) + .isEqualTo(networkTotalCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..466a39df8 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/NetworkTotalUpdatedWebhookEventTest.kt @@ -0,0 +1,105 @@ +// 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.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NetworkTotalUpdatedWebhookEventTest { + + @Test + fun create() { + val networkTotalUpdatedWebhookEvent = + NetworkTotalUpdatedWebhookEvent.builder() + .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + .amounts( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .currency("CAD") + .institutionId("1000000000") + .isComplete(true) + .network(NetworkTotal.Network.VISA) + .reportDate(LocalDate.parse("2025-02-25")) + .settlementInstitutionId("1000000001") + .settlementService("015") + .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .cycle(0L) + .eventType(NetworkTotalUpdatedWebhookEvent.EventType.NETWORK_TOTAL_UPDATED) + .build() + + assertThat(networkTotalUpdatedWebhookEvent.token()) + .isEqualTo("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + assertThat(networkTotalUpdatedWebhookEvent.amounts()) + .isEqualTo( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + assertThat(networkTotalUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + assertThat(networkTotalUpdatedWebhookEvent.currency()).isEqualTo("CAD") + assertThat(networkTotalUpdatedWebhookEvent.institutionId()).isEqualTo("1000000000") + assertThat(networkTotalUpdatedWebhookEvent.isComplete()).isEqualTo(true) + assertThat(networkTotalUpdatedWebhookEvent.network()).isEqualTo(NetworkTotal.Network.VISA) + assertThat(networkTotalUpdatedWebhookEvent.reportDate()) + .isEqualTo(LocalDate.parse("2025-02-25")) + assertThat(networkTotalUpdatedWebhookEvent.settlementInstitutionId()) + .isEqualTo("1000000001") + assertThat(networkTotalUpdatedWebhookEvent.settlementService()).isEqualTo("015") + assertThat(networkTotalUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + assertThat(networkTotalUpdatedWebhookEvent.cycle()).contains(0L) + assertThat(networkTotalUpdatedWebhookEvent.eventType()) + .isEqualTo(NetworkTotalUpdatedWebhookEvent.EventType.NETWORK_TOTAL_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val networkTotalUpdatedWebhookEvent = + NetworkTotalUpdatedWebhookEvent.builder() + .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + .amounts( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .currency("CAD") + .institutionId("1000000000") + .isComplete(true) + .network(NetworkTotal.Network.VISA) + .reportDate(LocalDate.parse("2025-02-25")) + .settlementInstitutionId("1000000001") + .settlementService("015") + .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .cycle(0L) + .eventType(NetworkTotalUpdatedWebhookEvent.EventType.NETWORK_TOTAL_UPDATED) + .build() + + val roundtrippedNetworkTotalUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(networkTotalUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNetworkTotalUpdatedWebhookEvent) + .isEqualTo(networkTotalUpdatedWebhookEvent) + } +} 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 new file mode 100644 index 000000000..f12d52b27 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ParsedWebhookEventTest.kt @@ -0,0 +1,11067 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import com.lithic.api.errors.LithicInvalidDataException +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ParsedWebhookEventTest { + + @Test + fun ofAccountHolderCreated() { + val accountHolderCreated = + AccountHolderCreatedWebhookEvent.builder() + .eventType(AccountHolderCreatedWebhookEvent.EventType.ACCOUNT_HOLDER_CREATED) + .token("00000000-0000-0000-0000-000000000001") + .accountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addRequiredDocument( + RequiredDocument.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addStatusReason("string") + .addValidDocument("string") + .build() + ) + .status(AccountHolderCreatedWebhookEvent.Status.ACCEPTED) + .addStatusReason("string") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofAccountHolderCreated(accountHolderCreated) + + assertThat(parsedWebhookEvent.accountHolderCreated()).contains(accountHolderCreated) + assertThat(parsedWebhookEvent.kybPayload()).isEmpty + assertThat(parsedWebhookEvent.kycPayload()).isEmpty + assertThat(parsedWebhookEvent.legacyPayload()).isEmpty + assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty + assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty + assertThat(parsedWebhookEvent.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofAccountHolderCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofAccountHolderCreated( + AccountHolderCreatedWebhookEvent.builder() + .eventType(AccountHolderCreatedWebhookEvent.EventType.ACCOUNT_HOLDER_CREATED) + .token("00000000-0000-0000-0000-000000000001") + .accountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addRequiredDocument( + RequiredDocument.builder() + .entityToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addStatusReason("string") + .addValidDocument("string") + .build() + ) + .status(AccountHolderCreatedWebhookEvent.Status.ACCEPTED) + .addStatusReason("string") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofKybPayload() { + val kybPayload = + ParsedWebhookEvent.KybPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .updateRequest( + ParsedWebhookEvent.KybPayload.UpdateRequest.builder() + .addBeneficialOwnerEntity( + KybBusinessEntity.builder() + .address( + KybBusinessEntity.Address.builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .addPhoneNumber("+15555555555") + .dbaBusinessName("dba_business_name") + .parentCompany("parent_company") + .build() + ) + .addBeneficialOwnerIndividual( + ParsedWebhookEvent.KybPayload.UpdateRequest.Individual.builder() + .address( + ParsedWebhookEvent.KybPayload.UpdateRequest.Individual.Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + KybBusinessEntity.builder() + .address( + KybBusinessEntity.Address.builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .addPhoneNumber("+15555555555") + .dbaBusinessName("dba_business_name") + .parentCompany("parent_company") + .build() + ) + .controlPerson( + ParsedWebhookEvent.KybPayload.UpdateRequest.Individual.builder() + .address( + ParsedWebhookEvent.KybPayload.UpdateRequest.Individual.Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .build() + ) + .eventType(ParsedWebhookEvent.KybPayload.EventType.ACCOUNT_HOLDER_UPDATED) + .externalId("external_id") + .natureOfBusiness("Software company selling solutions to the restaurant industry") + .websiteUrl("www.mybusiness.com") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofKybPayload(kybPayload) + + assertThat(parsedWebhookEvent.accountHolderCreated()).isEmpty + assertThat(parsedWebhookEvent.kybPayload()).contains(kybPayload) + assertThat(parsedWebhookEvent.kycPayload()).isEmpty + assertThat(parsedWebhookEvent.legacyPayload()).isEmpty + assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty + assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty + assertThat(parsedWebhookEvent.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofKybPayloadRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofKybPayload( + ParsedWebhookEvent.KybPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .updateRequest( + ParsedWebhookEvent.KybPayload.UpdateRequest.builder() + .addBeneficialOwnerEntity( + KybBusinessEntity.builder() + .address( + KybBusinessEntity.Address.builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .addPhoneNumber("+15555555555") + .dbaBusinessName("dba_business_name") + .parentCompany("parent_company") + .build() + ) + .addBeneficialOwnerIndividual( + ParsedWebhookEvent.KybPayload.UpdateRequest.Individual.builder() + .address( + ParsedWebhookEvent.KybPayload.UpdateRequest.Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .businessEntity( + KybBusinessEntity.builder() + .address( + KybBusinessEntity.Address.builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .governmentId("114-123-1513") + .legalBusinessName("Acme, Inc.") + .addPhoneNumber("+15555555555") + .dbaBusinessName("dba_business_name") + .parentCompany("parent_company") + .build() + ) + .controlPerson( + ParsedWebhookEvent.KybPayload.UpdateRequest.Individual.builder() + .address( + ParsedWebhookEvent.KybPayload.UpdateRequest.Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .build() + ) + .eventType(ParsedWebhookEvent.KybPayload.EventType.ACCOUNT_HOLDER_UPDATED) + .externalId("external_id") + .natureOfBusiness( + "Software company selling solutions to the restaurant industry" + ) + .websiteUrl("www.mybusiness.com") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofKycPayload() { + val kycPayload = + ParsedWebhookEvent.KycPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .updateRequest( + ParsedWebhookEvent.KycPayload.UpdateRequest.builder() + .individual( + ParsedWebhookEvent.KycPayload.UpdateRequest.Individual.builder() + .address( + ParsedWebhookEvent.KycPayload.UpdateRequest.Individual.Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .build() + ) + .eventType(ParsedWebhookEvent.KycPayload.EventType.ACCOUNT_HOLDER_UPDATED) + .externalId("external_id") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofKycPayload(kycPayload) + + assertThat(parsedWebhookEvent.accountHolderCreated()).isEmpty + assertThat(parsedWebhookEvent.kybPayload()).isEmpty + assertThat(parsedWebhookEvent.kycPayload()).contains(kycPayload) + assertThat(parsedWebhookEvent.legacyPayload()).isEmpty + assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty + assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty + assertThat(parsedWebhookEvent.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofKycPayloadRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofKycPayload( + ParsedWebhookEvent.KycPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .updateRequest( + ParsedWebhookEvent.KycPayload.UpdateRequest.builder() + .individual( + ParsedWebhookEvent.KycPayload.UpdateRequest.Individual.builder() + .address( + ParsedWebhookEvent.KycPayload.UpdateRequest.Individual + .Address + .builder() + .address1("123 Old Forest Way") + .city("Omaha") + .country("USA") + .postalCode("68022") + .state("NE") + .address2("address2") + .build() + ) + .dob("1991-03-08 08:00:00") + .email("tom@middle-earth.com") + .firstName("Tom") + .lastName("Bombadil") + .phoneNumber("+15555555555") + .build() + ) + .build() + ) + .eventType(ParsedWebhookEvent.KycPayload.EventType.ACCOUNT_HOLDER_UPDATED) + .externalId("external_id") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofLegacyPayload() { + val legacyPayload = + ParsedWebhookEvent.LegacyPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .businessAccountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("johnny@lithic.com") + .eventType(ParsedWebhookEvent.LegacyPayload.EventType.ACCOUNT_HOLDER_UPDATED) + .externalId("00000000-0000-0000-0000-000000000001") + .firstName("Johnny") + .lastName("Appleseed") + .legalBusinessName("Lithic") + .phoneNumber("+15555555555") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofLegacyPayload(legacyPayload) + + assertThat(parsedWebhookEvent.accountHolderCreated()).isEmpty + assertThat(parsedWebhookEvent.kybPayload()).isEmpty + assertThat(parsedWebhookEvent.kycPayload()).isEmpty + assertThat(parsedWebhookEvent.legacyPayload()).contains(legacyPayload) + assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty + assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty + assertThat(parsedWebhookEvent.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofLegacyPayloadRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofLegacyPayload( + ParsedWebhookEvent.LegacyPayload.builder() + .token("00000000-0000-0000-0000-000000000001") + .businessAccountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .email("johnny@lithic.com") + .eventType(ParsedWebhookEvent.LegacyPayload.EventType.ACCOUNT_HOLDER_UPDATED) + .externalId("00000000-0000-0000-0000-000000000001") + .firstName("Johnny") + .lastName("Appleseed") + .legalBusinessName("Lithic") + .phoneNumber("+15555555555") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofAccountHolderVerification() { + val accountHolderVerification = + AccountHolderVerificationWebhookEvent.builder() + .eventType( + AccountHolderVerificationWebhookEvent.EventType.ACCOUNT_HOLDER_VERIFICATION + ) + .token("00000000-0000-0000-0000-000000000001") + .accountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(AccountHolderVerificationWebhookEvent.Status.ACCEPTED) + .addStatusReason("string") + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofAccountHolderVerification(accountHolderVerification) + + assertThat(parsedWebhookEvent.accountHolderCreated()).isEmpty + assertThat(parsedWebhookEvent.kybPayload()).isEmpty + assertThat(parsedWebhookEvent.kycPayload()).isEmpty + assertThat(parsedWebhookEvent.legacyPayload()).isEmpty + assertThat(parsedWebhookEvent.accountHolderVerification()) + .contains(accountHolderVerification) + assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()).isEmpty + assertThat(parsedWebhookEvent.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofAccountHolderVerificationRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofAccountHolderVerification( + AccountHolderVerificationWebhookEvent.builder() + .eventType( + AccountHolderVerificationWebhookEvent.EventType.ACCOUNT_HOLDER_VERIFICATION + ) + .token("00000000-0000-0000-0000-000000000001") + .accountToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(AccountHolderVerificationWebhookEvent.Status.ACCEPTED) + .addStatusReason("string") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofAccountHolderDocumentUpdated() { + val accountHolderDocumentUpdated = + AccountHolderDocumentUpdatedWebhookEvent.builder() + .eventType( + AccountHolderDocumentUpdatedWebhookEvent.EventType + .ACCOUNT_HOLDER_DOCUMENT_UPDATED + ) + .token("9175a05c-a9da-4082-8e14-9296427ebba7") + .accountHolderToken("2b52494a-ae73-4ab1-97e8-2dd1d51d18b0") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .documentType(AccountHolderDocumentUpdatedWebhookEvent.DocumentType.DRIVERS_LICENSE) + .entityToken("c5f2d594-d957-4781-8877-fbea31f5944a") + .addRequiredDocumentUpload( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAcceptedEntityStatusReason("string") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .imageType( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .ImageType + .FRONT + ) + .addRejectedEntityStatusReason("string") + .status( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .DocumentUploadStatus + .ACCEPTED + ) + .addStatusReason("string") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofAccountHolderDocumentUpdated(accountHolderDocumentUpdated) + + assertThat(parsedWebhookEvent.accountHolderCreated()).isEmpty + assertThat(parsedWebhookEvent.kybPayload()).isEmpty + assertThat(parsedWebhookEvent.kycPayload()).isEmpty + assertThat(parsedWebhookEvent.legacyPayload()).isEmpty + assertThat(parsedWebhookEvent.accountHolderVerification()).isEmpty + assertThat(parsedWebhookEvent.accountHolderDocumentUpdated()) + .contains(accountHolderDocumentUpdated) + assertThat(parsedWebhookEvent.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofAccountHolderDocumentUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofAccountHolderDocumentUpdated( + AccountHolderDocumentUpdatedWebhookEvent.builder() + .eventType( + AccountHolderDocumentUpdatedWebhookEvent.EventType + .ACCOUNT_HOLDER_DOCUMENT_UPDATED + ) + .token("9175a05c-a9da-4082-8e14-9296427ebba7") + .accountHolderToken("2b52494a-ae73-4ab1-97e8-2dd1d51d18b0") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .documentType( + AccountHolderDocumentUpdatedWebhookEvent.DocumentType.DRIVERS_LICENSE + ) + .entityToken("c5f2d594-d957-4781-8877-fbea31f5944a") + .addRequiredDocumentUpload( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAcceptedEntityStatusReason("string") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .imageType( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .ImageType + .FRONT + ) + .addRejectedEntityStatusReason("string") + .status( + AccountHolderDocumentUpdatedWebhookEvent.RequiredDocumentUpload + .DocumentUploadStatus + .ACCEPTED + ) + .addStatusReason("string") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofAsaRequest() { + val asaRequest = + AsaRequestWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .authorizationAmount(0L) + .avs( + AsaRequestWebhookEvent.Avs.builder() + .address("address") + .addressOnFileMatch(AsaRequestWebhookEvent.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + AsaRequestWebhookEvent.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hostname("hostname") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + AsaRequestWebhookEvent.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(AsaRequestWebhookEvent.AsaRequestCard.State.CLOSED) + .type(AsaRequestWebhookEvent.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .settledAmount(0L) + .status(AsaRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(AsaRequestWebhookEvent.TransactionInitiator.CARDHOLDER) + .accountType(AsaRequestWebhookEvent.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( + AsaRequestWebhookEvent.AsaRequestFleetInfo.builder() + .fleetPromptCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + AsaRequestWebhookEvent.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(AsaRequestWebhookEvent.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(AsaRequestWebhookEvent.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + AsaRequestWebhookEvent.AsaNetworkSpecificData.builder() + .mastercard( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + AsaRequestWebhookEvent.AsaNetworkSpecificData.AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + AsaRequestWebhookEvent.Pos.builder() + .entryMode( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.builder() + .card( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Card.PRESENT + ) + .cardholder( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Pan.AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.Operator + .ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.PinCapability.CAPABLE + ) + .type(AsaRequestWebhookEvent.Pos.AsaPosTerminal.Type.ADMINISTRATIVE) + .acceptorTerminalId(" r 0K9tW") + .build() + ) + .build() + ) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofAsaRequest(asaRequest) + + 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.asaRequest()).contains(asaRequest) + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofAsaRequestRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofAsaRequest( + AsaRequestWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .acquirerFee(0L) + .amount(0L) + .authorizationAmount(0L) + .avs( + AsaRequestWebhookEvent.Avs.builder() + .address("address") + .addressOnFileMatch(AsaRequestWebhookEvent.Avs.AddressMatchResult.MATCH) + .zipcode("zipcode") + .build() + ) + .card( + AsaRequestWebhookEvent.AsaRequestCard.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .hostname("hostname") + .lastFour("last_four") + .memo("memo") + .spendLimit(0L) + .spendLimitDuration( + AsaRequestWebhookEvent.AsaRequestCard.SpendLimitDuration.ANNUALLY + ) + .state(AsaRequestWebhookEvent.AsaRequestCard.State.CLOSED) + .type(AsaRequestWebhookEvent.AsaRequestCard.CardType.SINGLE_USE) + .build() + ) + .cardholderCurrency("cardholder_currency") + .cashAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .merchantAmount(0L) + .merchantCurrency("USD") + .settledAmount(0L) + .status(AsaRequestWebhookEvent.AsaRequestStatus.AUTHORIZATION) + .transactionInitiator(AsaRequestWebhookEvent.TransactionInitiator.CARDHOLDER) + .accountType(AsaRequestWebhookEvent.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( + AsaRequestWebhookEvent.AsaRequestFleetInfo.builder() + .fleetPromptCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetPromptCode.NO_PROMPT + ) + .fleetRestrictionCode( + AsaRequestWebhookEvent.AsaRequestFleetInfo.FleetRestrictionCode + .NO_RESTRICTIONS + ) + .driverNumber("driver_number") + .vehicleNumber("vehicle_number") + .build() + ) + .latestChallenge( + AsaRequestWebhookEvent.LatestChallenge.builder() + .phoneNumber("phone_number") + .status(AsaRequestWebhookEvent.LatestChallenge.Status.COMPLETED) + .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .network(AsaRequestWebhookEvent.Network.AMEX) + .networkRiskScore(0L) + .networkSpecificData( + AsaRequestWebhookEvent.AsaNetworkSpecificData.builder() + .mastercard( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataMastercard + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + AsaRequestWebhookEvent.AsaNetworkSpecificData + .AsaNetworkSpecificDataVisa + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .pos( + AsaRequestWebhookEvent.Pos.builder() + .entryMode( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.builder() + .card( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Card + .PRESENT + ) + .cardholder( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Cardholder + .DEFERRED_BILLING + ) + .pan( + AsaRequestWebhookEvent.Pos.AsaRequestPosEntryMode.Pan + .AUTO_ENTRY + ) + .pinEntered(true) + .build() + ) + .terminal( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.builder() + .attended(true) + .cardRetentionCapable(true) + .onPremise(true) + .operator( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.Operator + .ADMINISTRATIVE + ) + .partialApprovalCapable(true) + .pinCapability( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.PinCapability + .CAPABLE + ) + .type( + AsaRequestWebhookEvent.Pos.AsaPosTerminal.Type + .ADMINISTRATIVE + ) + .acceptorTerminalId(" r 0K9tW") + .build() + ) + .build() + ) + .tokenInfo( + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() + ) + .ttl(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofTokenizationDecisioningRequest() { + val tokenizationDecisioningRequest = + TokenizationDecisioningRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2023-09-18T12:34:56Z")) + .eventType( + TokenizationDecisioningRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision(TokenizationDecisioningRequestWebhookEvent.IssuerDecision.APPROVED) + .tokenizationChannel( + TokenizationDecisioningRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET + ) + .tokenizationToken("tok_1234567890abcdef") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("Reason1") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("+15555555555") + .build() + ) + .panUniqueReference("pan_unique_ref_1234567890123456789012345678") + .paymentAccountReference("ref_1234567890123456789012") + .tokenUniqueReference( + "token_unique_ref_1234567890123456789012345678" + ) + .build() + ) + .status("Pending") + .paymentAppInstanceId("app_instance_123456789012345678901234567890") + .tokenRequestorId("12345678901") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .tokenizationSource( + TokenizationDecisioningRequestWebhookEvent.TokenizationSource.PUSH_PROVISION + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationDecisioningRequest(tokenizationDecisioningRequest) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()) + .contains(tokenizationDecisioningRequest) + 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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofTokenizationDecisioningRequestRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationDecisioningRequest( + TokenizationDecisioningRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2023-09-18T12:34:56Z")) + .eventType( + TokenizationDecisioningRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision( + TokenizationDecisioningRequestWebhookEvent.IssuerDecision.APPROVED + ) + .tokenizationChannel( + TokenizationDecisioningRequestWebhookEvent.TokenizationChannel + .DIGITAL_WALLET + ) + .tokenizationToken("tok_1234567890abcdef") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("Reason1") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo + .AccountHolderData + .builder() + .phoneNumber("+15555555555") + .build() + ) + .panUniqueReference( + "pan_unique_ref_1234567890123456789012345678" + ) + .paymentAccountReference("ref_1234567890123456789012") + .tokenUniqueReference( + "token_unique_ref_1234567890123456789012345678" + ) + .build() + ) + .status("Pending") + .paymentAppInstanceId("app_instance_123456789012345678901234567890") + .tokenRequestorId("12345678901") + .tokenRequestorName( + DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY + ) + .build() + ) + .tokenizationSource( + TokenizationDecisioningRequestWebhookEvent.TokenizationSource.PUSH_PROVISION + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofAuthRulesBacktestReportCreated() { + val authRulesBacktestReportCreated = + AuthRulesBacktestReportCreatedWebhookEvent.builder() + .backtestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .results( + BacktestResults.Results.builder() + .currentVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .version(0L) + .build() + ) + .draftVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .version(0L) + .build() + ) + .build() + ) + .simulationParameters( + BacktestResults.SimulationParameters.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType( + AuthRulesBacktestReportCreatedWebhookEvent.EventType + .AUTH_RULES_BACKTEST_REPORT_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofAuthRulesBacktestReportCreated(authRulesBacktestReportCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).isEmpty + assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()) + .contains(authRulesBacktestReportCreated) + 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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofAuthRulesBacktestReportCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofAuthRulesBacktestReportCreated( + AuthRulesBacktestReportCreatedWebhookEvent.builder() + .backtestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .results( + BacktestResults.Results.builder() + .currentVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .version(0L) + .build() + ) + .draftVersion( + RuleStats.builder() + .approved(0L) + .challenged(0L) + .declined(0L) + .addExample( + RuleStats.Example.builder() + .approved(true) + .decision(RuleStats.Example.Decision.APPROVED) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + .version(0L) + .build() + ) + .build() + ) + .simulationParameters( + BacktestResults.SimulationParameters.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType( + AuthRulesBacktestReportCreatedWebhookEvent.EventType + .AUTH_RULES_BACKTEST_REPORT_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofBalanceUpdated() { + val balanceUpdated = + BalanceUpdatedWebhookEvent.builder() + .addData( + FinancialAccountBalance.builder() + .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .availableAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .totalAmount(0L) + .type(FinancialAccountBalance.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType(BalanceUpdatedWebhookEvent.EventType.BALANCE_UPDATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofBalanceUpdated(balanceUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).isEmpty + assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty + assertThat(parsedWebhookEvent.balanceUpdated()).contains(balanceUpdated) + 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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofBalanceUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofBalanceUpdated( + BalanceUpdatedWebhookEvent.builder() + .addData( + FinancialAccountBalance.builder() + .token("3fa85f64-5717-4562-b3fc-2c963f66afa6") + .availableAmount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .lastTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .totalAmount(0L) + .type(FinancialAccountBalance.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .eventType(BalanceUpdatedWebhookEvent.EventType.BALANCE_UPDATED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofBookTransferTransactionCreated() { + val bookTransferTransactionCreated = + BookTransferTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_BALANCE_INQUIRY + ) + .build() + ) + .family(BookTransferResponse.Family.TRANSFER) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result(BookTransferResponse.TransactionResult.APPROVED) + .settledAmount(500L) + .status(BookTransferResponse.TransactionStatus.PENDING) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .eventType( + BookTransferTransactionCreatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofBookTransferTransactionCreated(bookTransferTransactionCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).isEmpty + assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty + assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionCreated()) + .contains(bookTransferTransactionCreated) + 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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofBookTransferTransactionCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofBookTransferTransactionCreated( + BookTransferTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_BALANCE_INQUIRY + ) + .build() + ) + .family(BookTransferResponse.Family.TRANSFER) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result(BookTransferResponse.TransactionResult.APPROVED) + .settledAmount(500L) + .status(BookTransferResponse.TransactionStatus.PENDING) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .eventType( + BookTransferTransactionCreatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofBookTransferTransactionUpdated() { + val bookTransferTransactionUpdated = + BookTransferTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_BALANCE_INQUIRY + ) + .build() + ) + .family(BookTransferResponse.Family.TRANSFER) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result(BookTransferResponse.TransactionResult.APPROVED) + .settledAmount(500L) + .status(BookTransferResponse.TransactionStatus.PENDING) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .eventType( + BookTransferTransactionUpdatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_UPDATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofBookTransferTransactionUpdated(bookTransferTransactionUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).isEmpty + assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty + assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionUpdated()) + .contains(bookTransferTransactionUpdated) + assertThat(parsedWebhookEvent.cardCreated()).isEmpty + assertThat(parsedWebhookEvent.cardConverted()).isEmpty + assertThat(parsedWebhookEvent.cardRenewed()).isEmpty + assertThat(parsedWebhookEvent.cardReissued()).isEmpty + assertThat(parsedWebhookEvent.cardShipped()).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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofBookTransferTransactionUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofBookTransferTransactionUpdated( + BookTransferTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(BookTransferResponse.BookTransferCategory.ADJUSTMENT) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addEvent( + BookTransferResponse.BookTransferEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + BookTransferResponse.BookTransferEvent.BookTransferDetailedResults + .APPROVED + ) + .memo("memo") + .result(BookTransferResponse.BookTransferEvent.Result.APPROVED) + .subtype("subtype") + .type( + BookTransferResponse.BookTransferEvent.BookTransferType + .ATM_BALANCE_INQUIRY + ) + .build() + ) + .family(BookTransferResponse.Family.TRANSFER) + .fromFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(1000L) + .result(BookTransferResponse.TransactionResult.APPROVED) + .settledAmount(500L) + .status(BookTransferResponse.TransactionStatus.PENDING) + .toFinancialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalId("external_id") + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .transactionSeries( + BookTransferResponse.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .eventType( + BookTransferTransactionUpdatedWebhookEvent.EventType + .BOOK_TRANSFER_TRANSACTION_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardCreated() { + val cardCreated = + CardCreatedWebhookEvent.builder() + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardCreatedWebhookEvent.EventType.CARD_CREATED) + .replacementFor("00000000-0000-0000-0000-000000000000") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofCardCreated(cardCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).isEmpty + assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty + assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardCreated()).contains(cardCreated) + assertThat(parsedWebhookEvent.cardConverted()).isEmpty + assertThat(parsedWebhookEvent.cardRenewed()).isEmpty + assertThat(parsedWebhookEvent.cardReissued()).isEmpty + assertThat(parsedWebhookEvent.cardShipped()).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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardCreated( + CardCreatedWebhookEvent.builder() + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardCreatedWebhookEvent.EventType.CARD_CREATED) + .replacementFor("00000000-0000-0000-0000-000000000000") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardConverted() { + val cardConverted = + CardConvertedWebhookEvent.builder() + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardConvertedWebhookEvent.EventType.CARD_CONVERTED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofCardConverted(cardConverted) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).isEmpty + assertThat(parsedWebhookEvent.authRulesBacktestReportCreated()).isEmpty + assertThat(parsedWebhookEvent.balanceUpdated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.bookTransferTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardCreated()).isEmpty + assertThat(parsedWebhookEvent.cardConverted()).contains(cardConverted) + assertThat(parsedWebhookEvent.cardRenewed()).isEmpty + assertThat(parsedWebhookEvent.cardReissued()).isEmpty + assertThat(parsedWebhookEvent.cardShipped()).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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardConvertedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardConverted( + CardConvertedWebhookEvent.builder() + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardConvertedWebhookEvent.EventType.CARD_CONVERTED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardRenewed() { + val cardRenewed = + CardRenewedWebhookEvent.builder() + .eventType(CardRenewedWebhookEvent.EventType.CARD_RENEWED) + .cardToken("00000000-0000-0000-0000-000000000001") + .expMonth("01") + .expYear("2030") + .previousExpMonth("01") + .previousExpYear("2024") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofCardRenewed(cardRenewed) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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()).contains(cardRenewed) + assertThat(parsedWebhookEvent.cardReissued()).isEmpty + assertThat(parsedWebhookEvent.cardShipped()).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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardRenewedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardRenewed( + CardRenewedWebhookEvent.builder() + .eventType(CardRenewedWebhookEvent.EventType.CARD_RENEWED) + .cardToken("00000000-0000-0000-0000-000000000001") + .expMonth("01") + .expYear("2030") + .previousExpMonth("01") + .previousExpYear("2024") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardReissued() { + val cardReissued = + CardReissuedWebhookEvent.builder() + .eventType(CardReissuedWebhookEvent.EventType.CARD_REISSUED) + .cardToken("00000000-0000-0000-0000-000000000001") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofCardReissued(cardReissued) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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()).contains(cardReissued) + assertThat(parsedWebhookEvent.cardShipped()).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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardReissuedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardReissued( + CardReissuedWebhookEvent.builder() + .eventType(CardReissuedWebhookEvent.EventType.CARD_REISSUED) + .cardToken("00000000-0000-0000-0000-000000000001") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardShipped() { + val cardShipped = + CardShippedWebhookEvent.builder() + .bulkOrderToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardShippedWebhookEvent.EventType.CARD_SHIPPED) + .shippingMethod( + CardShippedWebhookEvent.ShippingMethod.USPS_WITHOUT_TRACKING_ENVELOPE + ) + .trackingNumber("1Z9999999999999999") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofCardShipped(cardShipped) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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()).contains(cardShipped) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardShippedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardShipped( + CardShippedWebhookEvent.builder() + .bulkOrderToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .eventType(CardShippedWebhookEvent.EventType.CARD_SHIPPED) + .shippingMethod( + CardShippedWebhookEvent.ShippingMethod.USPS_WITHOUT_TRACKING_ENVELOPE + ) + .trackingNumber("1Z9999999999999999") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardTransactionUpdated() { + val cardTransactionUpdated = + CardTransactionUpdatedWebhookEvent.builder() + .token("c30c2182-1e69-4e0d-b40f-eec0d2a19123") + .accountToken("db3942f0-0627-4887-a190-1ea83b46d091") + .acquirerFee(0L) + .acquirerReferenceNumber(null) + .amount(1800L) + .amounts( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(-1800L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(1800L) + .authorizationCode("071471") + .avs( + Transaction.Avs.builder() + .address("123 Evergreen Terrace") + .zipcode("95006") + .build() + ) + .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult(CardholderAuthentication.AuthenticationResult.SUCCESS) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift(CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED) + .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .financialAccountToken("a3b113e8-01fe-42d3-b900-b9adf3f15496") + .merchant( + Merchant.builder() + .acceptorId("452322000053360") + .acquiringInstitutionId("333301802529120") + .city("gosq.com") + .country("USA") + .descriptor("SQ *SOMA EATS") + .mcc("5812") + .state("CA") + .build() + ) + .merchantAmount(1800L) + .merchantAuthorizationAmount(1800L) + .merchantCurrency("USD") + .network(Transaction.Network.MASTERCARD) + .networkRiskScore(5L) + .pos( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder(Transaction.Pos.PosEntryMode.Cardholder.NOT_PRESENT) + .pan(Transaction.Pos.PosEntryMode.Pan.ECOMMERCE) + .pinEntered(false) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(false) + .cardRetentionCapable(false) + .onPremise(false) + .operator(Transaction.Pos.PosTerminal.Operator.UNKNOWN) + .partialApprovalCapable(false) + .pinCapability( + Transaction.Pos.PosTerminal.PinCapability.NOT_CAPABLE + ) + .type(Transaction.Pos.PosTerminal.Type.UNKNOWN) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + .result(Transaction.DeclineResult.APPROVED) + .settledAmount(0L) + .status(Transaction.Status.PENDING) + .tokenInfo(TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build()) + .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addEvent( + Transaction.TransactionEvent.builder() + .token("bbbf1e86-322d-11ee-9779-00505685a123") + .amount(1800L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts.Cardholder + .builder() + .amount(1800L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts.Merchant + .builder() + .amount(1800L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts.Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber(null) + .retrievalReferenceNumber("064386558597") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard.builder() + .banknetReferenceNumber("U1HSCJ") + .originalBanknetReferenceNumber(null) + .originalSwitchSerialNumber(null) + .switchSerialNumber(null) + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result( + Transaction.TransactionEvent.RuleResult.DetailedResult.APPROVED + ) + .build() + ) + .type(Transaction.TransactionEvent.Type.AUTHORIZATION) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + .eventType(CardTransactionUpdatedWebhookEvent.EventType.CARD_TRANSACTION_UPDATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofCardTransactionUpdated(cardTransactionUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.cardTransactionUpdated()).contains(cardTransactionUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardTransactionUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardTransactionUpdated( + CardTransactionUpdatedWebhookEvent.builder() + .token("c30c2182-1e69-4e0d-b40f-eec0d2a19123") + .accountToken("db3942f0-0627-4887-a190-1ea83b46d091") + .acquirerFee(0L) + .acquirerReferenceNumber(null) + .amount(1800L) + .amounts( + Transaction.TransactionAmounts.builder() + .cardholder( + Transaction.TransactionAmounts.Cardholder.builder() + .amount(0L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .hold( + Transaction.TransactionAmounts.Hold.builder() + .amount(-1800L) + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionAmounts.Merchant.builder() + .amount(0L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionAmounts.Settlement.builder() + .amount(0L) + .currency("USD") + .build() + ) + .build() + ) + .authorizationAmount(1800L) + .authorizationCode("071471") + .avs( + Transaction.Avs.builder() + .address("123 Evergreen Terrace") + .zipcode("95006") + .build() + ) + .cardToken("aac502f9-aecc-458a-954e-4bcf6edb6123") + .cardholderAuthentication( + CardholderAuthentication.builder() + .authenticationMethod( + CardholderAuthentication.AuthenticationMethod.FRICTIONLESS + ) + .authenticationResult( + CardholderAuthentication.AuthenticationResult.SUCCESS + ) + .decisionMadeBy(CardholderAuthentication.DecisionMadeBy.NETWORK) + .liabilityShift( + CardholderAuthentication.LiabilityShift._3DS_AUTHENTICATED + ) + .threeDSAuthenticationToken("fc60d37d-95f7-419c-b628-dd9fbf9d80d0") + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .financialAccountToken("a3b113e8-01fe-42d3-b900-b9adf3f15496") + .merchant( + Merchant.builder() + .acceptorId("452322000053360") + .acquiringInstitutionId("333301802529120") + .city("gosq.com") + .country("USA") + .descriptor("SQ *SOMA EATS") + .mcc("5812") + .state("CA") + .build() + ) + .merchantAmount(1800L) + .merchantAuthorizationAmount(1800L) + .merchantCurrency("USD") + .network(Transaction.Network.MASTERCARD) + .networkRiskScore(5L) + .pos( + Transaction.Pos.builder() + .entryMode( + Transaction.Pos.PosEntryMode.builder() + .card(Transaction.Pos.PosEntryMode.Card.NOT_PRESENT) + .cardholder(Transaction.Pos.PosEntryMode.Cardholder.NOT_PRESENT) + .pan(Transaction.Pos.PosEntryMode.Pan.ECOMMERCE) + .pinEntered(false) + .build() + ) + .terminal( + Transaction.Pos.PosTerminal.builder() + .attended(false) + .cardRetentionCapable(false) + .onPremise(false) + .operator(Transaction.Pos.PosTerminal.Operator.UNKNOWN) + .partialApprovalCapable(false) + .pinCapability( + Transaction.Pos.PosTerminal.PinCapability.NOT_CAPABLE + ) + .type(Transaction.Pos.PosTerminal.Type.UNKNOWN) + .acceptorTerminalId("acceptor_terminal_id") + .build() + ) + .build() + ) + .result(Transaction.DeclineResult.APPROVED) + .settledAmount(0L) + .status(Transaction.Status.PENDING) + .tokenInfo( + TokenInfo.builder().walletType(TokenInfo.WalletType.APPLE_PAY).build() + ) + .updated(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addEvent( + Transaction.TransactionEvent.builder() + .token("bbbf1e86-322d-11ee-9779-00505685a123") + .amount(1800L) + .amounts( + Transaction.TransactionEvent.TransactionEventAmounts.builder() + .cardholder( + Transaction.TransactionEvent.TransactionEventAmounts + .Cardholder + .builder() + .amount(1800L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .merchant( + Transaction.TransactionEvent.TransactionEventAmounts + .Merchant + .builder() + .amount(1800L) + .currency("USD") + .build() + ) + .settlement( + Transaction.TransactionEvent.TransactionEventAmounts + .Settlement + .builder() + .amount(1000L) + .conversionRate("1.000000") + .currency("USD") + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2023-08-03T18:42:30Z")) + .addDetailedResult(Transaction.TransactionEvent.DetailedResult.APPROVED) + .effectivePolarity(Transaction.TransactionEvent.EffectivePolarity.DEBIT) + .networkInfo( + Transaction.TransactionEvent.NetworkInfo.builder() + .acquirer( + Transaction.TransactionEvent.NetworkInfo.Acquirer.builder() + .acquirerReferenceNumber(null) + .retrievalReferenceNumber("064386558597") + .build() + ) + .amex( + Transaction.TransactionEvent.NetworkInfo.Amex.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .mastercard( + Transaction.TransactionEvent.NetworkInfo.Mastercard + .builder() + .banknetReferenceNumber("U1HSCJ") + .originalBanknetReferenceNumber(null) + .originalSwitchSerialNumber(null) + .switchSerialNumber(null) + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkInfo.Visa.builder() + .originalTransactionId("original_transaction_id") + .transactionId("transaction_id") + .build() + ) + .build() + ) + .result(Transaction.TransactionEvent.DeclineResult.APPROVED) + .addRuleResult( + Transaction.TransactionEvent.RuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result( + Transaction.TransactionEvent.RuleResult.DetailedResult + .APPROVED + ) + .build() + ) + .type(Transaction.TransactionEvent.Type.AUTHORIZATION) + .accountType(Transaction.TransactionEvent.AccountType.CHECKING) + .networkSpecificData( + Transaction.TransactionEvent.NetworkSpecificData.builder() + .mastercard( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .builder() + .ecommerceSecurityLevelIndicator("xxx") + .addOnBehalfServiceResult( + Transaction.TransactionEvent.NetworkSpecificData + .MastercardNetworkSpecificData + .OnBehalfServiceResult + .builder() + .result1("x") + .result2("x") + .service("xx") + .build() + ) + .transactionTypeIdentifier("xxx") + .build() + ) + .visa( + Transaction.TransactionEvent.NetworkSpecificData + .VisaNetworkSpecificData + .builder() + .businessApplicationIdentifier("xx") + .build() + ) + .build() + ) + .build() + ) + .eventType( + CardTransactionUpdatedWebhookEvent.EventType.CARD_TRANSACTION_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardTransactionEnhancedDataCreated() { + val cardTransactionEnhancedDataCreated = + CardTransactionEnhancedDataCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .common( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt( + EnhancedData.CommonData.TaxData.TaxExemptIndicator.TAX_INCLUDED + ) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFleet( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure( + EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS + ) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType( + CardTransactionEnhancedDataCreatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardTransactionEnhancedDataCreated( + cardTransactionEnhancedDataCreated + ) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.cardTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataCreated()) + .contains(cardTransactionEnhancedDataCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardTransactionEnhancedDataCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardTransactionEnhancedDataCreated( + CardTransactionEnhancedDataCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .common( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt( + EnhancedData.CommonData.TaxData.TaxExemptIndicator + .TAX_INCLUDED + ) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFleet( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure( + EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS + ) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType( + CardTransactionEnhancedDataCreatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofCardTransactionEnhancedDataUpdated() { + val cardTransactionEnhancedDataUpdated = + CardTransactionEnhancedDataUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .common( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt( + EnhancedData.CommonData.TaxData.TaxExemptIndicator.TAX_INCLUDED + ) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFleet( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure( + EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS + ) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType( + CardTransactionEnhancedDataUpdatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_UPDATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardTransactionEnhancedDataUpdated( + cardTransactionEnhancedDataUpdated + ) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.cardTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataCreated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataUpdated()) + .contains(cardTransactionEnhancedDataUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofCardTransactionEnhancedDataUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofCardTransactionEnhancedDataUpdated( + CardTransactionEnhancedDataUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .common( + EnhancedData.CommonData.builder() + .addLineItem( + EnhancedData.CommonData.LineItem.builder() + .amount("amount") + .description("description") + .productCode("product_code") + .quantity("quantity") + .build() + ) + .tax( + EnhancedData.CommonData.TaxData.builder() + .amount(0L) + .exempt( + EnhancedData.CommonData.TaxData.TaxExemptIndicator + .TAX_INCLUDED + ) + .merchantTaxId("merchant_tax_id") + .build() + ) + .customerReferenceNumber("customer_reference_number") + .merchantReferenceNumber("merchant_reference_number") + .orderDate(LocalDate.parse("2019-12-27")) + .build() + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addFleet( + EnhancedData.Fleet.builder() + .amountTotals( + EnhancedData.Fleet.AmountTotals.builder() + .discount(0L) + .grossSale(0L) + .netSale(0L) + .build() + ) + .fuel( + EnhancedData.Fleet.FuelData.builder() + .quantity("quantity") + .type(EnhancedData.Fleet.FuelData.FuelType.UNKNOWN) + .unitOfMeasure( + EnhancedData.Fleet.FuelData.FuelUnitOfMeasure.GALLONS + ) + .unitPrice(0L) + .build() + ) + .driverNumber("driver_number") + .odometer(0L) + .serviceType(EnhancedData.Fleet.ServiceType.UNKNOWN) + .vehicleNumber("vehicle_number") + .build() + ) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType( + CardTransactionEnhancedDataUpdatedWebhookEvent.EventType + .CARD_TRANSACTION_ENHANCED_DATA_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDigitalWalletTokenizationApprovalRequest() { + val digitalWalletTokenizationApprovalRequest = + DigitalWalletTokenizationApprovalRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerTokenizationDecision( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .builder() + .outcome( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + .eventType( + DigitalWalletTokenizationApprovalRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision( + DigitalWalletTokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED + ) + .tokenizationChannel( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationChannel + .DIGITAL_WALLET + ) + .tokenizationToken("tokenization_token") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .tokenizationSource( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationSource + .PUSH_PROVISION + ) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationApprovalRequest( + digitalWalletTokenizationApprovalRequest + ) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.cardTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataCreated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataUpdated()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationApprovalRequest()) + .contains(digitalWalletTokenizationApprovalRequest) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofDigitalWalletTokenizationApprovalRequestRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationApprovalRequest( + DigitalWalletTokenizationApprovalRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerTokenizationDecision( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .builder() + .outcome( + DigitalWalletTokenizationApprovalRequestWebhookEvent + .CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + .eventType( + DigitalWalletTokenizationApprovalRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision( + DigitalWalletTokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED + ) + .tokenizationChannel( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationChannel + .DIGITAL_WALLET + ) + .tokenizationToken("tokenization_token") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo + .AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName( + DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY + ) + .build() + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .tokenizationSource( + DigitalWalletTokenizationApprovalRequestWebhookEvent.TokenizationSource + .PUSH_PROVISION + ) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDigitalWalletTokenizationResult() { + val digitalWalletTokenizationResult = + DigitalWalletTokenizationResultWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationResultWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_RESULT + ) + .tokenizationResultDetails( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationResult(digitalWalletTokenizationResult) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.cardTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataCreated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataUpdated()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationResult()) + .contains(digitalWalletTokenizationResult) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofDigitalWalletTokenizationResultRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationResult( + DigitalWalletTokenizationResultWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationResultWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_RESULT + ) + .tokenizationResultDetails( + DigitalWalletTokenizationResultWebhookEvent.TokenizationResultDetails + .builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent + .TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + DigitalWalletTokenizationResultWebhookEvent + .TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDigitalWalletTokenizationTwoFactorAuthenticationCode() { + val digitalWalletTokenizationTwoFactorAuthenticationCode = + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .authenticationCode("123456") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationTwoFactorAuthenticationCode( + digitalWalletTokenizationTwoFactorAuthenticationCode + ) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.cardTransactionUpdated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataCreated()).isEmpty + assertThat(parsedWebhookEvent.cardTransactionEnhancedDataUpdated()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationResult()).isEmpty + assertThat(parsedWebhookEvent.digitalWalletTokenizationTwoFactorAuthenticationCode()) + .contains(digitalWalletTokenizationTwoFactorAuthenticationCode) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofDigitalWalletTokenizationTwoFactorAuthenticationCodeRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationTwoFactorAuthenticationCode( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .authenticationCode("123456") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDigitalWalletTokenizationTwoFactorAuthenticationCodeSent() { + val digitalWalletTokenizationTwoFactorAuthenticationCodeSent = + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationTwoFactorAuthenticationCodeSent( + digitalWalletTokenizationTwoFactorAuthenticationCodeSent + ) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(digitalWalletTokenizationTwoFactorAuthenticationCodeSent) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofDigitalWalletTokenizationTwoFactorAuthenticationCodeSentRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationTwoFactorAuthenticationCodeSent( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .builder() + .type( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .EventType + .DIGITAL_WALLET_TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDigitalWalletTokenizationUpdated() { + val digitalWalletTokenizationUpdated = + DigitalWalletTokenizationUpdatedWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationUpdatedWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_UPDATED + ) + .tokenization( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason( + TokenizationDeclineReason.ACCOUNT_SCORE_1 + ) + .addTokenizationTfaReason( + TokenizationTfaReason.WALLET_RECOMMENDED_TFA + ) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationUpdated(digitalWalletTokenizationUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(digitalWalletTokenizationUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofDigitalWalletTokenizationUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDigitalWalletTokenizationUpdated( + DigitalWalletTokenizationUpdatedWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + DigitalWalletTokenizationUpdatedWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_UPDATED + ) + .tokenization( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome + .APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason( + TokenizationDeclineReason.ACCOUNT_SCORE_1 + ) + .addTokenizationTfaReason( + TokenizationTfaReason.WALLET_RECOMMENDED_TFA + ) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDisputeUpdated() { + val disputeUpdated = + DisputeUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .arbitrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerFiledDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerNote("customer_note") + .addNetworkClaimId("string") + .networkFiledDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkReasonCode("network_reason_code") + .prearbitrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .primaryClaimId("primary_claim_id") + .reason(Dispute.Reason.ATM_CASH_MISDISPENSE) + .representmentDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resolutionDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resolutionNote("resolution_note") + .resolutionReason(Dispute.ResolutionReason.CASE_LOST) + .status(Dispute.Status.ARBITRATION) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType(DisputeUpdatedWebhookEvent.EventType.DISPUTE_UPDATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofDisputeUpdated(disputeUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(disputeUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofDisputeUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDisputeUpdated( + DisputeUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .arbitrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerFiledDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerNote("customer_note") + .addNetworkClaimId("string") + .networkFiledDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .networkReasonCode("network_reason_code") + .prearbitrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .primaryClaimId("primary_claim_id") + .reason(Dispute.Reason.ATM_CASH_MISDISPENSE) + .representmentDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resolutionDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .resolutionNote("resolution_note") + .resolutionReason(Dispute.ResolutionReason.CASE_LOST) + .status(Dispute.Status.ARBITRATION) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .eventType(DisputeUpdatedWebhookEvent.EventType.DISPUTE_UPDATED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDisputeEvidenceUploadFailed() { + val disputeEvidenceUploadFailed = + DisputeEvidenceUploadFailedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .uploadStatus(DisputeEvidence.UploadStatus.DELETED) + .downloadUrl("download_url") + .filename("filename") + .uploadUrl("upload_url") + .eventType( + DisputeEvidenceUploadFailedWebhookEvent.EventType.DISPUTE_EVIDENCE_UPLOAD_FAILED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofDisputeEvidenceUploadFailed(disputeEvidenceUploadFailed) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(disputeEvidenceUploadFailed) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofDisputeEvidenceUploadFailedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDisputeEvidenceUploadFailed( + DisputeEvidenceUploadFailedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .uploadStatus(DisputeEvidence.UploadStatus.DELETED) + .downloadUrl("download_url") + .filename("filename") + .uploadUrl("upload_url") + .eventType( + DisputeEvidenceUploadFailedWebhookEvent.EventType + .DISPUTE_EVIDENCE_UPLOAD_FAILED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofExternalBankAccountCreated() { + val externalBankAccountCreated = + ExternalBankAccountCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .country("country") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastFour("last_four") + .owner("owner") + .ownerType(OwnerType.INDIVIDUAL) + .routingNumber("routing_number") + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) + .verificationAttempts(0L) + .verificationMethod(VerificationMethod.MANUAL) + .verificationState(ExternalBankAccount.VerificationState.PENDING) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + .companyId("company_id") + .dob(LocalDate.parse("2019-12-27")) + .doingBusinessAs("doing_business_as") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .userDefinedId("user_defined_id") + .verificationFailedReason("verification_failed_reason") + .eventType( + ExternalBankAccountCreatedWebhookEvent.EventType.EXTERNAL_BANK_ACCOUNT_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofExternalBankAccountCreated(externalBankAccountCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(externalBankAccountCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofExternalBankAccountCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofExternalBankAccountCreated( + ExternalBankAccountCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .country("country") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastFour("last_four") + .owner("owner") + .ownerType(OwnerType.INDIVIDUAL) + .routingNumber("routing_number") + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) + .verificationAttempts(0L) + .verificationMethod(VerificationMethod.MANUAL) + .verificationState(ExternalBankAccount.VerificationState.PENDING) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + .companyId("company_id") + .dob(LocalDate.parse("2019-12-27")) + .doingBusinessAs("doing_business_as") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .userDefinedId("user_defined_id") + .verificationFailedReason("verification_failed_reason") + .eventType( + ExternalBankAccountCreatedWebhookEvent.EventType + .EXTERNAL_BANK_ACCOUNT_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofExternalBankAccountUpdated() { + val externalBankAccountUpdated = + ExternalBankAccountUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .country("country") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastFour("last_four") + .owner("owner") + .ownerType(OwnerType.INDIVIDUAL) + .routingNumber("routing_number") + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) + .verificationAttempts(0L) + .verificationMethod(VerificationMethod.MANUAL) + .verificationState(ExternalBankAccount.VerificationState.PENDING) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + .companyId("company_id") + .dob(LocalDate.parse("2019-12-27")) + .doingBusinessAs("doing_business_as") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .userDefinedId("user_defined_id") + .verificationFailedReason("verification_failed_reason") + .eventType( + ExternalBankAccountUpdatedWebhookEvent.EventType.EXTERNAL_BANK_ACCOUNT_UPDATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofExternalBankAccountUpdated(externalBankAccountUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(externalBankAccountUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofExternalBankAccountUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofExternalBankAccountUpdated( + ExternalBankAccountUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .country("country") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .lastFour("last_four") + .owner("owner") + .ownerType(OwnerType.INDIVIDUAL) + .routingNumber("routing_number") + .state(ExternalBankAccount.State.ENABLED) + .type(ExternalBankAccount.AccountType.CHECKING) + .verificationAttempts(0L) + .verificationMethod(VerificationMethod.MANUAL) + .verificationState(ExternalBankAccount.VerificationState.PENDING) + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .address( + ExternalBankAccountAddress.builder() + .address1("x") + .city("x") + .country("USD") + .postalCode("11201") + .state("xx") + .address2("x") + .build() + ) + .companyId("company_id") + .dob(LocalDate.parse("2019-12-27")) + .doingBusinessAs("doing_business_as") + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .name("name") + .userDefinedId("user_defined_id") + .verificationFailedReason("verification_failed_reason") + .eventType( + ExternalBankAccountUpdatedWebhookEvent.EventType + .EXTERNAL_BANK_ACCOUNT_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofExternalPaymentCreated() { + val externalPaymentCreated = + ExternalPaymentCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .family(ExternalPayment.Family.EXTERNAL_PAYMENT) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .eventType(ExternalPaymentCreatedWebhookEvent.EventType.EXTERNAL_PAYMENT_CREATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofExternalPaymentCreated(externalPaymentCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(externalPaymentCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofExternalPaymentCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofExternalPaymentCreated( + ExternalPaymentCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .family(ExternalPayment.Family.EXTERNAL_PAYMENT) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .eventType( + ExternalPaymentCreatedWebhookEvent.EventType.EXTERNAL_PAYMENT_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofExternalPaymentUpdated() { + val externalPaymentUpdated = + ExternalPaymentUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .family(ExternalPayment.Family.EXTERNAL_PAYMENT) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .eventType(ExternalPaymentUpdatedWebhookEvent.EventType.EXTERNAL_PAYMENT_UPDATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofExternalPaymentUpdated(externalPaymentUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(externalPaymentUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofExternalPaymentUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofExternalPaymentUpdated( + ExternalPaymentUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ExternalPayment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ExternalPayment.ExternalPaymentCategory.EXTERNAL_WIRE) + .currency("currency") + .addEvent( + ExternalPayment.ExternalPaymentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ExternalPayment.ExternalPaymentEvent.DetailedResults.APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result(ExternalPayment.ExternalPaymentEvent.TransactionResult.APPROVED) + .type( + ExternalPayment.ExternalPaymentEvent.ExternalPaymentEventType + .EXTERNAL_WIRE_INITIATED + ) + .build() + ) + .family(ExternalPayment.Family.EXTERNAL_PAYMENT) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentType(ExternalPayment.ExternalPaymentDirection.DEPOSIT) + .pendingAmount(0L) + .result(ExternalPayment.TransactionResult.APPROVED) + .settledAmount(0L) + .userDefinedId("user_defined_id") + .eventType( + ExternalPaymentUpdatedWebhookEvent.EventType.EXTERNAL_PAYMENT_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofFinancialAccountCreated() { + val financialAccountCreated = + FinancialAccountCreatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + .isForBenefitOf(true) + .nickname("nickname") + .status(FinancialAccount.FinancialAccountStatus.OPEN) + .type(FinancialAccount.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accountNumber("account_number") + .routingNumber("routing_number") + .substatus(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + .eventType(FinancialAccountCreatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_CREATED) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofFinancialAccountCreated(financialAccountCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(financialAccountCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofFinancialAccountCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofFinancialAccountCreated( + FinancialAccountCreatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + .isForBenefitOf(true) + .nickname("nickname") + .status(FinancialAccount.FinancialAccountStatus.OPEN) + .type(FinancialAccount.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accountNumber("account_number") + .routingNumber("routing_number") + .substatus(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + .eventType( + FinancialAccountCreatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofFinancialAccountUpdated() { + val financialAccountUpdated = + FinancialAccountUpdatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + .isForBenefitOf(true) + .nickname("nickname") + .status(FinancialAccount.FinancialAccountStatus.OPEN) + .type(FinancialAccount.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accountNumber("account_number") + .routingNumber("routing_number") + .substatus(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + .eventType(FinancialAccountUpdatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_UPDATED) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofFinancialAccountUpdated(financialAccountUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(financialAccountUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofFinancialAccountUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofFinancialAccountUpdated( + FinancialAccountUpdatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditConfiguration( + FinancialAccount.FinancialAccountCreditConfig.builder() + .autoCollectionConfiguration( + FinancialAccount.FinancialAccountCreditConfig + .AutoCollectionConfigurationResponse + .builder() + .autoCollectionEnabled(true) + .build() + ) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .externalBankAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .tier("tier") + .build() + ) + .isForBenefitOf(true) + .nickname("nickname") + .status(FinancialAccount.FinancialAccountStatus.OPEN) + .type(FinancialAccount.Type.ISSUING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .accountNumber("account_number") + .routingNumber("routing_number") + .substatus(FinancialAccount.FinancialAccountSubstatus.CHARGED_OFF_DELINQUENT) + .eventType( + FinancialAccountUpdatedWebhookEvent.EventType.FINANCIAL_ACCOUNT_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofFundingEventCreated() { + val fundingEventCreated = + FundingEventCreatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) + .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") + .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .addNetworkSettlementSummary( + FundingEvent.FundingEventSettlement.builder() + .networkSettlementDate(LocalDate.parse("2024-01-01")) + .settledGrossAmount(0L) + .build() + ) + .previousHighWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .eventType(FundingEventCreatedWebhookEvent.EventType.FUNDING_EVENT_CREATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofFundingEventCreated(fundingEventCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(fundingEventCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofFundingEventCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofFundingEventCreated( + FundingEventCreatedWebhookEvent.builder() + .token("b68b7424-aa69-4cbc-a946-30d90181b621") + .collectionResourceType(FundingEvent.CollectionResourceType.PAYMENT) + .addCollectionToken("b68b7424-aa69-4cbc-a946-30d90181b621") + .created(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .highWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .addNetworkSettlementSummary( + FundingEvent.FundingEventSettlement.builder() + .networkSettlementDate(LocalDate.parse("2024-01-01")) + .settledGrossAmount(0L) + .build() + ) + .previousHighWatermark(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .updated(OffsetDateTime.parse("2024-01-01T00:00:00Z")) + .eventType(FundingEventCreatedWebhookEvent.EventType.FUNDING_EVENT_CREATED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofLoanTapeCreated() { + val loanTapeCreated = + LoanTapeCreatedWebhookEvent.builder() + .token("token") + .accountStanding( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + .availableCredit(0L) + .balances( + LoanTape.Balances.builder() + .due(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .nextStatementDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastStatementsDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .date(LocalDate.parse("2019-12-27")) + .dayTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .endingBalance(0L) + .excessCredits(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .interestDetails( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .minimumPaymentBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .paymentAllocation( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .previousStatementBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .startingBalance(0L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .tier("tier") + .eventType(LoanTapeCreatedWebhookEvent.EventType.LOAN_TAPE_CREATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofLoanTapeCreated(loanTapeCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(loanTapeCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofLoanTapeCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofLoanTapeCreated( + LoanTapeCreatedWebhookEvent.builder() + .token("token") + .accountStanding( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + .availableCredit(0L) + .balances( + LoanTape.Balances.builder() + .due( + CategoryBalances.builder() + .fees(0L) + .interest(0L) + .principal(0L) + .build() + ) + .nextStatementDue( + CategoryBalances.builder() + .fees(0L) + .interest(0L) + .principal(0L) + .build() + ) + .pastDue( + CategoryBalances.builder() + .fees(0L) + .interest(0L) + .principal(0L) + .build() + ) + .pastStatementsDue( + CategoryBalances.builder() + .fees(0L) + .interest(0L) + .principal(0L) + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .date(LocalDate.parse("2019-12-27")) + .dayTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .endingBalance(0L) + .excessCredits(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .interestDetails( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .minimumPaymentBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .paymentAllocation( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .previousStatementBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .startingBalance(0L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .tier("tier") + .eventType(LoanTapeCreatedWebhookEvent.EventType.LOAN_TAPE_CREATED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofLoanTapeUpdated() { + val loanTapeUpdated = + LoanTapeUpdatedWebhookEvent.builder() + .token("token") + .accountStanding( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + .availableCredit(0L) + .balances( + LoanTape.Balances.builder() + .due(CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build()) + .nextStatementDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .pastStatementsDue( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .date(LocalDate.parse("2019-12-27")) + .dayTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .endingBalance(0L) + .excessCredits(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .interestDetails( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .minimumPaymentBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .paymentAllocation( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .previousStatementBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .startingBalance(0L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .tier("tier") + .eventType(LoanTapeUpdatedWebhookEvent.EventType.LOAN_TAPE_UPDATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofLoanTapeUpdated(loanTapeUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(loanTapeUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofLoanTapeUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofLoanTapeUpdated( + LoanTapeUpdatedWebhookEvent.builder() + .token("token") + .accountStanding( + LoanTape.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + LoanTape.AccountStanding.FinancialAccountState.builder() + .status( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + LoanTape.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(LoanTape.AccountStanding.PeriodState.STANDARD) + .build() + ) + .availableCredit(0L) + .balances( + LoanTape.Balances.builder() + .due( + CategoryBalances.builder() + .fees(0L) + .interest(0L) + .principal(0L) + .build() + ) + .nextStatementDue( + CategoryBalances.builder() + .fees(0L) + .interest(0L) + .principal(0L) + .build() + ) + .pastDue( + CategoryBalances.builder() + .fees(0L) + .interest(0L) + .principal(0L) + .build() + ) + .pastStatementsDue( + CategoryBalances.builder() + .fees(0L) + .interest(0L) + .principal(0L) + .build() + ) + .build() + ) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .date(LocalDate.parse("2019-12-27")) + .dayTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .endingBalance(0L) + .excessCredits(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .interestDetails( + LoanTape.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + LoanTape.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .minimumPaymentBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .paymentAllocation( + CategoryBalances.builder().fees(0L).interest(0L).principal(0L).build() + ) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .previousStatementBalance( + LoanTape.BalanceDetails.builder().amount(0L).remaining(0L).build() + ) + .startingBalance(0L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .version(0L) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .tier("tier") + .eventType(LoanTapeUpdatedWebhookEvent.EventType.LOAN_TAPE_UPDATED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofManagementOperationCreated() { + val managementOperationCreated = + ManagementOperationCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .family(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .eventType( + ManagementOperationCreatedWebhookEvent.EventType.MANAGEMENT_OPERATION_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofManagementOperationCreated(managementOperationCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(managementOperationCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofManagementOperationCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofManagementOperationCreated( + ManagementOperationCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category( + ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE + ) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent + .DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .family(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .eventType( + ManagementOperationCreatedWebhookEvent.EventType + .MANAGEMENT_OPERATION_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofManagementOperationUpdated() { + val managementOperationUpdated = + ManagementOperationUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category(ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent.DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .family(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .eventType( + ManagementOperationUpdatedWebhookEvent.EventType.MANAGEMENT_OPERATION_UPDATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofManagementOperationUpdated(managementOperationUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(managementOperationUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofManagementOperationUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofManagementOperationUpdated( + ManagementOperationUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .status(ManagementOperationTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .category( + ManagementOperationTransaction.ManagementOperationCategory.MANAGEMENT_FEE + ) + .currency("currency") + .direction(ManagementOperationTransaction.ManagementOperationDirection.CREDIT) + .addEvent( + ManagementOperationTransaction.ManagementOperationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addDetailedResult( + ManagementOperationTransaction.ManagementOperationEvent + .DetailedResults + .APPROVED + ) + .effectiveDate(LocalDate.parse("2019-12-27")) + .memo("memo") + .result( + ManagementOperationTransaction.ManagementOperationEvent + .TransactionResult + .APPROVED + ) + .type( + ManagementOperationTransaction.ManagementOperationEvent + .ManagementOperationEventType + .LOSS_WRITE_OFF + ) + .subtype("subtype") + .build() + ) + .externalResource( + ExternalResource.builder() + .externalResourceToken("external_resource_token") + .externalResourceType(ExternalResourceType.STATEMENT) + .externalResourceSubToken("external_resource_sub_token") + .build() + ) + .family(ManagementOperationTransaction.Family.MANAGEMENT_OPERATION) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pendingAmount(0L) + .result(ManagementOperationTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .transactionSeries( + ManagementOperationTransaction.TransactionSeries.builder() + .relatedTransactionEventToken("123e4567-e89b-12d3-a456-426614174000") + .relatedTransactionToken("123e4567-e89b-12d3-a456-426614174000") + .type("FEE") + .build() + ) + .userDefinedId("user_defined_id") + .eventType( + ManagementOperationUpdatedWebhookEvent.EventType + .MANAGEMENT_OPERATION_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofInternalTransactionCreated() { + val internalTransactionCreated = + InternalTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED + ) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + InternalTransactionCreatedWebhookEvent.EventType.INTERNAL_TRANSACTION_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofInternalTransactionCreated(internalTransactionCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(internalTransactionCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofInternalTransactionCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofInternalTransactionCreated( + InternalTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult + .APPROVED + ) + .type( + InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT + ) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + InternalTransactionCreatedWebhookEvent.EventType + .INTERNAL_TRANSACTION_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofInternalTransactionUpdated() { + val internalTransactionUpdated = + InternalTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult.APPROVED + ) + .type(InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + InternalTransactionUpdatedWebhookEvent.EventType.INTERNAL_TRANSACTION_UPDATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofInternalTransactionUpdated(internalTransactionUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(internalTransactionUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofInternalTransactionUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofInternalTransactionUpdated( + InternalTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .category(InternalTransaction.Category.INTERNAL) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("currency") + .descriptor("descriptor") + .addEvent( + InternalTransaction.InternalAdjustmentEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .amount(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + InternalTransaction.InternalAdjustmentEvent.TransactionResult + .APPROVED + ) + .type( + InternalTransaction.InternalAdjustmentEvent.Type.INTERNAL_ADJUSTMENT + ) + .build() + ) + .pendingAmount(0L) + .result(InternalTransaction.TransactionResult.APPROVED) + .settledAmount(0L) + .status(InternalTransaction.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + InternalTransactionUpdatedWebhookEvent.EventType + .INTERNAL_TRANSACTION_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofNetworkTotalCreated() { + val networkTotalCreated = + NetworkTotalCreatedWebhookEvent.builder() + .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + .amounts( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .currency("CAD") + .institutionId("1000000000") + .isComplete(true) + .network(NetworkTotal.Network.VISA) + .reportDate(LocalDate.parse("2025-02-25")) + .settlementInstitutionId("1000000001") + .settlementService("015") + .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .cycle(0L) + .eventType(NetworkTotalCreatedWebhookEvent.EventType.NETWORK_TOTAL_CREATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofNetworkTotalCreated(networkTotalCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(networkTotalCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofNetworkTotalCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofNetworkTotalCreated( + NetworkTotalCreatedWebhookEvent.builder() + .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + .amounts( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .currency("CAD") + .institutionId("1000000000") + .isComplete(true) + .network(NetworkTotal.Network.VISA) + .reportDate(LocalDate.parse("2025-02-25")) + .settlementInstitutionId("1000000001") + .settlementService("015") + .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .cycle(0L) + .eventType(NetworkTotalCreatedWebhookEvent.EventType.NETWORK_TOTAL_CREATED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofNetworkTotalUpdated() { + val networkTotalUpdated = + NetworkTotalUpdatedWebhookEvent.builder() + .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + .amounts( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .currency("CAD") + .institutionId("1000000000") + .isComplete(true) + .network(NetworkTotal.Network.VISA) + .reportDate(LocalDate.parse("2025-02-25")) + .settlementInstitutionId("1000000001") + .settlementService("015") + .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .cycle(0L) + .eventType(NetworkTotalUpdatedWebhookEvent.EventType.NETWORK_TOTAL_UPDATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofNetworkTotalUpdated(networkTotalUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(networkTotalUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofNetworkTotalUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofNetworkTotalUpdated( + NetworkTotalUpdatedWebhookEvent.builder() + .token("12cf7505-06a8-435e-b1c7-4c430d02f6c3") + .amounts( + NetworkTotal.Amounts.builder() + .grossSettlement(100L) + .interchangeFees(-25L) + .netSettlement(85L) + .visaCharges(10L) + .build() + ) + .created(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .currency("CAD") + .institutionId("1000000000") + .isComplete(true) + .network(NetworkTotal.Network.VISA) + .reportDate(LocalDate.parse("2025-02-25")) + .settlementInstitutionId("1000000001") + .settlementService("015") + .updated(OffsetDateTime.parse("2025-02-25T13:07:31.419631Z")) + .cycle(0L) + .eventType(NetworkTotalUpdatedWebhookEvent.EventType.NETWORK_TOTAL_UPDATED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofPaymentTransactionCreated() { + val paymentTransactionCreated = + PaymentTransactionCreatedWebhookEvent.builder() + .token("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + .category(Payment.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .descriptor("ach_origination_credit") + .direction(Payment.Direction.CREDIT) + .addEvent( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .addEvent( + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .family(Payment.Family.PAYMENT) + .financialAccountToken("35b0c466-a3e3-519a-9549-ead6a6a2277d") + .method(Payment.Method.ACH_NEXT_DAY) + .methodAttributes( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + .pendingAmount(-1588L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(Payment.TransactionResult.APPROVED) + .settledAmount(0L) + .source(Payment.Source.LITHIC) + .status(Payment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .currency("USD") + .expectedReleaseDate(null) + .externalBankAccountToken("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + .type(Payment.TransferType.ORIGINATION_CREDIT) + .userDefinedId(null) + .eventType( + PaymentTransactionCreatedWebhookEvent.EventType.PAYMENT_TRANSACTION_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofPaymentTransactionCreated(paymentTransactionCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(paymentTransactionCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofPaymentTransactionCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofPaymentTransactionCreated( + PaymentTransactionCreatedWebhookEvent.builder() + .token("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + .category(Payment.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .descriptor("ach_origination_credit") + .direction(Payment.Direction.CREDIT) + .addEvent( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .addEvent( + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .family(Payment.Family.PAYMENT) + .financialAccountToken("35b0c466-a3e3-519a-9549-ead6a6a2277d") + .method(Payment.Method.ACH_NEXT_DAY) + .methodAttributes( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + .pendingAmount(-1588L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(Payment.TransactionResult.APPROVED) + .settledAmount(0L) + .source(Payment.Source.LITHIC) + .status(Payment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .currency("USD") + .expectedReleaseDate(null) + .externalBankAccountToken("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + .type(Payment.TransferType.ORIGINATION_CREDIT) + .userDefinedId(null) + .eventType( + PaymentTransactionCreatedWebhookEvent.EventType.PAYMENT_TRANSACTION_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofPaymentTransactionUpdated() { + val paymentTransactionUpdated = + PaymentTransactionUpdatedWebhookEvent.builder() + .token("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + .category(Payment.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .descriptor("ach_origination_credit") + .direction(Payment.Direction.CREDIT) + .addEvent( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .addEvent( + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .family(Payment.Family.PAYMENT) + .financialAccountToken("35b0c466-a3e3-519a-9549-ead6a6a2277d") + .method(Payment.Method.ACH_NEXT_DAY) + .methodAttributes( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + .pendingAmount(-1588L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(Payment.TransactionResult.APPROVED) + .settledAmount(0L) + .source(Payment.Source.LITHIC) + .status(Payment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .currency("USD") + .expectedReleaseDate(null) + .externalBankAccountToken("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + .type(Payment.TransferType.ORIGINATION_CREDIT) + .userDefinedId(null) + .eventType( + PaymentTransactionUpdatedWebhookEvent.EventType.PAYMENT_TRANSACTION_UPDATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofPaymentTransactionUpdated(paymentTransactionUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(paymentTransactionUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofPaymentTransactionUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofPaymentTransactionUpdated( + PaymentTransactionUpdatedWebhookEvent.builder() + .token("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + .category(Payment.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .descriptor("ach_origination_credit") + .direction(Payment.Direction.CREDIT) + .addEvent( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .addEvent( + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .family(Payment.Family.PAYMENT) + .financialAccountToken("35b0c466-a3e3-519a-9549-ead6a6a2277d") + .method(Payment.Method.ACH_NEXT_DAY) + .methodAttributes( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + .pendingAmount(-1588L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(Payment.TransactionResult.APPROVED) + .settledAmount(0L) + .source(Payment.Source.LITHIC) + .status(Payment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .currency("USD") + .expectedReleaseDate(null) + .externalBankAccountToken("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + .type(Payment.TransferType.ORIGINATION_CREDIT) + .userDefinedId(null) + .eventType( + PaymentTransactionUpdatedWebhookEvent.EventType.PAYMENT_TRANSACTION_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofSettlementReportUpdated() { + val settlementReportUpdated = + SettlementReportUpdatedWebhookEvent.builder() + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addDetail( + SettlementSummaryDetails.builder() + .currency("USD") + .disputesGrossAmount(0L) + .institution("00001") + .interchangeGrossAmount(-7L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(0L) + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .build() + ) + .disputesGrossAmount(0L) + .interchangeGrossAmount(-7L) + .isComplete(true) + .otherFeesGrossAmount(0L) + .reportDate("2023-06-01") + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType(SettlementReportUpdatedWebhookEvent.EventType.SETTLEMENT_REPORT_UPDATED) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofSettlementReportUpdated(settlementReportUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(settlementReportUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofSettlementReportUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofSettlementReportUpdated( + SettlementReportUpdatedWebhookEvent.builder() + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addDetail( + SettlementSummaryDetails.builder() + .currency("USD") + .disputesGrossAmount(0L) + .institution("00001") + .interchangeGrossAmount(-7L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(0L) + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .build() + ) + .disputesGrossAmount(0L) + .interchangeGrossAmount(-7L) + .isComplete(true) + .otherFeesGrossAmount(0L) + .reportDate("2023-06-01") + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + SettlementReportUpdatedWebhookEvent.EventType.SETTLEMENT_REPORT_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofStatementsCreated() { + val statementsCreated = + StatementsCreatedWebhookEvent.builder() + .token("token") + .accountStanding( + Statement.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + Statement.AccountStanding.FinancialAccountState.builder() + .status( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(Statement.AccountStanding.PeriodState.STANDARD) + .build() + ) + .amountDue(Statement.AmountDue.builder().amount(0L).pastDue(0L).build()) + .availableCredit(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .daysInBillingCycle(0L) + .endingBalance(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentDueDate(LocalDate.parse("2019-12-27")) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .startingBalance(0L) + .statementEndDate(LocalDate.parse("2019-12-27")) + .statementStartDate(LocalDate.parse("2019-12-27")) + .statementType(Statement.StatementType.INITIAL) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .interestDetails( + Statement.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + Statement.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .nextPaymentDueDate(LocalDate.parse("2019-12-27")) + .nextStatementEndDate(LocalDate.parse("2019-12-27")) + .payoffDetails( + Statement.PayoffDetails.builder() + .minimumPaymentMonths("minimum_payment_months") + .minimumPaymentTotal("minimum_payment_total") + .payoffPeriodLengthMonths(0L) + .payoffPeriodMonthlyPaymentAmount(0L) + .payoffPeriodPaymentTotal(0L) + .build() + ) + .eventType(StatementsCreatedWebhookEvent.EventType.STATEMENTS_CREATED) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofStatementsCreated(statementsCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(statementsCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofStatementsCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofStatementsCreated( + StatementsCreatedWebhookEvent.builder() + .token("token") + .accountStanding( + Statement.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + Statement.AccountStanding.FinancialAccountState.builder() + .status( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(Statement.AccountStanding.PeriodState.STANDARD) + .build() + ) + .amountDue(Statement.AmountDue.builder().amount(0L).pastDue(0L).build()) + .availableCredit(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .daysInBillingCycle(0L) + .endingBalance(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentDueDate(LocalDate.parse("2019-12-27")) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .startingBalance(0L) + .statementEndDate(LocalDate.parse("2019-12-27")) + .statementStartDate(LocalDate.parse("2019-12-27")) + .statementType(Statement.StatementType.INITIAL) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .interestDetails( + Statement.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + Statement.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .nextPaymentDueDate(LocalDate.parse("2019-12-27")) + .nextStatementEndDate(LocalDate.parse("2019-12-27")) + .payoffDetails( + Statement.PayoffDetails.builder() + .minimumPaymentMonths("minimum_payment_months") + .minimumPaymentTotal("minimum_payment_total") + .payoffPeriodLengthMonths(0L) + .payoffPeriodMonthlyPaymentAmount(0L) + .payoffPeriodPaymentTotal(0L) + .build() + ) + .eventType(StatementsCreatedWebhookEvent.EventType.STATEMENTS_CREATED) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofThreeDSAuthenticationCreated() { + val threeDSAuthenticationCreated = + ThreeDSAuthenticationCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .eventType( + ThreeDSAuthenticationCreatedWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofThreeDSAuthenticationCreated(threeDSAuthenticationCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(threeDSAuthenticationCreated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofThreeDSAuthenticationCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofThreeDSAuthenticationCreated( + ThreeDSAuthenticationCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator + .DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator + .OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory( + ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION + ) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType( + ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD + ) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType( + ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION + ) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .eventType( + ThreeDSAuthenticationCreatedWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofThreeDSAuthenticationUpdated() { + val threeDSAuthenticationUpdated = + ThreeDSAuthenticationUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .eventType( + ThreeDSAuthenticationUpdatedWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_UPDATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofThreeDSAuthenticationUpdated(threeDSAuthenticationUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(threeDSAuthenticationUpdated) + 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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofThreeDSAuthenticationUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofThreeDSAuthenticationUpdated( + ThreeDSAuthenticationUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator + .DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator + .OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory( + ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION + ) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType( + ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD + ) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType( + ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION + ) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .eventType( + ThreeDSAuthenticationUpdatedWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofThreeDSAuthenticationChallenge() { + val threeDSAuthenticationChallenge = + ThreeDSAuthenticationChallengeWebhookEvent.builder() + .authenticationObject( + ThreeDSAuthentication.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator + .DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator + .OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator + .ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator + .ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory( + ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION + ) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType( + ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD + ) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType( + ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP + ) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy( + ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC + ) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType( + ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION + ) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .build() + ) + .challenge( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.builder() + .challengeMethodType( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.ChallengeMethodType + .OUT_OF_BAND + ) + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .appRequestorUrl("https://example.com") + .build() + ) + .eventType( + ThreeDSAuthenticationChallengeWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CHALLENGE + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofThreeDSAuthenticationChallenge(threeDSAuthenticationChallenge) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(threeDSAuthenticationChallenge) + assertThat(parsedWebhookEvent.tokenizationApprovalRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationResult()).isEmpty + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCode()).isEmpty + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCodeSent()).isEmpty + assertThat(parsedWebhookEvent.tokenizationUpdated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofThreeDSAuthenticationChallengeRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofThreeDSAuthenticationChallenge( + ThreeDSAuthenticationChallengeWebhookEvent.builder() + .authenticationObject( + ThreeDSAuthentication.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult( + ThreeDSAuthentication.AuthenticationResult.DECLINE + ) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator + .DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator + .OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator + .ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator + .ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory( + ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION + ) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator + .NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision + .LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType( + ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD + ) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType( + ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP + ) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy( + ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC + ) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType( + ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION + ) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .build() + ) + .challenge( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.builder() + .challengeMethodType( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge + .ChallengeMethodType + .OUT_OF_BAND + ) + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .appRequestorUrl("https://example.com") + .build() + ) + .eventType( + ThreeDSAuthenticationChallengeWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CHALLENGE + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofTokenizationApprovalRequest() { + val tokenizationApprovalRequest = + TokenizationApprovalRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerTokenizationDecision( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision.builder() + .outcome( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + .eventType( + TokenizationApprovalRequestWebhookEvent.EventType.TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision(TokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED) + .tokenizationChannel( + TokenizationApprovalRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET + ) + .tokenizationToken("tokenization_token") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .tokenizationSource( + TokenizationApprovalRequestWebhookEvent.TokenizationSource.PUSH_PROVISION + ) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationApprovalRequest(tokenizationApprovalRequest) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(tokenizationApprovalRequest) + assertThat(parsedWebhookEvent.tokenizationResult()).isEmpty + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCode()).isEmpty + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCodeSent()).isEmpty + assertThat(parsedWebhookEvent.tokenizationUpdated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofTokenizationApprovalRequestRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationApprovalRequest( + TokenizationApprovalRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerTokenizationDecision( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision + .builder() + .outcome( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + .eventType( + TokenizationApprovalRequestWebhookEvent.EventType + .TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision(TokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED) + .tokenizationChannel( + TokenizationApprovalRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET + ) + .tokenizationToken("tokenization_token") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo + .AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName( + DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY + ) + .build() + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .tokenizationSource( + TokenizationApprovalRequestWebhookEvent.TokenizationSource.PUSH_PROVISION + ) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofTokenizationResult() { + val tokenizationResult = + TokenizationResultWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType(TokenizationResultWebhookEvent.EventType.TOKENIZATION_RESULT) + .tokenizationResultDetails( + TokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofTokenizationResult(tokenizationResult) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(tokenizationResult) + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCode()).isEmpty + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCodeSent()).isEmpty + assertThat(parsedWebhookEvent.tokenizationUpdated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofTokenizationResultRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationResult( + TokenizationResultWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType(TokenizationResultWebhookEvent.EventType.TOKENIZATION_RESULT) + .tokenizationResultDetails( + TokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofTokenizationTwoFactorAuthenticationCode() { + val tokenizationTwoFactorAuthenticationCode = + TokenizationTwoFactorAuthenticationCodeWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod.builder() + .type( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .authenticationCode("123456") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationTwoFactorAuthenticationCode( + tokenizationTwoFactorAuthenticationCode + ) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(tokenizationTwoFactorAuthenticationCode) + assertThat(parsedWebhookEvent.tokenizationTwoFactorAuthenticationCodeSent()).isEmpty + assertThat(parsedWebhookEvent.tokenizationUpdated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofTokenizationTwoFactorAuthenticationCodeRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationTwoFactorAuthenticationCode( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod + .builder() + .type( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .authenticationCode("123456") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofTokenizationTwoFactorAuthenticationCodeSent() { + val tokenizationTwoFactorAuthenticationCodeSent = + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod + .builder() + .type( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationTwoFactorAuthenticationCodeSent( + tokenizationTwoFactorAuthenticationCodeSent + ) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()) + .contains(tokenizationTwoFactorAuthenticationCodeSent) + assertThat(parsedWebhookEvent.tokenizationUpdated()).isEmpty + assertThat(parsedWebhookEvent.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofTokenizationTwoFactorAuthenticationCodeSentRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationTwoFactorAuthenticationCodeSent( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod + .builder() + .type( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent + .ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofTokenizationUpdated() { + val tokenizationUpdated = + TokenizationUpdatedWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType(TokenizationUpdatedWebhookEvent.EventType.TOKENIZATION_UPDATED) + .tokenization( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason( + TokenizationDeclineReason.ACCOUNT_SCORE_1 + ) + .addTokenizationTfaReason( + TokenizationTfaReason.WALLET_RECOMMENDED_TFA + ) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofTokenizationUpdated(tokenizationUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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()).contains(tokenizationUpdated) + assertThat(parsedWebhookEvent.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofTokenizationUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofTokenizationUpdated( + TokenizationUpdatedWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType(TokenizationUpdatedWebhookEvent.EventType.TOKENIZATION_UPDATED) + .tokenization( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome + .APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason( + TokenizationDeclineReason.ACCOUNT_SCORE_1 + ) + .addTokenizationTfaReason( + TokenizationTfaReason.WALLET_RECOMMENDED_TFA + ) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofThreeDSAuthentication() { + val threeDSAuthentication = + ThreeDSAuthentication.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .build() + + val parsedWebhookEvent = ParsedWebhookEvent.ofThreeDSAuthentication(threeDSAuthentication) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).contains(threeDSAuthentication) + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofThreeDSAuthenticationRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofThreeDSAuthentication( + ThreeDSAuthentication.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator + .DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator + .OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory( + ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION + ) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType( + ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD + ) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType( + ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION + ) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDisputeTransactionCreated() { + val disputeTransactionCreated = + DisputeTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .caseId("case_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .disposition(DisputeV2.Disposition.WON) + .addEvent( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition(DisputeV2.Event.Data.WorkflowEventData.Disposition.WON) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + .liabilityAllocation( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .network(DisputeV2.Network.VISA) + .status(DisputeV2.Status.OPEN) + .transactionSeries( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + DisputeTransactionCreatedWebhookEvent.EventType.DISPUTE_TRANSACTION_CREATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofDisputeTransactionCreated(disputeTransactionCreated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()) + .contains(disputeTransactionCreated) + assertThat(parsedWebhookEvent.disputeTransactionUpdated()).isEmpty + } + + @Test + fun ofDisputeTransactionCreatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDisputeTransactionCreated( + DisputeTransactionCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .caseId("case_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .disposition(DisputeV2.Disposition.WON) + .addEvent( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition( + DisputeV2.Event.Data.WorkflowEventData.Disposition.WON + ) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + .liabilityAllocation( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .network(DisputeV2.Network.VISA) + .status(DisputeV2.Status.OPEN) + .transactionSeries( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + DisputeTransactionCreatedWebhookEvent.EventType.DISPUTE_TRANSACTION_CREATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + @Test + fun ofDisputeTransactionUpdated() { + val disputeTransactionUpdated = + DisputeTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .caseId("case_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .disposition(DisputeV2.Disposition.WON) + .addEvent( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition(DisputeV2.Event.Data.WorkflowEventData.Disposition.WON) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + .liabilityAllocation( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .network(DisputeV2.Network.VISA) + .status(DisputeV2.Status.OPEN) + .transactionSeries( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + DisputeTransactionUpdatedWebhookEvent.EventType.DISPUTE_TRANSACTION_UPDATED + ) + .build() + + val parsedWebhookEvent = + ParsedWebhookEvent.ofDisputeTransactionUpdated(disputeTransactionUpdated) + + 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.asaRequest()).isEmpty + assertThat(parsedWebhookEvent.tokenizationDecisioningRequest()).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.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.threeDSAuthentication()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionCreated()).isEmpty + assertThat(parsedWebhookEvent.disputeTransactionUpdated()) + .contains(disputeTransactionUpdated) + } + + @Test + fun ofDisputeTransactionUpdatedRoundtrip() { + val jsonMapper = jsonMapper() + val parsedWebhookEvent = + ParsedWebhookEvent.ofDisputeTransactionUpdated( + DisputeTransactionUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .caseId("case_id") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .disposition(DisputeV2.Disposition.WON) + .addEvent( + DisputeV2.Event.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .data( + DisputeV2.Event.Data.WorkflowEventData.builder() + .action(DisputeV2.Event.Data.WorkflowEventData.Action.OPENED) + .amount(0L) + .disposition( + DisputeV2.Event.Data.WorkflowEventData.Disposition.WON + ) + .reason("reason") + .stage(DisputeV2.Event.Data.WorkflowEventData.Stage.CLAIM) + .type(DisputeV2.Event.Data.WorkflowEventData.Type.WORKFLOW) + .build() + ) + .type(DisputeV2.Event.Type.WORKFLOW) + .build() + ) + .liabilityAllocation( + DisputeV2.LiabilityAllocation.builder() + .deniedAmount(0L) + .originalAmount(0L) + .recoveredAmount(0L) + .remainingAmount(0L) + .writtenOffAmount(0L) + .build() + ) + .merchant( + Merchant.builder() + .acceptorId("333301802529120") + .acquiringInstitutionId("191231") + .city("NEW YORK") + .country("USA") + .descriptor("COFFEE SHOP") + .mcc("5812") + .state("NY") + .build() + ) + .network(DisputeV2.Network.VISA) + .status(DisputeV2.Status.OPEN) + .transactionSeries( + DisputeV2.TransactionSeries.builder() + .relatedTransactionEventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .relatedTransactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .type(DisputeV2.TransactionSeries.Type.DISPUTE) + .build() + ) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType( + DisputeTransactionUpdatedWebhookEvent.EventType.DISPUTE_TRANSACTION_UPDATED + ) + .build() + ) + + val roundtrippedParsedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsedWebhookEvent).isEqualTo(parsedWebhookEvent) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val parsedWebhookEvent = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { parsedWebhookEvent.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTransactionCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTransactionCreatedWebhookEventTest.kt new file mode 100644 index 000000000..22e21ef28 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTransactionCreatedWebhookEventTest.kt @@ -0,0 +1,231 @@ +// 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 PaymentTransactionCreatedWebhookEventTest { + + @Test + fun create() { + val paymentTransactionCreatedWebhookEvent = + PaymentTransactionCreatedWebhookEvent.builder() + .token("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + .category(Payment.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .descriptor("ach_origination_credit") + .direction(Payment.Direction.CREDIT) + .addEvent( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .addEvent( + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .family(Payment.Family.PAYMENT) + .financialAccountToken("35b0c466-a3e3-519a-9549-ead6a6a2277d") + .method(Payment.Method.ACH_NEXT_DAY) + .methodAttributes( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + .pendingAmount(-1588L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(Payment.TransactionResult.APPROVED) + .settledAmount(0L) + .source(Payment.Source.LITHIC) + .status(Payment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .currency("USD") + .expectedReleaseDate(null) + .externalBankAccountToken("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + .type(Payment.TransferType.ORIGINATION_CREDIT) + .userDefinedId(null) + .eventType( + PaymentTransactionCreatedWebhookEvent.EventType.PAYMENT_TRANSACTION_CREATED + ) + .build() + + assertThat(paymentTransactionCreatedWebhookEvent.token()) + .isEqualTo("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + assertThat(paymentTransactionCreatedWebhookEvent.category()) + .isEqualTo(Payment.TransactionCategory.ACH) + assertThat(paymentTransactionCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + assertThat(paymentTransactionCreatedWebhookEvent.descriptor()) + .isEqualTo("ach_origination_credit") + assertThat(paymentTransactionCreatedWebhookEvent.direction()) + .isEqualTo(Payment.Direction.CREDIT) + assertThat(paymentTransactionCreatedWebhookEvent.events()) + .containsExactly( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build(), + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build(), + ) + assertThat(paymentTransactionCreatedWebhookEvent.family()).isEqualTo(Payment.Family.PAYMENT) + assertThat(paymentTransactionCreatedWebhookEvent.financialAccountToken()) + .isEqualTo("35b0c466-a3e3-519a-9549-ead6a6a2277d") + assertThat(paymentTransactionCreatedWebhookEvent.method()) + .isEqualTo(Payment.Method.ACH_NEXT_DAY) + assertThat(paymentTransactionCreatedWebhookEvent.methodAttributes()) + .isEqualTo( + Payment.MethodAttributes.ofAch( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + ) + assertThat(paymentTransactionCreatedWebhookEvent.pendingAmount()).isEqualTo(-1588L) + assertThat(paymentTransactionCreatedWebhookEvent.relatedAccountTokens()) + .contains( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(paymentTransactionCreatedWebhookEvent.result()) + .isEqualTo(Payment.TransactionResult.APPROVED) + assertThat(paymentTransactionCreatedWebhookEvent.settledAmount()).isEqualTo(0L) + assertThat(paymentTransactionCreatedWebhookEvent.source()).isEqualTo(Payment.Source.LITHIC) + assertThat(paymentTransactionCreatedWebhookEvent.status()) + .isEqualTo(Payment.TransactionStatus.PENDING) + assertThat(paymentTransactionCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + assertThat(paymentTransactionCreatedWebhookEvent.currency()).contains("USD") + assertThat(paymentTransactionCreatedWebhookEvent.expectedReleaseDate()).isEmpty + assertThat(paymentTransactionCreatedWebhookEvent.externalBankAccountToken()) + .contains("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + assertThat(paymentTransactionCreatedWebhookEvent.type()) + .contains(Payment.TransferType.ORIGINATION_CREDIT) + assertThat(paymentTransactionCreatedWebhookEvent.userDefinedId()).isEmpty + assertThat(paymentTransactionCreatedWebhookEvent.eventType()) + .isEqualTo(PaymentTransactionCreatedWebhookEvent.EventType.PAYMENT_TRANSACTION_CREATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val paymentTransactionCreatedWebhookEvent = + PaymentTransactionCreatedWebhookEvent.builder() + .token("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + .category(Payment.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .descriptor("ach_origination_credit") + .direction(Payment.Direction.CREDIT) + .addEvent( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .addEvent( + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .family(Payment.Family.PAYMENT) + .financialAccountToken("35b0c466-a3e3-519a-9549-ead6a6a2277d") + .method(Payment.Method.ACH_NEXT_DAY) + .methodAttributes( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + .pendingAmount(-1588L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(Payment.TransactionResult.APPROVED) + .settledAmount(0L) + .source(Payment.Source.LITHIC) + .status(Payment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .currency("USD") + .expectedReleaseDate(null) + .externalBankAccountToken("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + .type(Payment.TransferType.ORIGINATION_CREDIT) + .userDefinedId(null) + .eventType( + PaymentTransactionCreatedWebhookEvent.EventType.PAYMENT_TRANSACTION_CREATED + ) + .build() + + val roundtrippedPaymentTransactionCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(paymentTransactionCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPaymentTransactionCreatedWebhookEvent) + .isEqualTo(paymentTransactionCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTransactionUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTransactionUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..cce65d851 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/PaymentTransactionUpdatedWebhookEventTest.kt @@ -0,0 +1,231 @@ +// 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 PaymentTransactionUpdatedWebhookEventTest { + + @Test + fun create() { + val paymentTransactionUpdatedWebhookEvent = + PaymentTransactionUpdatedWebhookEvent.builder() + .token("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + .category(Payment.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .descriptor("ach_origination_credit") + .direction(Payment.Direction.CREDIT) + .addEvent( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .addEvent( + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .family(Payment.Family.PAYMENT) + .financialAccountToken("35b0c466-a3e3-519a-9549-ead6a6a2277d") + .method(Payment.Method.ACH_NEXT_DAY) + .methodAttributes( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + .pendingAmount(-1588L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(Payment.TransactionResult.APPROVED) + .settledAmount(0L) + .source(Payment.Source.LITHIC) + .status(Payment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .currency("USD") + .expectedReleaseDate(null) + .externalBankAccountToken("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + .type(Payment.TransferType.ORIGINATION_CREDIT) + .userDefinedId(null) + .eventType( + PaymentTransactionUpdatedWebhookEvent.EventType.PAYMENT_TRANSACTION_UPDATED + ) + .build() + + assertThat(paymentTransactionUpdatedWebhookEvent.token()) + .isEqualTo("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + assertThat(paymentTransactionUpdatedWebhookEvent.category()) + .isEqualTo(Payment.TransactionCategory.ACH) + assertThat(paymentTransactionUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + assertThat(paymentTransactionUpdatedWebhookEvent.descriptor()) + .isEqualTo("ach_origination_credit") + assertThat(paymentTransactionUpdatedWebhookEvent.direction()) + .isEqualTo(Payment.Direction.CREDIT) + assertThat(paymentTransactionUpdatedWebhookEvent.events()) + .containsExactly( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build(), + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build(), + ) + assertThat(paymentTransactionUpdatedWebhookEvent.family()).isEqualTo(Payment.Family.PAYMENT) + assertThat(paymentTransactionUpdatedWebhookEvent.financialAccountToken()) + .isEqualTo("35b0c466-a3e3-519a-9549-ead6a6a2277d") + assertThat(paymentTransactionUpdatedWebhookEvent.method()) + .isEqualTo(Payment.Method.ACH_NEXT_DAY) + assertThat(paymentTransactionUpdatedWebhookEvent.methodAttributes()) + .isEqualTo( + Payment.MethodAttributes.ofAch( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + ) + assertThat(paymentTransactionUpdatedWebhookEvent.pendingAmount()).isEqualTo(-1588L) + assertThat(paymentTransactionUpdatedWebhookEvent.relatedAccountTokens()) + .contains( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + assertThat(paymentTransactionUpdatedWebhookEvent.result()) + .isEqualTo(Payment.TransactionResult.APPROVED) + assertThat(paymentTransactionUpdatedWebhookEvent.settledAmount()).isEqualTo(0L) + assertThat(paymentTransactionUpdatedWebhookEvent.source()).isEqualTo(Payment.Source.LITHIC) + assertThat(paymentTransactionUpdatedWebhookEvent.status()) + .isEqualTo(Payment.TransactionStatus.PENDING) + assertThat(paymentTransactionUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + assertThat(paymentTransactionUpdatedWebhookEvent.currency()).contains("USD") + assertThat(paymentTransactionUpdatedWebhookEvent.expectedReleaseDate()).isEmpty + assertThat(paymentTransactionUpdatedWebhookEvent.externalBankAccountToken()) + .contains("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + assertThat(paymentTransactionUpdatedWebhookEvent.type()) + .contains(Payment.TransferType.ORIGINATION_CREDIT) + assertThat(paymentTransactionUpdatedWebhookEvent.userDefinedId()).isEmpty + assertThat(paymentTransactionUpdatedWebhookEvent.eventType()) + .isEqualTo(PaymentTransactionUpdatedWebhookEvent.EventType.PAYMENT_TRANSACTION_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val paymentTransactionUpdatedWebhookEvent = + PaymentTransactionUpdatedWebhookEvent.builder() + .token("bd4efddb-771b-49e3-9af9-49b077ab5eb8") + .category(Payment.TransactionCategory.ACH) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .descriptor("ach_origination_credit") + .direction(Payment.Direction.CREDIT) + .addEvent( + Payment.PaymentEvent.builder() + .token("327dccc3-fe42-54d2-962c-7f8135805464") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:22Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_INITIATED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .addEvent( + Payment.PaymentEvent.builder() + .token("f9165477-7cfc-53c6-98f1-84e9ec856a60") + .amount(-1588L) + .created(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .result(Payment.PaymentEvent.Result.APPROVED) + .type(Payment.PaymentEvent.PaymentEventType.ACH_ORIGINATION_REVIEWED) + .addDetailedResult(Payment.PaymentEvent.DetailedResult.APPROVED) + .build() + ) + .family(Payment.Family.PAYMENT) + .financialAccountToken("35b0c466-a3e3-519a-9549-ead6a6a2277d") + .method(Payment.Method.ACH_NEXT_DAY) + .methodAttributes( + Payment.MethodAttributes.AchMethodAttributes.builder() + .secCode(Payment.MethodAttributes.AchMethodAttributes.SecCode.CCD) + .achHoldPeriod(1L) + .addenda(null) + .companyId("1111111111") + .receiptRoutingNumber(null) + .retries(0L) + .returnReasonCode(null) + .addTraceNumber("string") + .build() + ) + .pendingAmount(-1588L) + .relatedAccountTokens( + Payment.RelatedAccountTokens.builder() + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .result(Payment.TransactionResult.APPROVED) + .settledAmount(0L) + .source(Payment.Source.LITHIC) + .status(Payment.TransactionStatus.PENDING) + .updated(OffsetDateTime.parse("2025-10-27T20:12:25Z")) + .currency("USD") + .expectedReleaseDate(null) + .externalBankAccountToken("feb4fee1-2414-4c38-a5f6-9deac293c8f4") + .type(Payment.TransferType.ORIGINATION_CREDIT) + .userDefinedId(null) + .eventType( + PaymentTransactionUpdatedWebhookEvent.EventType.PAYMENT_TRANSACTION_UPDATED + ) + .build() + + val roundtrippedPaymentTransactionUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(paymentTransactionUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPaymentTransactionUpdatedWebhookEvent) + .isEqualTo(paymentTransactionUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementReportUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementReportUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..0ac176a52 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementReportUpdatedWebhookEventTest.kt @@ -0,0 +1,110 @@ +// 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 SettlementReportUpdatedWebhookEventTest { + + @Test + fun create() { + val settlementReportUpdatedWebhookEvent = + SettlementReportUpdatedWebhookEvent.builder() + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addDetail( + SettlementSummaryDetails.builder() + .currency("USD") + .disputesGrossAmount(0L) + .institution("00001") + .interchangeGrossAmount(-7L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(0L) + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .build() + ) + .disputesGrossAmount(0L) + .interchangeGrossAmount(-7L) + .isComplete(true) + .otherFeesGrossAmount(0L) + .reportDate("2023-06-01") + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType(SettlementReportUpdatedWebhookEvent.EventType.SETTLEMENT_REPORT_UPDATED) + .build() + + assertThat(settlementReportUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(settlementReportUpdatedWebhookEvent.currency()).isEqualTo("USD") + assertThat(settlementReportUpdatedWebhookEvent.details()) + .containsExactly( + SettlementSummaryDetails.builder() + .currency("USD") + .disputesGrossAmount(0L) + .institution("00001") + .interchangeGrossAmount(-7L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(0L) + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .build() + ) + assertThat(settlementReportUpdatedWebhookEvent.disputesGrossAmount()).isEqualTo(0L) + assertThat(settlementReportUpdatedWebhookEvent.interchangeGrossAmount()).isEqualTo(-7L) + assertThat(settlementReportUpdatedWebhookEvent.isComplete()).isEqualTo(true) + assertThat(settlementReportUpdatedWebhookEvent.otherFeesGrossAmount()).isEqualTo(0L) + assertThat(settlementReportUpdatedWebhookEvent.reportDate()).isEqualTo("2023-06-01") + assertThat(settlementReportUpdatedWebhookEvent.settledNetAmount()).isEqualTo(1893L) + assertThat(settlementReportUpdatedWebhookEvent.transactionsGrossAmount()).isEqualTo(1900L) + assertThat(settlementReportUpdatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(settlementReportUpdatedWebhookEvent.eventType()) + .isEqualTo(SettlementReportUpdatedWebhookEvent.EventType.SETTLEMENT_REPORT_UPDATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val settlementReportUpdatedWebhookEvent = + SettlementReportUpdatedWebhookEvent.builder() + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .currency("USD") + .addDetail( + SettlementSummaryDetails.builder() + .currency("USD") + .disputesGrossAmount(0L) + .institution("00001") + .interchangeGrossAmount(-7L) + .network(SettlementSummaryDetails.Network.MASTERCARD) + .otherFeesGrossAmount(0L) + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .build() + ) + .disputesGrossAmount(0L) + .interchangeGrossAmount(-7L) + .isComplete(true) + .otherFeesGrossAmount(0L) + .reportDate("2023-06-01") + .settledNetAmount(1893L) + .transactionsGrossAmount(1900L) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventType(SettlementReportUpdatedWebhookEvent.EventType.SETTLEMENT_REPORT_UPDATED) + .build() + + val roundtrippedSettlementReportUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(settlementReportUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSettlementReportUpdatedWebhookEvent) + .isEqualTo(settlementReportUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/StatementsCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/StatementsCreatedWebhookEventTest.kt new file mode 100644 index 000000000..31c7e03b5 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/StatementsCreatedWebhookEventTest.kt @@ -0,0 +1,395 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import java.time.LocalDate +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class StatementsCreatedWebhookEventTest { + + @Test + fun create() { + val statementsCreatedWebhookEvent = + StatementsCreatedWebhookEvent.builder() + .token("token") + .accountStanding( + Statement.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + Statement.AccountStanding.FinancialAccountState.builder() + .status( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(Statement.AccountStanding.PeriodState.STANDARD) + .build() + ) + .amountDue(Statement.AmountDue.builder().amount(0L).pastDue(0L).build()) + .availableCredit(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .daysInBillingCycle(0L) + .endingBalance(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentDueDate(LocalDate.parse("2019-12-27")) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .startingBalance(0L) + .statementEndDate(LocalDate.parse("2019-12-27")) + .statementStartDate(LocalDate.parse("2019-12-27")) + .statementType(Statement.StatementType.INITIAL) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .interestDetails( + Statement.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + Statement.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .nextPaymentDueDate(LocalDate.parse("2019-12-27")) + .nextStatementEndDate(LocalDate.parse("2019-12-27")) + .payoffDetails( + Statement.PayoffDetails.builder() + .minimumPaymentMonths("minimum_payment_months") + .minimumPaymentTotal("minimum_payment_total") + .payoffPeriodLengthMonths(0L) + .payoffPeriodMonthlyPaymentAmount(0L) + .payoffPeriodPaymentTotal(0L) + .build() + ) + .eventType(StatementsCreatedWebhookEvent.EventType.STATEMENTS_CREATED) + .build() + + assertThat(statementsCreatedWebhookEvent.token()).isEqualTo("token") + assertThat(statementsCreatedWebhookEvent.accountStanding()) + .isEqualTo( + Statement.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + Statement.AccountStanding.FinancialAccountState.builder() + .status( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(Statement.AccountStanding.PeriodState.STANDARD) + .build() + ) + assertThat(statementsCreatedWebhookEvent.amountDue()) + .isEqualTo(Statement.AmountDue.builder().amount(0L).pastDue(0L).build()) + assertThat(statementsCreatedWebhookEvent.availableCredit()).isEqualTo(0L) + assertThat(statementsCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(statementsCreatedWebhookEvent.creditLimit()).isEqualTo(0L) + assertThat(statementsCreatedWebhookEvent.creditProductToken()) + .isEqualTo("credit_product_token") + assertThat(statementsCreatedWebhookEvent.daysInBillingCycle()).isEqualTo(0L) + assertThat(statementsCreatedWebhookEvent.endingBalance()).isEqualTo(0L) + assertThat(statementsCreatedWebhookEvent.financialAccountToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(statementsCreatedWebhookEvent.paymentDueDate()) + .contains(LocalDate.parse("2019-12-27")) + assertThat(statementsCreatedWebhookEvent.periodTotals()) + .isEqualTo( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + assertThat(statementsCreatedWebhookEvent.startingBalance()).isEqualTo(0L) + assertThat(statementsCreatedWebhookEvent.statementEndDate()) + .isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(statementsCreatedWebhookEvent.statementStartDate()) + .isEqualTo(LocalDate.parse("2019-12-27")) + assertThat(statementsCreatedWebhookEvent.statementType()) + .isEqualTo(Statement.StatementType.INITIAL) + assertThat(statementsCreatedWebhookEvent.updated()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(statementsCreatedWebhookEvent.ytdTotals()) + .isEqualTo( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + assertThat(statementsCreatedWebhookEvent.interestDetails()) + .contains( + Statement.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + Statement.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + assertThat(statementsCreatedWebhookEvent.nextPaymentDueDate()) + .contains(LocalDate.parse("2019-12-27")) + assertThat(statementsCreatedWebhookEvent.nextStatementEndDate()) + .contains(LocalDate.parse("2019-12-27")) + assertThat(statementsCreatedWebhookEvent.payoffDetails()) + .contains( + Statement.PayoffDetails.builder() + .minimumPaymentMonths("minimum_payment_months") + .minimumPaymentTotal("minimum_payment_total") + .payoffPeriodLengthMonths(0L) + .payoffPeriodMonthlyPaymentAmount(0L) + .payoffPeriodPaymentTotal(0L) + .build() + ) + assertThat(statementsCreatedWebhookEvent.eventType()) + .isEqualTo(StatementsCreatedWebhookEvent.EventType.STATEMENTS_CREATED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val statementsCreatedWebhookEvent = + StatementsCreatedWebhookEvent.builder() + .token("token") + .accountStanding( + Statement.AccountStanding.builder() + .consecutiveFullPaymentsMade(0L) + .consecutiveMinimumPaymentsMade(0L) + .consecutiveMinimumPaymentsMissed(0L) + .daysPastDue(0L) + .financialAccountState( + Statement.AccountStanding.FinancialAccountState.builder() + .status( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountStatus + .OPEN + ) + .substatus( + Statement.AccountStanding.FinancialAccountState + .FinancialAccountSubstatus + .CHARGED_OFF_DELINQUENT + ) + .build() + ) + .hasGrace(true) + .periodNumber(0L) + .periodState(Statement.AccountStanding.PeriodState.STANDARD) + .build() + ) + .amountDue(Statement.AmountDue.builder().amount(0L).pastDue(0L).build()) + .availableCredit(0L) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .creditLimit(0L) + .creditProductToken("credit_product_token") + .daysInBillingCycle(0L) + .endingBalance(0L) + .financialAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .paymentDueDate(LocalDate.parse("2019-12-27")) + .periodTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .startingBalance(0L) + .statementEndDate(LocalDate.parse("2019-12-27")) + .statementStartDate(LocalDate.parse("2019-12-27")) + .statementType(Statement.StatementType.INITIAL) + .updated(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .ytdTotals( + StatementTotals.builder() + .balanceTransfers(0L) + .cashAdvances(0L) + .credits(0L) + .debits(0L) + .fees(0L) + .interest(0L) + .payments(0L) + .purchases(0L) + .creditDetails(JsonValue.from(mapOf())) + .debitDetails(JsonValue.from(mapOf())) + .paymentDetails(JsonValue.from(mapOf())) + .build() + ) + .interestDetails( + Statement.InterestDetails.builder() + .actualInterestCharged(0L) + .dailyBalanceAmounts( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .effectiveApr( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .interestCalculationMethod( + Statement.InterestDetails.InterestCalculationMethod.DAILY + ) + .interestForPeriod( + CategoryDetails.builder() + .balanceTransfers("balance_transfers") + .cashAdvances("cash_advances") + .purchases("purchases") + .build() + ) + .primeRate("prime_rate") + .minimumInterestCharged(0L) + .build() + ) + .nextPaymentDueDate(LocalDate.parse("2019-12-27")) + .nextStatementEndDate(LocalDate.parse("2019-12-27")) + .payoffDetails( + Statement.PayoffDetails.builder() + .minimumPaymentMonths("minimum_payment_months") + .minimumPaymentTotal("minimum_payment_total") + .payoffPeriodLengthMonths(0L) + .payoffPeriodMonthlyPaymentAmount(0L) + .payoffPeriodPaymentTotal(0L) + .build() + ) + .eventType(StatementsCreatedWebhookEvent.EventType.STATEMENTS_CREATED) + .build() + + val roundtrippedStatementsCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(statementsCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedStatementsCreatedWebhookEvent) + .isEqualTo(statementsCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationChallengeWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationChallengeWebhookEventTest.kt new file mode 100644 index 000000000..c67163292 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationChallengeWebhookEventTest.kt @@ -0,0 +1,535 @@ +// 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 ThreeDSAuthenticationChallengeWebhookEventTest { + + @Test + fun create() { + val threeDSAuthenticationChallengeWebhookEvent = + ThreeDSAuthenticationChallengeWebhookEvent.builder() + .authenticationObject( + ThreeDSAuthentication.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator + .DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator + .OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator + .ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator + .ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory( + ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION + ) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType( + ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD + ) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType( + ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP + ) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy( + ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC + ) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType( + ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION + ) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .build() + ) + .challenge( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.builder() + .challengeMethodType( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.ChallengeMethodType + .OUT_OF_BAND + ) + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .appRequestorUrl("https://example.com") + .build() + ) + .eventType( + ThreeDSAuthenticationChallengeWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CHALLENGE + ) + .build() + + assertThat(threeDSAuthenticationChallengeWebhookEvent.authenticationObject()) + .isEqualTo( + ThreeDSAuthentication.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator + .DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator + .OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory( + ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION + ) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType( + ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD + ) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType( + ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION + ) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .build() + ) + assertThat(threeDSAuthenticationChallengeWebhookEvent.challenge()) + .isEqualTo( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.builder() + .challengeMethodType( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.ChallengeMethodType + .OUT_OF_BAND + ) + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .appRequestorUrl("https://example.com") + .build() + ) + assertThat(threeDSAuthenticationChallengeWebhookEvent.eventType()) + .isEqualTo( + ThreeDSAuthenticationChallengeWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CHALLENGE + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val threeDSAuthenticationChallengeWebhookEvent = + ThreeDSAuthenticationChallengeWebhookEvent.builder() + .authenticationObject( + ThreeDSAuthentication.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator + .DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator + .OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator + .ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator + .ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory( + ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION + ) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType( + ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD + ) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType( + ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP + ) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy( + ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC + ) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType( + ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION + ) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .build() + ) + .challenge( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.builder() + .challengeMethodType( + ThreeDSAuthenticationChallengeWebhookEvent.Challenge.ChallengeMethodType + .OUT_OF_BAND + ) + .expiryTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .appRequestorUrl("https://example.com") + .build() + ) + .eventType( + ThreeDSAuthenticationChallengeWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CHALLENGE + ) + .build() + + val roundtrippedThreeDSAuthenticationChallengeWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(threeDSAuthenticationChallengeWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedThreeDSAuthenticationChallengeWebhookEvent) + .isEqualTo(threeDSAuthenticationChallengeWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationCreatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationCreatedWebhookEventTest.kt new file mode 100644 index 000000000..fb4ae18d6 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationCreatedWebhookEventTest.kt @@ -0,0 +1,463 @@ +// 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 ThreeDSAuthenticationCreatedWebhookEventTest { + + @Test + fun create() { + val threeDSAuthenticationCreatedWebhookEvent = + ThreeDSAuthenticationCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .eventType( + ThreeDSAuthenticationCreatedWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CREATED + ) + .build() + + assertThat(threeDSAuthenticationCreatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(threeDSAuthenticationCreatedWebhookEvent.accountType()) + .contains(ThreeDSAuthentication.AccountType.CREDIT) + assertThat(threeDSAuthenticationCreatedWebhookEvent.authenticationResult()) + .isEqualTo(ThreeDSAuthentication.AuthenticationResult.DECLINE) + assertThat(threeDSAuthenticationCreatedWebhookEvent.cardExpiryCheck()) + .isEqualTo(ThreeDSAuthentication.CardExpiryCheck.MATCH) + assertThat(threeDSAuthenticationCreatedWebhookEvent.cardToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(threeDSAuthenticationCreatedWebhookEvent.cardholder()) + .isEqualTo( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch(ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + assertThat(threeDSAuthenticationCreatedWebhookEvent.channel()) + .isEqualTo(ThreeDSAuthentication.Channel.APP_BASED) + assertThat(threeDSAuthenticationCreatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(threeDSAuthenticationCreatedWebhookEvent.merchant()) + .isEqualTo( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + assertThat(threeDSAuthenticationCreatedWebhookEvent.messageCategory()) + .isEqualTo(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + assertThat(threeDSAuthenticationCreatedWebhookEvent.threeDSRequestorChallengeIndicator()) + .isEqualTo(ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE) + assertThat(threeDSAuthenticationCreatedWebhookEvent.additionalData()) + .contains( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision(ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK) + .networkRiskScore(0L) + .build() + ) + assertThat(threeDSAuthenticationCreatedWebhookEvent.app()) + .contains( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + assertThat(threeDSAuthenticationCreatedWebhookEvent.authenticationRequestType()) + .contains(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + assertThat(threeDSAuthenticationCreatedWebhookEvent.browser()) + .contains( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + assertThat(threeDSAuthenticationCreatedWebhookEvent.challengeMetadata()) + .contains( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + assertThat(threeDSAuthenticationCreatedWebhookEvent.challengeOrchestratedBy()) + .contains(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + assertThat(threeDSAuthenticationCreatedWebhookEvent.decisionMadeBy()) + .contains(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + assertThat(threeDSAuthenticationCreatedWebhookEvent.threeRiRequestType()) + .contains(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + assertThat(threeDSAuthenticationCreatedWebhookEvent.transaction()) + .contains( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + assertThat(threeDSAuthenticationCreatedWebhookEvent.eventType()) + .isEqualTo( + ThreeDSAuthenticationCreatedWebhookEvent.EventType.THREE_DS_AUTHENTICATION_CREATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val threeDSAuthenticationCreatedWebhookEvent = + ThreeDSAuthenticationCreatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .eventType( + ThreeDSAuthenticationCreatedWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_CREATED + ) + .build() + + val roundtrippedThreeDSAuthenticationCreatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(threeDSAuthenticationCreatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedThreeDSAuthenticationCreatedWebhookEvent) + .isEqualTo(threeDSAuthenticationCreatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..18b03f6ea --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ThreeDSAuthenticationUpdatedWebhookEventTest.kt @@ -0,0 +1,463 @@ +// 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 ThreeDSAuthenticationUpdatedWebhookEventTest { + + @Test + fun create() { + val threeDSAuthenticationUpdatedWebhookEvent = + ThreeDSAuthenticationUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .eventType( + ThreeDSAuthenticationUpdatedWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_UPDATED + ) + .build() + + assertThat(threeDSAuthenticationUpdatedWebhookEvent.token()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(threeDSAuthenticationUpdatedWebhookEvent.accountType()) + .contains(ThreeDSAuthentication.AccountType.CREDIT) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.authenticationResult()) + .isEqualTo(ThreeDSAuthentication.AuthenticationResult.DECLINE) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.cardExpiryCheck()) + .isEqualTo(ThreeDSAuthentication.CardExpiryCheck.MATCH) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.cardToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(threeDSAuthenticationUpdatedWebhookEvent.cardholder()) + .isEqualTo( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch(ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.channel()) + .isEqualTo(ThreeDSAuthentication.Channel.APP_BASED) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.merchant()) + .isEqualTo( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.messageCategory()) + .isEqualTo(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.threeDSRequestorChallengeIndicator()) + .isEqualTo(ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.additionalData()) + .contains( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision(ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK) + .networkRiskScore(0L) + .build() + ) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.app()) + .contains( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.authenticationRequestType()) + .contains(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.browser()) + .contains( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.challengeMetadata()) + .contains( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.challengeOrchestratedBy()) + .contains(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.decisionMadeBy()) + .contains(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.threeRiRequestType()) + .contains(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.transaction()) + .contains( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + assertThat(threeDSAuthenticationUpdatedWebhookEvent.eventType()) + .isEqualTo( + ThreeDSAuthenticationUpdatedWebhookEvent.EventType.THREE_DS_AUTHENTICATION_UPDATED + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val threeDSAuthenticationUpdatedWebhookEvent = + ThreeDSAuthenticationUpdatedWebhookEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountType(ThreeDSAuthentication.AccountType.CREDIT) + .authenticationResult(ThreeDSAuthentication.AuthenticationResult.DECLINE) + .cardExpiryCheck(ThreeDSAuthentication.CardExpiryCheck.MATCH) + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardholder( + ThreeDSAuthentication.Cardholder.builder() + .addressMatch(true) + .addressOnFileMatch( + ThreeDSAuthentication.Cardholder.AddressMatchResult.MATCH + ) + .billingAddress( + ThreeDSAuthentication.Cardholder.BillingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .email("x") + .name("x") + .phoneNumberHome("x") + .phoneNumberMobile("x") + .phoneNumberWork("x") + .shippingAddress( + ThreeDSAuthentication.Cardholder.ShippingAddress.builder() + .address1("address1") + .address2("address2") + .address3("address3") + .city("city") + .country("xxx") + .postalCode("postal_code") + .build() + ) + .build() + ) + .channel(ThreeDSAuthentication.Channel.APP_BASED) + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .merchant( + ThreeDSAuthentication.Merchant.builder() + .riskIndicator( + ThreeDSAuthentication.Merchant.RiskIndicator.builder() + .deliveryEmailAddress("delivery_email_address") + .deliveryTimeFrame( + ThreeDSAuthentication.Merchant.RiskIndicator.DeliveryTimeFrame + .ELECTRONIC_DELIVERY + ) + .giftCardAmount(0L) + .giftCardCount(0L) + .giftCardCurrency("xxx") + .orderAvailability( + ThreeDSAuthentication.Merchant.RiskIndicator.OrderAvailability + .FUTURE_AVAILABILITY + ) + .preOrderAvailableDate( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .reorderItems( + ThreeDSAuthentication.Merchant.RiskIndicator.ReorderItems + .FIRST_TIME_ORDERED + ) + .shippingMethod( + ThreeDSAuthentication.Merchant.RiskIndicator.ShippingMethod + .DIGITAL_GOODS + ) + .build() + ) + .id("id") + .country("xxx") + .mcc("xxxx") + .name("name") + .build() + ) + .messageCategory(ThreeDSAuthentication.MessageCategory.NON_PAYMENT_AUTHENTICATION) + .threeDSRequestorChallengeIndicator( + ThreeDSAuthentication.ThreeDSRequestorChallengeIndicator.NO_PREFERENCE + ) + .additionalData( + ThreeDSAuthentication.AdditionalData.builder() + .networkDecision( + ThreeDSAuthentication.AdditionalData.NetworkDecision.LOW_RISK + ) + .networkRiskScore(0L) + .build() + ) + .app( + ThreeDSAuthentication.App.builder() + .device("device") + .deviceInfo("device_info") + .ip("ip") + .latitude(-90.0) + .locale("locale") + .longitude(-180.0) + .os("os") + .platform("platform") + .screenHeight(0L) + .screenWidth(0L) + .timeZone("time_zone") + .build() + ) + .authenticationRequestType(ThreeDSAuthentication.AuthenticationRequestType.ADD_CARD) + .browser( + ThreeDSAuthentication.Browser.builder() + .acceptHeader("accept_header") + .ip("ip") + .javaEnabled(true) + .javascriptEnabled(true) + .language("language") + .timeZone("time_zone") + .userAgent("user_agent") + .build() + ) + .challengeMetadata( + ThreeDSAuthentication.ChallengeMetadata.builder() + .methodType(ThreeDSAuthentication.ChallengeMetadata.MethodType.SMS_OTP) + .status(ThreeDSAuthentication.ChallengeMetadata.Status.SUCCESS) + .phoneNumber("phone_number") + .build() + ) + .challengeOrchestratedBy(ThreeDSAuthentication.ChallengeOrchestratedBy.LITHIC) + .decisionMadeBy(ThreeDSAuthentication.DecisionMadeBy.LITHIC_RULES) + .threeRiRequestType(ThreeDSAuthentication.ThreeRiRequestType.ACCOUNT_VERIFICATION) + .transaction( + ThreeDSAuthentication.Transaction.builder() + .amount(0.0) + .cardholderAmount(0.0) + .currency("xxx") + .currencyExponent(0.0) + .dateTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .type(ThreeDSAuthentication.Transaction.Type.ACCOUNT_FUNDING) + .build() + ) + .eventType( + ThreeDSAuthenticationUpdatedWebhookEvent.EventType + .THREE_DS_AUTHENTICATION_UPDATED + ) + .build() + + val roundtrippedThreeDSAuthenticationUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(threeDSAuthenticationUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedThreeDSAuthenticationUpdatedWebhookEvent) + .isEqualTo(threeDSAuthenticationUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationApprovalRequestWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationApprovalRequestWebhookEventTest.kt new file mode 100644 index 000000000..3d8789892 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationApprovalRequestWebhookEventTest.kt @@ -0,0 +1,264 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenizationApprovalRequestWebhookEventTest { + + @Test + fun create() { + val tokenizationApprovalRequestWebhookEvent = + TokenizationApprovalRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerTokenizationDecision( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision.builder() + .outcome( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + .eventType( + TokenizationApprovalRequestWebhookEvent.EventType.TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision(TokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED) + .tokenizationChannel( + TokenizationApprovalRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET + ) + .tokenizationToken("tokenization_token") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .tokenizationSource( + TokenizationApprovalRequestWebhookEvent.TokenizationSource.PUSH_PROVISION + ) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .build() + + assertThat(tokenizationApprovalRequestWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(tokenizationApprovalRequestWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(tokenizationApprovalRequestWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(tokenizationApprovalRequestWebhookEvent.customerTokenizationDecision()) + .contains( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision.builder() + .outcome( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision.Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + assertThat(tokenizationApprovalRequestWebhookEvent.eventType()) + .isEqualTo( + TokenizationApprovalRequestWebhookEvent.EventType.TOKENIZATION_APPROVAL_REQUEST + ) + assertThat(tokenizationApprovalRequestWebhookEvent.issuerDecision()) + .isEqualTo(TokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED) + assertThat(tokenizationApprovalRequestWebhookEvent.tokenizationChannel()) + .isEqualTo(TokenizationApprovalRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET) + assertThat(tokenizationApprovalRequestWebhookEvent.tokenizationToken()) + .isEqualTo("tokenization_token") + assertThat(tokenizationApprovalRequestWebhookEvent.walletDecisioningInfo()) + .isEqualTo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + assertThat(tokenizationApprovalRequestWebhookEvent.device()) + .contains( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + assertThat(tokenizationApprovalRequestWebhookEvent.digitalWalletTokenMetadata()) + .contains( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + assertThat(tokenizationApprovalRequestWebhookEvent.ruleResults().getOrNull()) + .containsExactly( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + assertThat(tokenizationApprovalRequestWebhookEvent.tokenizationDeclineReasons().getOrNull()) + .containsExactly(TokenizationDeclineReason.ACCOUNT_SCORE_1) + assertThat(tokenizationApprovalRequestWebhookEvent.tokenizationSource()) + .contains(TokenizationApprovalRequestWebhookEvent.TokenizationSource.PUSH_PROVISION) + assertThat(tokenizationApprovalRequestWebhookEvent.tokenizationTfaReasons().getOrNull()) + .containsExactly(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenizationApprovalRequestWebhookEvent = + TokenizationApprovalRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .customerTokenizationDecision( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision.builder() + .outcome( + TokenizationApprovalRequestWebhookEvent.CustomerTokenizationDecision + .Outcome + .APPROVED + ) + .responderUrl("https://example.com") + .latency("100") + .responseCode("123456") + .build() + ) + .eventType( + TokenizationApprovalRequestWebhookEvent.EventType.TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision(TokenizationApprovalRequestWebhookEvent.IssuerDecision.APPROVED) + .tokenizationChannel( + TokenizationApprovalRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET + ) + .tokenizationToken("tokenization_token") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("string") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("phone_number") + .build() + ) + .panUniqueReference("pan_unique_reference") + .paymentAccountReference("payment_account_reference") + .tokenUniqueReference("token_unique_reference") + .build() + ) + .status("status") + .paymentAppInstanceId("payment_app_instance_id") + .tokenRequestorId("xxxxxxxxxxx") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .tokenizationSource( + TokenizationApprovalRequestWebhookEvent.TokenizationSource.PUSH_PROVISION + ) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .build() + + val roundtrippedTokenizationApprovalRequestWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenizationApprovalRequestWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenizationApprovalRequestWebhookEvent) + .isEqualTo(tokenizationApprovalRequestWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationDecisioningRequestWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationDecisioningRequestWebhookEventTest.kt new file mode 100644 index 000000000..4e70558be --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationDecisioningRequestWebhookEventTest.kt @@ -0,0 +1,203 @@ +// 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 TokenizationDecisioningRequestWebhookEventTest { + + @Test + fun create() { + val tokenizationDecisioningRequestWebhookEvent = + TokenizationDecisioningRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2023-09-18T12:34:56Z")) + .eventType( + TokenizationDecisioningRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision(TokenizationDecisioningRequestWebhookEvent.IssuerDecision.APPROVED) + .tokenizationChannel( + TokenizationDecisioningRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET + ) + .tokenizationToken("tok_1234567890abcdef") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("Reason1") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("+15555555555") + .build() + ) + .panUniqueReference("pan_unique_ref_1234567890123456789012345678") + .paymentAccountReference("ref_1234567890123456789012") + .tokenUniqueReference( + "token_unique_ref_1234567890123456789012345678" + ) + .build() + ) + .status("Pending") + .paymentAppInstanceId("app_instance_123456789012345678901234567890") + .tokenRequestorId("12345678901") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .tokenizationSource( + TokenizationDecisioningRequestWebhookEvent.TokenizationSource.PUSH_PROVISION + ) + .build() + + assertThat(tokenizationDecisioningRequestWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(tokenizationDecisioningRequestWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(tokenizationDecisioningRequestWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2023-09-18T12:34:56Z")) + assertThat(tokenizationDecisioningRequestWebhookEvent.eventType()) + .isEqualTo( + TokenizationDecisioningRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + assertThat(tokenizationDecisioningRequestWebhookEvent.issuerDecision()) + .isEqualTo(TokenizationDecisioningRequestWebhookEvent.IssuerDecision.APPROVED) + assertThat(tokenizationDecisioningRequestWebhookEvent.tokenizationChannel()) + .isEqualTo( + TokenizationDecisioningRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET + ) + assertThat(tokenizationDecisioningRequestWebhookEvent.tokenizationToken()) + .isEqualTo("tok_1234567890abcdef") + assertThat(tokenizationDecisioningRequestWebhookEvent.walletDecisioningInfo()) + .isEqualTo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("Reason1") + .build() + ) + assertThat(tokenizationDecisioningRequestWebhookEvent.device()) + .contains( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + assertThat(tokenizationDecisioningRequestWebhookEvent.digitalWalletTokenMetadata()) + .contains( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("+15555555555") + .build() + ) + .panUniqueReference("pan_unique_ref_1234567890123456789012345678") + .paymentAccountReference("ref_1234567890123456789012") + .tokenUniqueReference("token_unique_ref_1234567890123456789012345678") + .build() + ) + .status("Pending") + .paymentAppInstanceId("app_instance_123456789012345678901234567890") + .tokenRequestorId("12345678901") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + assertThat(tokenizationDecisioningRequestWebhookEvent.tokenizationSource()) + .contains(TokenizationDecisioningRequestWebhookEvent.TokenizationSource.PUSH_PROVISION) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenizationDecisioningRequestWebhookEvent = + TokenizationDecisioningRequestWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2023-09-18T12:34:56Z")) + .eventType( + TokenizationDecisioningRequestWebhookEvent.EventType + .DIGITAL_WALLET_TOKENIZATION_APPROVAL_REQUEST + ) + .issuerDecision(TokenizationDecisioningRequestWebhookEvent.IssuerDecision.APPROVED) + .tokenizationChannel( + TokenizationDecisioningRequestWebhookEvent.TokenizationChannel.DIGITAL_WALLET + ) + .tokenizationToken("tok_1234567890abcdef") + .walletDecisioningInfo( + WalletDecisioningInfo.builder() + .accountScore("100") + .deviceScore("100") + .recommendedDecision("Decision1") + .addRecommendationReason("Reason1") + .build() + ) + .device( + Device.builder() + .imei("123456789012345") + .ipAddress("1.1.1.1") + .location("37.3860517/-122.0838511") + .build() + ) + .digitalWalletTokenMetadata( + DigitalWalletTokenMetadata.builder() + .paymentAccountInfo( + DigitalWalletTokenMetadata.PaymentAccountInfo.builder() + .accountHolderData( + DigitalWalletTokenMetadata.PaymentAccountInfo.AccountHolderData + .builder() + .phoneNumber("+15555555555") + .build() + ) + .panUniqueReference("pan_unique_ref_1234567890123456789012345678") + .paymentAccountReference("ref_1234567890123456789012") + .tokenUniqueReference( + "token_unique_ref_1234567890123456789012345678" + ) + .build() + ) + .status("Pending") + .paymentAppInstanceId("app_instance_123456789012345678901234567890") + .tokenRequestorId("12345678901") + .tokenRequestorName(DigitalWalletTokenMetadata.TokenRequestorName.APPLE_PAY) + .build() + ) + .tokenizationSource( + TokenizationDecisioningRequestWebhookEvent.TokenizationSource.PUSH_PROVISION + ) + .build() + + val roundtrippedTokenizationDecisioningRequestWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenizationDecisioningRequestWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenizationDecisioningRequestWebhookEvent) + .isEqualTo(tokenizationDecisioningRequestWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationResultWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationResultWebhookEventTest.kt new file mode 100644 index 000000000..0fd12ef14 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationResultWebhookEventTest.kt @@ -0,0 +1,139 @@ +// 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 TokenizationResultWebhookEventTest { + + @Test + fun create() { + val tokenizationResultWebhookEvent = + TokenizationResultWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType(TokenizationResultWebhookEvent.EventType.TOKENIZATION_RESULT) + .tokenizationResultDetails( + TokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + assertThat(tokenizationResultWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(tokenizationResultWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(tokenizationResultWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + assertThat(tokenizationResultWebhookEvent.eventType()) + .isEqualTo(TokenizationResultWebhookEvent.EventType.TOKENIZATION_RESULT) + assertThat(tokenizationResultWebhookEvent.tokenizationResultDetails()) + .isEqualTo( + TokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + assertThat(tokenizationResultWebhookEvent.tokenizationToken()) + .isEqualTo("00000000-0000-0000-0000-000000000003") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenizationResultWebhookEvent = + TokenizationResultWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType(TokenizationResultWebhookEvent.EventType.TOKENIZATION_RESULT) + .tokenizationResultDetails( + TokenizationResultWebhookEvent.TokenizationResultDetails.builder() + .issuerDecision("issuer_decision") + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .ACCOUNT_SCORE_1 + ) + .addTokenizationDeclineReason( + TokenizationResultWebhookEvent.TokenizationResultDetails + .TokenizationDeclineReason + .DEVICE_SCORE_1 + ) + .customerDecision("customer_decision") + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .tokenActivatedDateTime(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .walletDecision("APPROVED") + .build() + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val roundtrippedTokenizationResultWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenizationResultWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenizationResultWebhookEvent) + .isEqualTo(tokenizationResultWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeSentWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeSentWebhookEventTest.kt new file mode 100644 index 000000000..894d40efa --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeSentWebhookEventTest.kt @@ -0,0 +1,101 @@ +// 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 TokenizationTwoFactorAuthenticationCodeSentWebhookEventTest { + + @Test + fun create() { + val tokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod + .builder() + .type( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + assertThat(tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.activationMethod()) + .isEqualTo( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod.builder() + .type( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + assertThat(tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + assertThat(tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.eventType()) + .isEqualTo( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + assertThat(tokenizationTwoFactorAuthenticationCodeSentWebhookEvent.tokenizationToken()) + .isEqualTo("00000000-0000-0000-0000-000000000003") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod + .builder() + .type( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + TokenizationTwoFactorAuthenticationCodeSentWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE_SENT + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val roundtrippedTokenizationTwoFactorAuthenticationCodeSentWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString( + tokenizationTwoFactorAuthenticationCodeSentWebhookEvent + ), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenizationTwoFactorAuthenticationCodeSentWebhookEvent) + .isEqualTo(tokenizationTwoFactorAuthenticationCodeSentWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeWebhookEventTest.kt new file mode 100644 index 000000000..5d185ea17 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationTwoFactorAuthenticationCodeWebhookEventTest.kt @@ -0,0 +1,100 @@ +// 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 TokenizationTwoFactorAuthenticationCodeWebhookEventTest { + + @Test + fun create() { + val tokenizationTwoFactorAuthenticationCodeWebhookEvent = + TokenizationTwoFactorAuthenticationCodeWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod.builder() + .type( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .authenticationCode("123456") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + assertThat(tokenizationTwoFactorAuthenticationCodeWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(tokenizationTwoFactorAuthenticationCodeWebhookEvent.activationMethod()) + .isEqualTo( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod.builder() + .type( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod.Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + assertThat(tokenizationTwoFactorAuthenticationCodeWebhookEvent.authenticationCode()) + .isEqualTo("123456") + assertThat(tokenizationTwoFactorAuthenticationCodeWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(tokenizationTwoFactorAuthenticationCodeWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + assertThat(tokenizationTwoFactorAuthenticationCodeWebhookEvent.eventType()) + .isEqualTo( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + assertThat(tokenizationTwoFactorAuthenticationCodeWebhookEvent.tokenizationToken()) + .isEqualTo("00000000-0000-0000-0000-000000000003") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenizationTwoFactorAuthenticationCodeWebhookEvent = + TokenizationTwoFactorAuthenticationCodeWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .activationMethod( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod.builder() + .type( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.ActivationMethod + .Type + .TEXT_TO_CARDHOLDER_NUMBER + ) + .value("+15555555555") + .build() + ) + .authenticationCode("123456") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType( + TokenizationTwoFactorAuthenticationCodeWebhookEvent.EventType + .TOKENIZATION_TWO_FACTOR_AUTHENTICATION_CODE + ) + .tokenizationToken("00000000-0000-0000-0000-000000000003") + .build() + + val roundtrippedTokenizationTwoFactorAuthenticationCodeWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenizationTwoFactorAuthenticationCodeWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenizationTwoFactorAuthenticationCodeWebhookEvent) + .isEqualTo(tokenizationTwoFactorAuthenticationCodeWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdatedWebhookEventTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdatedWebhookEventTest.kt new file mode 100644 index 000000000..fcc7aaf86 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TokenizationUpdatedWebhookEventTest.kt @@ -0,0 +1,173 @@ +// 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 TokenizationUpdatedWebhookEventTest { + + @Test + fun create() { + val tokenizationUpdatedWebhookEvent = + TokenizationUpdatedWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType(TokenizationUpdatedWebhookEvent.EventType.TOKENIZATION_UPDATED) + .tokenization( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason( + TokenizationDeclineReason.ACCOUNT_SCORE_1 + ) + .addTokenizationTfaReason( + TokenizationTfaReason.WALLET_RECOMMENDED_TFA + ) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + .build() + + assertThat(tokenizationUpdatedWebhookEvent.accountToken()) + .isEqualTo("00000000-0000-0000-0000-000000000002") + assertThat(tokenizationUpdatedWebhookEvent.cardToken()) + .isEqualTo("00000000-0000-0000-0000-000000000001") + assertThat(tokenizationUpdatedWebhookEvent.created()) + .isEqualTo(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + assertThat(tokenizationUpdatedWebhookEvent.eventType()) + .isEqualTo(TokenizationUpdatedWebhookEvent.EventType.TOKENIZATION_UPDATED) + assertThat(tokenizationUpdatedWebhookEvent.tokenization()) + .isEqualTo( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason(TokenizationDeclineReason.ACCOUNT_SCORE_1) + .addTokenizationTfaReason(TokenizationTfaReason.WALLET_RECOMMENDED_TFA) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenizationUpdatedWebhookEvent = + TokenizationUpdatedWebhookEvent.builder() + .accountToken("00000000-0000-0000-0000-000000000002") + .cardToken("00000000-0000-0000-0000-000000000001") + .created(OffsetDateTime.parse("2020-01-01T00:00:00Z")) + .eventType(TokenizationUpdatedWebhookEvent.EventType.TOKENIZATION_UPDATED) + .tokenization( + Tokenization.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .dpan("dpan") + .status(Tokenization.Status.ACTIVE) + .tokenRequestorName(Tokenization.TokenRequestorName.AMAZON_ONE) + .tokenUniqueReference("token_unique_reference") + .tokenizationChannel(Tokenization.TokenizationChannel.DIGITAL_WALLET) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .deviceId("device_id") + .digitalCardArtToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addEvent( + Tokenization.TokenizationEvent.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .result( + Tokenization.TokenizationEvent.TokenizationEventOutcome.APPROVED + ) + .addRuleResult( + TokenizationRuleResult.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .explanation("explanation") + .name("name") + .result(TokenizationRuleResult.Result.APPROVED) + .build() + ) + .addTokenizationDeclineReason( + TokenizationDeclineReason.ACCOUNT_SCORE_1 + ) + .addTokenizationTfaReason( + TokenizationTfaReason.WALLET_RECOMMENDED_TFA + ) + .type(Tokenization.TokenizationEvent.Type.TOKENIZATION_2_FA) + .build() + ) + .paymentAccountReferenceId("payment_account_reference_id") + .build() + ) + .build() + + val roundtrippedTokenizationUpdatedWebhookEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenizationUpdatedWebhookEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenizationUpdatedWebhookEvent) + .isEqualTo(tokenizationUpdatedWebhookEvent) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/WebhookServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/WebhookServiceTest.kt index 3703a319a..e647cb95f 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/WebhookServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/WebhookServiceTest.kt @@ -2,7 +2,6 @@ package com.lithic.api.services.blocking -import com.lithic.api.TestServerExtension import com.lithic.api.client.okhttp.LithicOkHttpClient import com.lithic.api.core.http.Headers import com.lithic.api.errors.LithicException @@ -10,30 +9,49 @@ import com.lithic.api.models.* import java.time.Clock import java.time.Instant import java.time.ZoneOffset +import java.util.Base64 +import javax.crypto.Mac +import javax.crypto.spec.SecretKeySpec import org.assertj.core.api.Assertions.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -@ExtendWith(TestServerExtension::class) class WebhookServiceTest { + private fun generateSignature( + secret: String, + msgId: String, + timestamp: Long, + payload: String, + ): String { + val whsecret = Base64.getDecoder().decode(secret.removePrefix("whsec_")) + val mac = Mac.getInstance("HmacSHA256") + mac.init(SecretKeySpec(whsecret, "HmacSHA256")) + val signature = mac.doFinal("$msgId.$timestamp.$payload".toByteArray()) + return Base64.getEncoder().encodeToString(signature) + } + @Test fun unwrap() { + val now = Instant.now() + val timestamp = now.epochSecond val client = LithicOkHttpClient.builder() .apiKey("test-api-key") .webhookSecret("whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst") - .clock(Clock.fixed(Instant.ofEpochSecond(1676312382), ZoneOffset.UTC)) + .clock(Clock.fixed(now, ZoneOffset.UTC)) .build() val payload = "{\"card_token\":\"sit Lorem ipsum, accusantium repellendus possimus\",\"created_at\":\"elit. placeat libero architecto molestias, sit\",\"account_token\":\"elit.\",\"issuer_decision\":\"magnam, libero esse Lorem ipsum magnam, magnam,\",\"tokenization_attempt_id\":\"illum dolor repellendus libero esse accusantium\",\"wallet_decisioning_info\":{\"device_score\":\"placeat architecto\"},\"digital_wallet_token_metadata\":{\"status\":\"reprehenderit dolor\",\"token_requestor_id\":\"possimus\",\"payment_account_info\":{\"account_holder_data\":{\"phone_number\":\"libero\",\"email_address\":\"nobis molestias, veniam culpa! quas elit. quas libero esse architecto placeat\"},\"pan_unique_reference\":\"adipisicing odit magnam, odit\"}}}" + val msgId = "msg_2Lh9KRb0pzN4LePd3XiA4v12Axj" + val signature = + generateSignature("whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst", msgId, timestamp, payload) val headers = Headers.builder() - .put("webhook-id", "msg_2Lh9KRb0pzN4LePd3XiA4v12Axj") - .put("webhook-timestamp", "1676312382") - .put("webhook-signature", "v1,Dwa0AHInLL3XFo2sxcHamOQDrJNi7F654S3L6skMAOI=") + .put("webhook-id", msgId) + .put("webhook-timestamp", timestamp.toString()) + .put("webhook-signature", "v1,$signature") .build() val event = client.webhooks().unwrap(payload, headers, null) @@ -43,18 +61,26 @@ class WebhookServiceTest { @Test fun verifySignature() { + val now = Instant.now() + val timestamp = now.epochSecond val client = LithicOkHttpClient.builder() .apiKey("test-api-key") .webhookSecret("whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst") - .clock(Clock.fixed(Instant.ofEpochSecond(1676312382), ZoneOffset.UTC)) + .clock(Clock.fixed(now, ZoneOffset.UTC)) .build() val payload = "{\"card_token\":\"sit Lorem ipsum, accusantium repellendus possimus\",\"created_at\":\"elit. placeat libero architecto molestias, sit\",\"account_token\":\"elit.\",\"issuer_decision\":\"magnam, libero esse Lorem ipsum magnam, magnam,\",\"tokenization_attempt_id\":\"illum dolor repellendus libero esse accusantium\",\"wallet_decisioning_info\":{\"device_score\":\"placeat architecto\"},\"digital_wallet_token_metadata\":{\"status\":\"reprehenderit dolor\",\"token_requestor_id\":\"possimus\",\"payment_account_info\":{\"account_holder_data\":{\"phone_number\":\"libero\",\"email_address\":\"nobis molestias, veniam culpa! quas elit. quas libero esse architecto placeat\"},\"pan_unique_reference\":\"adipisicing odit magnam, odit\"}}}" val webhookId = "msg_2Lh9KRb0pzN4LePd3XiA4v12Axj" - val webhookTimestamp = "1676312382" - val webhookSignature = "Dwa0AHInLL3XFo2sxcHamOQDrJNi7F654S3L6skMAOI=" + val webhookTimestamp = timestamp.toString() + val webhookSignature = + generateSignature( + "whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst", + webhookId, + timestamp, + payload, + ) val headers = Headers.builder() .put("webhook-id", webhookId) @@ -62,6 +88,15 @@ class WebhookServiceTest { .put("webhook-signature", "v1,$webhookSignature") .build() + // Test timestamp too old (> 5 minutes) + val oldTimestamp = timestamp - 360 // 6 minutes ago + val oldSignature = + generateSignature( + "whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst", + webhookId, + oldTimestamp, + payload, + ) assertThatThrownBy { client .webhooks() @@ -69,8 +104,8 @@ class WebhookServiceTest { payload, Headers.builder() .put("webhook-id", webhookId) - .put("webhook-timestamp", "1676312022") - .put("webhook-signature", "v1,$webhookSignature") + .put("webhook-timestamp", oldTimestamp.toString()) + .put("webhook-signature", "v1,$oldSignature") .build(), null, ) @@ -78,6 +113,15 @@ class WebhookServiceTest { .isInstanceOf(LithicException::class.java) .hasMessage("Webhook timestamp too old") + // Test timestamp too new (> 5 minutes in future) + val futureTimestamp = timestamp + 360 // 6 minutes from now + val futureSignature = + generateSignature( + "whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst", + webhookId, + futureTimestamp, + payload, + ) assertThatThrownBy { client .webhooks() @@ -85,8 +129,8 @@ class WebhookServiceTest { payload, Headers.builder() .put("webhook-id", webhookId) - .put("webhook-timestamp", "1676312742") - .put("webhook-signature", "v1,$webhookSignature") + .put("webhook-timestamp", futureTimestamp.toString()) + .put("webhook-signature", "v1,$futureSignature") .build(), null, ) @@ -94,14 +138,17 @@ class WebhookServiceTest { .isInstanceOf(LithicException::class.java) .hasMessage("Webhook timestamp too new") + // Test invalid secret format assertThatThrownBy { client.webhooks().verifySignature(payload, headers, "invalid-secret") } .isInstanceOf(LithicException::class.java) .hasMessage("Invalid webhook secret") + // Test incorrect signature with valid secret assertThatThrownBy { client.webhooks().verifySignature(payload, headers, "Zm9v") } .isInstanceOf(LithicException::class.java) .hasMessage("None of the given webhook signatures match the expected signature") + // Test multiple signatures where one is valid assertThatCode { client .webhooks() @@ -117,6 +164,7 @@ class WebhookServiceTest { } .doesNotThrowAnyException() + // Test wrong signature version assertThatThrownBy { client .webhooks() @@ -133,6 +181,8 @@ class WebhookServiceTest { .isInstanceOf(LithicException::class.java) .hasMessage("None of the given webhook signatures match the expected signature") + // Test multiple signatures where the first is valid (should succeed even if later ones are + // wrong version) assertThatCode { client .webhooks() @@ -148,6 +198,7 @@ class WebhookServiceTest { } .doesNotThrowAnyException() + // Test signature without version prefix assertThatThrownBy { client .webhooks() @@ -164,4 +215,54 @@ class WebhookServiceTest { .isInstanceOf(LithicException::class.java) .hasMessage("None of the given webhook signatures match the expected signature") } + + @Test + fun parse() { + val now = Instant.now() + val timestamp = now.epochSecond + val client = + LithicOkHttpClient.builder() + .apiKey("test-api-key") + .webhookSecret("whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst") + .clock(Clock.fixed(now, ZoneOffset.UTC)) + .build() + + val payload = """{"card_token":"card_Ao6kQgjenC6H2bSd","event_type":"card.created"}""" + val msgId = "msg_2Lh9KRb0pzN4LePd3XiA4v12Axj" + val signature = + generateSignature("whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst", msgId, timestamp, payload) + val headers = + Headers.builder() + .put("webhook-id", msgId) + .put("webhook-timestamp", timestamp.toString()) + .put("webhook-signature", "v1,$signature") + .build() + + val event = client.webhooks().parse(payload, headers, null) + + assertThat(event.isCardCreated()).isTrue() + assertThat(event.cardCreated()).isPresent + assertThat(event.cardCreated().get().cardToken()).isEqualTo("card_Ao6kQgjenC6H2bSd") + assertThat(event.asCardCreated().cardToken()).isEqualTo("card_Ao6kQgjenC6H2bSd") + + // Verify other event types are not present + assertThat(event.isCardTransactionUpdated()).isFalse() + assertThat(event.isDisputeUpdated()).isFalse() + } + + @Test + fun parseUnsafe() { + val client = + LithicOkHttpClient.builder() + .apiKey("test-api-key") + .webhookSecret("whsec_zlFsbBZ8Xcodlpcu6NDTdSzZRLSdhkst") + .build() + + val payload = """{"card_token":"card_Ao6kQgjenC6H2bSd","event_type":"card.created"}""" + + val event = client.webhooks().parseUnsafe(payload) + + assertThat(event.isCardCreated()).isTrue() + assertThat(event.asCardCreated().cardToken()).isEqualTo("card_Ao6kQgjenC6H2bSd") + } } From d6a3d507e65b6e483060ae0fa69fb11f9f1e29a3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 11 Dec 2025 09:19:57 +0000 Subject: [PATCH 12/12] release: 0.114.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 38 +++++++++++++++++++++++++++++++++++ README.md | 10 ++++----- build.gradle.kts | 2 +- 4 files changed, 45 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 939bb1750..d61779f3c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.113.0" + ".": "0.114.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e08861ad..8d4795f3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,43 @@ # Changelog +## 0.114.0 (2025-12-11) + +Full Changelog: [v0.113.0...v0.114.0](https://github.com/lithic-com/lithic-java/compare/v0.113.0...v0.114.0) + +### Features + +* **api:** add bulk card creation APIs ([713f81e](https://github.com/lithic-com/lithic-java/commit/713f81e8e58763762f07358edda1fe0b97a041dc)) +* **api:** Add event_streams to auth rules APIs ([d0cd057](https://github.com/lithic-com/lithic-java/commit/d0cd05742ef5c0bc6c3ac80b3f94a2ade0be2d24)) +* **api:** add Google WPP to SDKs ([a8c6766](https://github.com/lithic-com/lithic-java/commit/a8c67666f0575c873d3f8c0244c1f7747861ba98)) +* **api:** add IS_AFTER / IS_BEFORE operators to Auth Rule APIs ([a8c6766](https://github.com/lithic-com/lithic-java/commit/a8c67666f0575c873d3f8c0244c1f7747861ba98)) +* **api:** Add new fee types ([d0cd057](https://github.com/lithic-com/lithic-java/commit/d0cd05742ef5c0bc6c3ac80b3f94a2ade0be2d24)) +* **api:** Add optional ach_hold_period ([d0cd057](https://github.com/lithic-com/lithic-java/commit/d0cd05742ef5c0bc6c3ac80b3f94a2ade0be2d24)) +* **api:** add parse/parseUnsafe webhook helpers and event schemas ([3c51183](https://github.com/lithic-com/lithic-java/commit/3c51183f40c0bf1caaf325d6b4a192a8f9417278)) +* **api:** add WALLET_RECOMMENDATION_REASONS attribute for tokenization rules ([7545f9b](https://github.com/lithic-com/lithic-java/commit/7545f9b4a91eff8e057133d099cf5aeb489adf7d)) +* **api:** add webhook schemas to SDKs - add parse and parse_unsafe ([1bac5f3](https://github.com/lithic-com/lithic-java/commit/1bac5f34b5826b4d5e11f601a4347377e0e46722)) +* **api:** provide a unified model for AuthRule ([7545f9b](https://github.com/lithic-com/lithic-java/commit/7545f9b4a91eff8e057133d099cf5aeb489adf7d)) +* **api:** support event_streams in auth_rules list endpoint ([c6cb655](https://github.com/lithic-com/lithic-java/commit/c6cb6550c60fac0c4e412505e86ecd45a5ca6031)) + + +### Bug Fixes + +* **api:** extract several common types to reduce duplication ([713f81e](https://github.com/lithic-com/lithic-java/commit/713f81e8e58763762f07358edda1fe0b97a041dc)) +* **api:** fix examples in spec that were not fully valid ([7545f9b](https://github.com/lithic-com/lithic-java/commit/7545f9b4a91eff8e057133d099cf5aeb489adf7d)) +* **api:** make certain payoff fields nullable ([7545f9b](https://github.com/lithic-com/lithic-java/commit/7545f9b4a91eff8e057133d099cf5aeb489adf7d)) +* **client:** cancel okhttp call when future cancelled ([99c266a](https://github.com/lithic-com/lithic-java/commit/99c266a62f1b3fcd92ea9cf0ad56c5c5e130fd06)) +* fix auth rule conditional value parsing ([08fd371](https://github.com/lithic-com/lithic-java/commit/08fd3715052ba80f9df989fea7530c28ee55fbaf)) + + +### Chores + +* replace custom webhook signature verification with standardwebhooks ([1bac5f3](https://github.com/lithic-com/lithic-java/commit/1bac5f34b5826b4d5e11f601a4347377e0e46722)) + + +### Documentation + +* **api:** clarify error 422 for 3DS challenge response ([a8c6766](https://github.com/lithic-com/lithic-java/commit/a8c67666f0575c873d3f8c0244c1f7747861ba98)) +* remove `$` for better copy-pasteabality ([7c3897e](https://github.com/lithic-com/lithic-java/commit/7c3897e8506a633273f462ddd7964b92ace98d3f)) + ## 0.113.0 (2025-11-20) Full Changelog: [v0.112.0...v0.113.0](https://github.com/lithic-com/lithic-java/compare/v0.112.0...v0.113.0) diff --git a/README.md b/README.md index cc8099d2f..0fa561515 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.113.0) -[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.113.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.113.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.114.0) +[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.114.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.114.0) @@ -13,7 +13,7 @@ The Lithic Java SDK is similar to the Lithic Kotlin SDK but with minor differenc -The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.113.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.114.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic ### Gradle ```kotlin -implementation("com.lithic.api:lithic-java:0.113.0") +implementation("com.lithic.api:lithic-java:0.114.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.113.0") com.lithic.api lithic-java - 0.113.0 + 0.114.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index ee8a549d7..ec3bd95e1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.lithic.api" - version = "0.113.0" // x-release-please-version + version = "0.114.0" // x-release-please-version } subprojects {