From 7b3da9f438112a023cb85f7b0296c4fb633c40bd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 19:52:02 +0000 Subject: [PATCH 1/5] feat(api): api update --- .stats.yml | 8 +- .../com/increase/api/client/IncreaseClient.kt | 5 + .../api/client/IncreaseClientAsync.kt | 5 + .../api/client/IncreaseClientAsyncImpl.kt | 14 + .../increase/api/client/IncreaseClientImpl.kt | 14 + .../api/models/carddisputes/CardDispute.kt | 37922 ++++++++++++++++ .../carddisputes/CardDisputeCreateParams.kt | 25246 ++++++++++ .../carddisputes/CardDisputeListPage.kt | 132 + .../carddisputes/CardDisputeListPageAsync.kt | 146 + .../CardDisputeListPageResponse.kt | 237 + .../carddisputes/CardDisputeListParams.kt | 810 + .../carddisputes/CardDisputeRetrieveParams.kt | 199 + .../CardDisputeSubmitUserSubmissionParams.kt | 27057 +++++++++++ .../carddisputes/CardDisputeWithdrawParams.kt | 240 + .../carddisputes/CardDisputeActionParams.kt | 1580 + .../services/async/CardDisputeServiceAsync.kt | 327 + .../async/CardDisputeServiceAsyncImpl.kt | 265 + .../services/async/SimulationServiceAsync.kt | 5 + .../async/SimulationServiceAsyncImpl.kt | 14 + .../simulations/CardDisputeServiceAsync.kt | 100 + .../CardDisputeServiceAsyncImpl.kt | 91 + .../services/blocking/CardDisputeService.kt | 328 + .../blocking/CardDisputeServiceImpl.kt | 248 + .../services/blocking/SimulationService.kt | 5 + .../blocking/SimulationServiceImpl.kt | 12 + .../simulations/CardDisputeService.kt | 97 + .../simulations/CardDisputeServiceImpl.kt | 87 + .../CardDisputeCreateParamsTest.kt | 1961 + .../CardDisputeListPageResponseTest.kt | 3826 ++ .../carddisputes/CardDisputeListParamsTest.kt | 81 + .../CardDisputeRetrieveParamsTest.kt | 28 + ...rdDisputeSubmitUserSubmissionParamsTest.kt | 2488 + .../models/carddisputes/CardDisputeTest.kt | 3296 ++ .../CardDisputeWithdrawParamsTest.kt | 28 + .../CardDisputeActionParamsTest.kt | 115 + .../async/CardDisputeServiceAsyncTest.kt | 1666 + .../CardDisputeServiceAsyncTest.kt | 54 + .../blocking/CardDisputeServiceTest.kt | 1659 + .../simulations/CardDisputeServiceTest.kt | 53 + .../api/proguard/ProGuardCompatibilityTest.kt | 1 + 40 files changed, 110446 insertions(+), 4 deletions(-) create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDispute.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeCreateParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPage.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageAsync.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponse.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeRetrieveParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeSubmitUserSubmissionParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeWithdrawParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/simulations/carddisputes/CardDisputeActionParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/async/CardDisputeServiceAsync.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/async/CardDisputeServiceAsyncImpl.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsync.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsyncImpl.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardDisputeService.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardDisputeServiceImpl.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardDisputeService.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardDisputeServiceImpl.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeCreateParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponseTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeRetrieveParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeSubmitUserSubmissionParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeWithdrawParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/simulations/carddisputes/CardDisputeActionParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/services/async/CardDisputeServiceAsyncTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsyncTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardDisputeServiceTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardDisputeServiceTest.kt diff --git a/.stats.yml b/.stats.yml index cffc17a5a..9aa42589f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 214 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-2932a989d9e2cf36e16aaea23ed5e0e1788be21d56042097ea6ea02f6cd9dcfe.yml -openapi_spec_hash: 24a293bc92d9ac62345ef24cca251af7 -config_hash: a143293c5450ae8f52acad08f3102575 +configured_endpoints: 220 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-dc0a89abaae59dd7fc23cc5463a412d79b5c8c042eb144b05e97823d11a76b2b.yml +openapi_spec_hash: 24ce07f273cf90d08b3fa22958316846 +config_hash: f0b80170c2ea09811aeae3f1e94bc422 diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt index 952133bfb..4de8c0ea2 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClient.kt @@ -12,6 +12,7 @@ import com.increase.api.services.blocking.AchTransferService import com.increase.api.services.blocking.BookkeepingAccountService import com.increase.api.services.blocking.BookkeepingEntryService import com.increase.api.services.blocking.BookkeepingEntrySetService +import com.increase.api.services.blocking.CardDisputeService import com.increase.api.services.blocking.CardPaymentService import com.increase.api.services.blocking.CardPurchaseSupplementService import com.increase.api.services.blocking.CardPushTransferService @@ -108,6 +109,8 @@ interface IncreaseClient { fun cardPurchaseSupplements(): CardPurchaseSupplementService + fun cardDisputes(): CardDisputeService + fun physicalCards(): PhysicalCardService fun digitalCardProfiles(): DigitalCardProfileService @@ -241,6 +244,8 @@ interface IncreaseClient { fun cardPurchaseSupplements(): CardPurchaseSupplementService.WithRawResponse + fun cardDisputes(): CardDisputeService.WithRawResponse + fun physicalCards(): PhysicalCardService.WithRawResponse fun digitalCardProfiles(): DigitalCardProfileService.WithRawResponse diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt index 254077478..ac800b994 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsync.kt @@ -12,6 +12,7 @@ import com.increase.api.services.async.AchTransferServiceAsync import com.increase.api.services.async.BookkeepingAccountServiceAsync import com.increase.api.services.async.BookkeepingEntryServiceAsync import com.increase.api.services.async.BookkeepingEntrySetServiceAsync +import com.increase.api.services.async.CardDisputeServiceAsync import com.increase.api.services.async.CardPaymentServiceAsync import com.increase.api.services.async.CardPurchaseSupplementServiceAsync import com.increase.api.services.async.CardPushTransferServiceAsync @@ -108,6 +109,8 @@ interface IncreaseClientAsync { fun cardPurchaseSupplements(): CardPurchaseSupplementServiceAsync + fun cardDisputes(): CardDisputeServiceAsync + fun physicalCards(): PhysicalCardServiceAsync fun digitalCardProfiles(): DigitalCardProfileServiceAsync @@ -245,6 +248,8 @@ interface IncreaseClientAsync { fun cardPurchaseSupplements(): CardPurchaseSupplementServiceAsync.WithRawResponse + fun cardDisputes(): CardDisputeServiceAsync.WithRawResponse + fun physicalCards(): PhysicalCardServiceAsync.WithRawResponse fun digitalCardProfiles(): DigitalCardProfileServiceAsync.WithRawResponse diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt index 7c881b56d..1adb82f42 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientAsyncImpl.kt @@ -22,6 +22,8 @@ import com.increase.api.services.async.BookkeepingEntryServiceAsync import com.increase.api.services.async.BookkeepingEntryServiceAsyncImpl import com.increase.api.services.async.BookkeepingEntrySetServiceAsync import com.increase.api.services.async.BookkeepingEntrySetServiceAsyncImpl +import com.increase.api.services.async.CardDisputeServiceAsync +import com.increase.api.services.async.CardDisputeServiceAsyncImpl import com.increase.api.services.async.CardPaymentServiceAsync import com.increase.api.services.async.CardPaymentServiceAsyncImpl import com.increase.api.services.async.CardPurchaseSupplementServiceAsync @@ -155,6 +157,10 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa CardPurchaseSupplementServiceAsyncImpl(clientOptionsWithUserAgent) } + private val cardDisputes: CardDisputeServiceAsync by lazy { + CardDisputeServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val physicalCards: PhysicalCardServiceAsync by lazy { PhysicalCardServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -368,6 +374,8 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa override fun cardPurchaseSupplements(): CardPurchaseSupplementServiceAsync = cardPurchaseSupplements + override fun cardDisputes(): CardDisputeServiceAsync = cardDisputes + override fun physicalCards(): PhysicalCardServiceAsync = physicalCards override fun digitalCardProfiles(): DigitalCardProfileServiceAsync = digitalCardProfiles @@ -500,6 +508,10 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa CardPurchaseSupplementServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val cardDisputes: CardDisputeServiceAsync.WithRawResponse by lazy { + CardDisputeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val physicalCards: PhysicalCardServiceAsync.WithRawResponse by lazy { PhysicalCardServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -718,6 +730,8 @@ class IncreaseClientAsyncImpl(private val clientOptions: ClientOptions) : Increa override fun cardPurchaseSupplements(): CardPurchaseSupplementServiceAsync.WithRawResponse = cardPurchaseSupplements + override fun cardDisputes(): CardDisputeServiceAsync.WithRawResponse = cardDisputes + override fun physicalCards(): PhysicalCardServiceAsync.WithRawResponse = physicalCards override fun digitalCardProfiles(): DigitalCardProfileServiceAsync.WithRawResponse = diff --git a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt index b2c6d0aa0..0f57c4411 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/client/IncreaseClientImpl.kt @@ -22,6 +22,8 @@ import com.increase.api.services.blocking.BookkeepingEntryService import com.increase.api.services.blocking.BookkeepingEntryServiceImpl import com.increase.api.services.blocking.BookkeepingEntrySetService import com.increase.api.services.blocking.BookkeepingEntrySetServiceImpl +import com.increase.api.services.blocking.CardDisputeService +import com.increase.api.services.blocking.CardDisputeServiceImpl import com.increase.api.services.blocking.CardPaymentService import com.increase.api.services.blocking.CardPaymentServiceImpl import com.increase.api.services.blocking.CardPurchaseSupplementService @@ -153,6 +155,10 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli CardPurchaseSupplementServiceImpl(clientOptionsWithUserAgent) } + private val cardDisputes: CardDisputeService by lazy { + CardDisputeServiceImpl(clientOptionsWithUserAgent) + } + private val physicalCards: PhysicalCardService by lazy { PhysicalCardServiceImpl(clientOptionsWithUserAgent) } @@ -352,6 +358,8 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli override fun cardPurchaseSupplements(): CardPurchaseSupplementService = cardPurchaseSupplements + override fun cardDisputes(): CardDisputeService = cardDisputes + override fun physicalCards(): PhysicalCardService = physicalCards override fun digitalCardProfiles(): DigitalCardProfileService = digitalCardProfiles @@ -483,6 +491,10 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli CardPurchaseSupplementServiceImpl.WithRawResponseImpl(clientOptions) } + private val cardDisputes: CardDisputeService.WithRawResponse by lazy { + CardDisputeServiceImpl.WithRawResponseImpl(clientOptions) + } + private val physicalCards: PhysicalCardService.WithRawResponse by lazy { PhysicalCardServiceImpl.WithRawResponseImpl(clientOptions) } @@ -699,6 +711,8 @@ class IncreaseClientImpl(private val clientOptions: ClientOptions) : IncreaseCli override fun cardPurchaseSupplements(): CardPurchaseSupplementService.WithRawResponse = cardPurchaseSupplements + override fun cardDisputes(): CardDisputeService.WithRawResponse = cardDisputes + override fun physicalCards(): PhysicalCardService.WithRawResponse = physicalCards override fun digitalCardProfiles(): DigitalCardProfileService.WithRawResponse = diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDispute.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDispute.kt new file mode 100644 index 000000000..46bde6b2e --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDispute.kt @@ -0,0 +1,37922 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.increase.api.core.Enum +import com.increase.api.core.ExcludeMissing +import com.increase.api.core.JsonField +import com.increase.api.core.JsonMissing +import com.increase.api.core.JsonValue +import com.increase.api.core.checkKnown +import com.increase.api.core.checkRequired +import com.increase.api.core.toImmutable +import com.increase.api.errors.IncreaseInvalidDataException +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 + +/** + * If unauthorized activity occurs on a card, you can create a Card Dispute and we'll work with the + * card networks to return the funds if appropriate. + */ +class CardDispute +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val amount: JsonField, + private val cardId: JsonField, + private val createdAt: JsonField, + private val disputedTransactionId: JsonField, + private val idempotencyKey: JsonField, + private val loss: JsonField, + private val network: JsonField, + private val status: JsonField, + private val type: JsonField, + private val userSubmissionRequiredBy: JsonField, + private val visa: JsonField, + private val win: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("card_id") @ExcludeMissing cardId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("disputed_transaction_id") + @ExcludeMissing + disputedTransactionId: JsonField = JsonMissing.of(), + @JsonProperty("idempotency_key") + @ExcludeMissing + idempotencyKey: JsonField = JsonMissing.of(), + @JsonProperty("loss") @ExcludeMissing loss: JsonField = JsonMissing.of(), + @JsonProperty("network") @ExcludeMissing network: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("user_submission_required_by") + @ExcludeMissing + userSubmissionRequiredBy: JsonField = JsonMissing.of(), + @JsonProperty("visa") @ExcludeMissing visa: JsonField = JsonMissing.of(), + @JsonProperty("win") @ExcludeMissing win: JsonField = JsonMissing.of(), + ) : this( + id, + amount, + cardId, + createdAt, + disputedTransactionId, + idempotencyKey, + loss, + network, + status, + type, + userSubmissionRequiredBy, + visa, + win, + mutableMapOf(), + ) + + /** + * The Card Dispute identifier. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The amount of the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun amount(): Long = amount.getRequired("amount") + + /** + * The Card that the Card Dispute is associated with. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardId(): String = cardId.getRequired("card_id") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the Card + * Dispute was created. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The identifier of the Transaction that was disputed. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun disputedTransactionId(): String = + disputedTransactionId.getRequired("disputed_transaction_id") + + /** + * The idempotency key you chose for this object. This value is unique across Increase and is + * used to ensure that a request is only processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun idempotencyKey(): Optional = idempotencyKey.getOptional("idempotency_key") + + /** + * If the Card Dispute's status is `lost`, this will contain details of the lost dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loss(): Optional = loss.getOptional("loss") + + /** + * The network that the Card Dispute is associated with. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): Network = network.getRequired("network") + + /** + * The status of the Card Dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * A constant representing the object's type. For this resource it will always be + * `card_dispute`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the user + * submission is required by. Present only if status is `user_submission_required` and a user + * submission is required by a certain time. Otherwise, this will be `nil`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userSubmissionRequiredBy(): Optional = + userSubmissionRequiredBy.getOptional("user_submission_required_by") + + /** + * Card Dispute information for card payments processed over Visa's network. This field will be + * present in the JSON response if and only if `network` is equal to `visa`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun visa(): Optional = visa.getOptional("visa") + + /** + * If the Card Dispute's status is `won`, this will contain details of the won dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun win(): Optional = win.getOptional("win") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [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 [cardId]. + * + * Unlike [cardId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_id") @ExcludeMissing fun _cardId(): JsonField = cardId + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [disputedTransactionId]. + * + * Unlike [disputedTransactionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("disputed_transaction_id") + @ExcludeMissing + fun _disputedTransactionId(): JsonField = disputedTransactionId + + /** + * Returns the raw JSON value of [idempotencyKey]. + * + * Unlike [idempotencyKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("idempotency_key") + @ExcludeMissing + fun _idempotencyKey(): JsonField = idempotencyKey + + /** + * Returns the raw JSON value of [loss]. + * + * Unlike [loss], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loss") @ExcludeMissing fun _loss(): JsonField = loss + + /** + * 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 [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 [userSubmissionRequiredBy]. + * + * Unlike [userSubmissionRequiredBy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("user_submission_required_by") + @ExcludeMissing + fun _userSubmissionRequiredBy(): JsonField = userSubmissionRequiredBy + + /** + * 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 + + /** + * Returns the raw JSON value of [win]. + * + * Unlike [win], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("win") @ExcludeMissing fun _win(): JsonField = win + + @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 [CardDispute]. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .cardId() + * .createdAt() + * .disputedTransactionId() + * .idempotencyKey() + * .loss() + * .network() + * .status() + * .type() + * .userSubmissionRequiredBy() + * .visa() + * .win() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDispute]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var amount: JsonField? = null + private var cardId: JsonField? = null + private var createdAt: JsonField? = null + private var disputedTransactionId: JsonField? = null + private var idempotencyKey: JsonField? = null + private var loss: JsonField? = null + private var network: JsonField? = null + private var status: JsonField? = null + private var type: JsonField? = null + private var userSubmissionRequiredBy: JsonField? = null + private var visa: JsonField? = null + private var win: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardDispute: CardDispute) = apply { + id = cardDispute.id + amount = cardDispute.amount + cardId = cardDispute.cardId + createdAt = cardDispute.createdAt + disputedTransactionId = cardDispute.disputedTransactionId + idempotencyKey = cardDispute.idempotencyKey + loss = cardDispute.loss + network = cardDispute.network + status = cardDispute.status + type = cardDispute.type + userSubmissionRequiredBy = cardDispute.userSubmissionRequiredBy + visa = cardDispute.visa + win = cardDispute.win + additionalProperties = cardDispute.additionalProperties.toMutableMap() + } + + /** The Card Dispute identifier. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The amount of the dispute. */ + 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 Card that the Card Dispute is associated with. */ + fun cardId(cardId: String) = cardId(JsonField.of(cardId)) + + /** + * Sets [Builder.cardId] to an arbitrary JSON value. + * + * You should usually call [Builder.cardId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cardId(cardId: JsonField) = apply { this.cardId = cardId } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the Card + * Dispute was created. + */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** The identifier of the Transaction that was disputed. */ + fun disputedTransactionId(disputedTransactionId: String) = + disputedTransactionId(JsonField.of(disputedTransactionId)) + + /** + * Sets [Builder.disputedTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.disputedTransactionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun disputedTransactionId(disputedTransactionId: JsonField) = apply { + this.disputedTransactionId = disputedTransactionId + } + + /** + * The idempotency key you chose for this object. This value is unique across Increase and + * is used to ensure that a request is only processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(idempotencyKey: String?) = + idempotencyKey(JsonField.ofNullable(idempotencyKey)) + + /** Alias for calling [Builder.idempotencyKey] with `idempotencyKey.orElse(null)`. */ + fun idempotencyKey(idempotencyKey: Optional) = + idempotencyKey(idempotencyKey.getOrNull()) + + /** + * Sets [Builder.idempotencyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.idempotencyKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun idempotencyKey(idempotencyKey: JsonField) = apply { + this.idempotencyKey = idempotencyKey + } + + /** + * If the Card Dispute's status is `lost`, this will contain details of the lost dispute. + */ + fun loss(loss: Loss?) = loss(JsonField.ofNullable(loss)) + + /** Alias for calling [Builder.loss] with `loss.orElse(null)`. */ + fun loss(loss: Optional) = loss(loss.getOrNull()) + + /** + * Sets [Builder.loss] to an arbitrary JSON value. + * + * You should usually call [Builder.loss] with a well-typed [Loss] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loss(loss: JsonField) = apply { this.loss = loss } + + /** The network that the Card Dispute is associated with. */ + 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 } + + /** The status of the Card Dispute. */ + 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 } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_dispute`. + */ + 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 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the user + * submission is required by. Present only if status is `user_submission_required` and a + * user submission is required by a certain time. Otherwise, this will be `nil`. + */ + fun userSubmissionRequiredBy(userSubmissionRequiredBy: OffsetDateTime?) = + userSubmissionRequiredBy(JsonField.ofNullable(userSubmissionRequiredBy)) + + /** + * Alias for calling [Builder.userSubmissionRequiredBy] with + * `userSubmissionRequiredBy.orElse(null)`. + */ + fun userSubmissionRequiredBy(userSubmissionRequiredBy: Optional) = + userSubmissionRequiredBy(userSubmissionRequiredBy.getOrNull()) + + /** + * Sets [Builder.userSubmissionRequiredBy] to an arbitrary JSON value. + * + * You should usually call [Builder.userSubmissionRequiredBy] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun userSubmissionRequiredBy(userSubmissionRequiredBy: JsonField) = apply { + this.userSubmissionRequiredBy = userSubmissionRequiredBy + } + + /** + * Card Dispute information for card payments processed over Visa's network. This field will + * be present in the JSON response if and only if `network` is equal to `visa`. + */ + fun visa(visa: Visa?) = 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 [Visa] 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 } + + /** If the Card Dispute's status is `won`, this will contain details of the won dispute. */ + fun win(win: Win?) = win(JsonField.ofNullable(win)) + + /** Alias for calling [Builder.win] with `win.orElse(null)`. */ + fun win(win: Optional) = win(win.getOrNull()) + + /** + * Sets [Builder.win] to an arbitrary JSON value. + * + * You should usually call [Builder.win] with a well-typed [Win] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun win(win: JsonField) = apply { this.win = win } + + 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 [CardDispute]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .amount() + * .cardId() + * .createdAt() + * .disputedTransactionId() + * .idempotencyKey() + * .loss() + * .network() + * .status() + * .type() + * .userSubmissionRequiredBy() + * .visa() + * .win() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardDispute = + CardDispute( + checkRequired("id", id), + checkRequired("amount", amount), + checkRequired("cardId", cardId), + checkRequired("createdAt", createdAt), + checkRequired("disputedTransactionId", disputedTransactionId), + checkRequired("idempotencyKey", idempotencyKey), + checkRequired("loss", loss), + checkRequired("network", network), + checkRequired("status", status), + checkRequired("type", type), + checkRequired("userSubmissionRequiredBy", userSubmissionRequiredBy), + checkRequired("visa", visa), + checkRequired("win", win), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardDispute = apply { + if (validated) { + return@apply + } + + id() + amount() + cardId() + createdAt() + disputedTransactionId() + idempotencyKey() + loss().ifPresent { it.validate() } + network().validate() + status().validate() + type().validate() + userSubmissionRequiredBy() + visa().ifPresent { it.validate() } + win().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (cardId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (disputedTransactionId.asKnown().isPresent) 1 else 0) + + (if (idempotencyKey.asKnown().isPresent) 1 else 0) + + (loss.asKnown().getOrNull()?.validity() ?: 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (userSubmissionRequiredBy.asKnown().isPresent) 1 else 0) + + (visa.asKnown().getOrNull()?.validity() ?: 0) + + (win.asKnown().getOrNull()?.validity() ?: 0) + + /** If the Card Dispute's status is `lost`, this will contain details of the lost dispute. */ + class Loss + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lostAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lost_at") + @ExcludeMissing + lostAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + ) : this(lostAt, reason, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the Card + * Dispute was lost. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lostAt(): OffsetDateTime = lostAt.getRequired("lost_at") + + /** + * The reason the Card Dispute was lost. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun reason(): Reason = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [lostAt]. + * + * Unlike [lostAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lost_at") @ExcludeMissing fun _lostAt(): JsonField = lostAt + + /** + * 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 + + @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 [Loss]. + * + * The following fields are required: + * ```java + * .lostAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Loss]. */ + class Builder internal constructor() { + + private var lostAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(loss: Loss) = apply { + lostAt = loss.lostAt + reason = loss.reason + additionalProperties = loss.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Card Dispute was lost. + */ + fun lostAt(lostAt: OffsetDateTime) = lostAt(JsonField.of(lostAt)) + + /** + * Sets [Builder.lostAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lostAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lostAt(lostAt: JsonField) = apply { this.lostAt = lostAt } + + /** The reason the Card Dispute was lost. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [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 } + + 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 [Loss]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .lostAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Loss = + Loss( + checkRequired("lostAt", lostAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Loss = apply { + if (validated) { + return@apply + } + + lostAt() + reason().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lostAt.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** The reason the Card Dispute was lost. */ + class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** The user withdrew the Card Dispute. */ + @JvmField val USER_WITHDRAWN = of("user_withdrawn") + + /** The Card Dispute was lost according to network rules. */ + @JvmField val LOSS = of("loss") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** The user withdrew the Card Dispute. */ + USER_WITHDRAWN, + /** The Card Dispute was lost according to network rules. */ + LOSS, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** The user withdrew the Card Dispute. */ + USER_WITHDRAWN, + /** The Card Dispute was lost according to network rules. */ + LOSS, + /** + * An enum member indicating that [Reason] 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) { + USER_WITHDRAWN -> Value.USER_WITHDRAWN + LOSS -> Value.LOSS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USER_WITHDRAWN -> Known.USER_WITHDRAWN + LOSS -> Known.LOSS + else -> throw IncreaseInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && 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 Loss && + lostAt == other.lostAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(lostAt, reason, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Loss{lostAt=$lostAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** The network that the Card Dispute is associated with. */ + 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 { + + /** Visa: details will be under the `visa` object. */ + @JvmField val VISA = of("visa") + + @JvmStatic fun of(value: String) = Network(JsonField.of(value)) + } + + /** An enum containing [Network]'s known values. */ + enum class Known { + /** Visa: details will be under the `visa` object. */ + 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 { + /** Visa: details will be under the `visa` object. */ + 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) { + 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 IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VISA -> Known.VISA + else -> throw IncreaseInvalidDataException("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 IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Network = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Network && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The status of the Card Dispute. */ + 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 { + + /** A User Submission is required to continue with the Card Dispute. */ + @JvmField val USER_SUBMISSION_REQUIRED = of("user_submission_required") + + /** The most recent User Submission is being reviewed. */ + @JvmField + val PENDING_USER_SUBMISSION_REVIEWING = of("pending_user_submission_reviewing") + + /** The most recent User Submission is being submitted to the network. */ + @JvmField + val PENDING_USER_SUBMISSION_SUBMITTING = of("pending_user_submission_submitting") + + /** The user's withdrawal of the Card Dispute is being submitted to the network. */ + @JvmField + val PENDING_USER_WITHDRAWAL_SUBMITTING = of("pending_user_withdrawal_submitting") + + /** The Card Dispute is pending a response from the network. */ + @JvmField val PENDING_RESPONSE = of("pending_response") + + /** + * The Card Dispute has been lost and funds previously credited from the acceptance have + * been debited. + */ + @JvmField val LOST = of("lost") + + /** The Card Dispute has been won and no further action can be taken. */ + @JvmField val WON = of("won") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + /** A User Submission is required to continue with the Card Dispute. */ + USER_SUBMISSION_REQUIRED, + /** The most recent User Submission is being reviewed. */ + PENDING_USER_SUBMISSION_REVIEWING, + /** The most recent User Submission is being submitted to the network. */ + PENDING_USER_SUBMISSION_SUBMITTING, + /** The user's withdrawal of the Card Dispute is being submitted to the network. */ + PENDING_USER_WITHDRAWAL_SUBMITTING, + /** The Card Dispute is pending a response from the network. */ + PENDING_RESPONSE, + /** + * The Card Dispute has been lost and funds previously credited from the acceptance have + * been debited. + */ + LOST, + /** The Card Dispute has been won and no further action can be taken. */ + WON, + } + + /** + * 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 { + /** A User Submission is required to continue with the Card Dispute. */ + USER_SUBMISSION_REQUIRED, + /** The most recent User Submission is being reviewed. */ + PENDING_USER_SUBMISSION_REVIEWING, + /** The most recent User Submission is being submitted to the network. */ + PENDING_USER_SUBMISSION_SUBMITTING, + /** The user's withdrawal of the Card Dispute is being submitted to the network. */ + PENDING_USER_WITHDRAWAL_SUBMITTING, + /** The Card Dispute is pending a response from the network. */ + PENDING_RESPONSE, + /** + * The Card Dispute has been lost and funds previously credited from the acceptance have + * been debited. + */ + LOST, + /** The Card Dispute has been won and no further action can be taken. */ + WON, + /** 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) { + USER_SUBMISSION_REQUIRED -> Value.USER_SUBMISSION_REQUIRED + PENDING_USER_SUBMISSION_REVIEWING -> Value.PENDING_USER_SUBMISSION_REVIEWING + PENDING_USER_SUBMISSION_SUBMITTING -> Value.PENDING_USER_SUBMISSION_SUBMITTING + PENDING_USER_WITHDRAWAL_SUBMITTING -> Value.PENDING_USER_WITHDRAWAL_SUBMITTING + PENDING_RESPONSE -> Value.PENDING_RESPONSE + LOST -> Value.LOST + WON -> Value.WON + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USER_SUBMISSION_REQUIRED -> Known.USER_SUBMISSION_REQUIRED + PENDING_USER_SUBMISSION_REVIEWING -> Known.PENDING_USER_SUBMISSION_REVIEWING + PENDING_USER_SUBMISSION_SUBMITTING -> Known.PENDING_USER_SUBMISSION_SUBMITTING + PENDING_USER_WITHDRAWAL_SUBMITTING -> Known.PENDING_USER_WITHDRAWAL_SUBMITTING + PENDING_RESPONSE -> Known.PENDING_RESPONSE + LOST -> Known.LOST + WON -> Known.WON + else -> throw IncreaseInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * A constant representing the object's type. For this resource it will always be + * `card_dispute`. + */ + 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 CARD_DISPUTE = of("card_dispute") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CARD_DISPUTE + } + + /** + * 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 { + CARD_DISPUTE, + /** 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) { + CARD_DISPUTE -> Value.CARD_DISPUTE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CARD_DISPUTE -> Known.CARD_DISPUTE + else -> throw IncreaseInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Card Dispute information for card payments processed over Visa's network. This field will be + * present in the JSON response if and only if `network` is equal to `visa`. + */ + class Visa + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val networkEvents: JsonField>, + private val requiredUserSubmissionCategory: JsonField, + private val userSubmissions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("network_events") + @ExcludeMissing + networkEvents: JsonField> = JsonMissing.of(), + @JsonProperty("required_user_submission_category") + @ExcludeMissing + requiredUserSubmissionCategory: JsonField = + JsonMissing.of(), + @JsonProperty("user_submissions") + @ExcludeMissing + userSubmissions: JsonField> = JsonMissing.of(), + ) : this(networkEvents, requiredUserSubmissionCategory, userSubmissions, mutableMapOf()) + + /** + * The network events for the Card Dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun networkEvents(): List = networkEvents.getRequired("network_events") + + /** + * The category of the currently required user submission if the user wishes to proceed with + * the dispute. Present if and only if status is `user_submission_required`. Otherwise, this + * will be `nil`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requiredUserSubmissionCategory(): Optional = + requiredUserSubmissionCategory.getOptional("required_user_submission_category") + + /** + * The user submissions for the Card Dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun userSubmissions(): List = + userSubmissions.getRequired("user_submissions") + + /** + * Returns the raw JSON value of [networkEvents]. + * + * Unlike [networkEvents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("network_events") + @ExcludeMissing + fun _networkEvents(): JsonField> = networkEvents + + /** + * Returns the raw JSON value of [requiredUserSubmissionCategory]. + * + * Unlike [requiredUserSubmissionCategory], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("required_user_submission_category") + @ExcludeMissing + fun _requiredUserSubmissionCategory(): JsonField = + requiredUserSubmissionCategory + + /** + * Returns the raw JSON value of [userSubmissions]. + * + * Unlike [userSubmissions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("user_submissions") + @ExcludeMissing + fun _userSubmissions(): JsonField> = userSubmissions + + @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 [Visa]. + * + * The following fields are required: + * ```java + * .networkEvents() + * .requiredUserSubmissionCategory() + * .userSubmissions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Visa]. */ + class Builder internal constructor() { + + private var networkEvents: JsonField>? = null + private var requiredUserSubmissionCategory: JsonField? = + null + private var userSubmissions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(visa: Visa) = apply { + networkEvents = visa.networkEvents.map { it.toMutableList() } + requiredUserSubmissionCategory = visa.requiredUserSubmissionCategory + userSubmissions = visa.userSubmissions.map { it.toMutableList() } + additionalProperties = visa.additionalProperties.toMutableMap() + } + + /** The network events for the Card Dispute. */ + fun networkEvents(networkEvents: List) = + networkEvents(JsonField.of(networkEvents)) + + /** + * Sets [Builder.networkEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.networkEvents] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun networkEvents(networkEvents: JsonField>) = apply { + this.networkEvents = networkEvents.map { it.toMutableList() } + } + + /** + * Adds a single [NetworkEvent] to [networkEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNetworkEvent(networkEvent: NetworkEvent) = apply { + networkEvents = + (networkEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("networkEvents", it).add(networkEvent) + } + } + + /** + * The category of the currently required user submission if the user wishes to proceed + * with the dispute. Present if and only if status is `user_submission_required`. + * Otherwise, this will be `nil`. + */ + fun requiredUserSubmissionCategory( + requiredUserSubmissionCategory: RequiredUserSubmissionCategory? + ) = requiredUserSubmissionCategory(JsonField.ofNullable(requiredUserSubmissionCategory)) + + /** + * Alias for calling [Builder.requiredUserSubmissionCategory] with + * `requiredUserSubmissionCategory.orElse(null)`. + */ + fun requiredUserSubmissionCategory( + requiredUserSubmissionCategory: Optional + ) = requiredUserSubmissionCategory(requiredUserSubmissionCategory.getOrNull()) + + /** + * Sets [Builder.requiredUserSubmissionCategory] to an arbitrary JSON value. + * + * You should usually call [Builder.requiredUserSubmissionCategory] with a well-typed + * [RequiredUserSubmissionCategory] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun requiredUserSubmissionCategory( + requiredUserSubmissionCategory: JsonField + ) = apply { this.requiredUserSubmissionCategory = requiredUserSubmissionCategory } + + /** The user submissions for the Card Dispute. */ + fun userSubmissions(userSubmissions: List) = + userSubmissions(JsonField.of(userSubmissions)) + + /** + * Sets [Builder.userSubmissions] to an arbitrary JSON value. + * + * You should usually call [Builder.userSubmissions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun userSubmissions(userSubmissions: JsonField>) = apply { + this.userSubmissions = userSubmissions.map { it.toMutableList() } + } + + /** + * Adds a single [UserSubmission] to [userSubmissions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUserSubmission(userSubmission: UserSubmission) = apply { + userSubmissions = + (userSubmissions ?: JsonField.of(mutableListOf())).also { + checkKnown("userSubmissions", it).add(userSubmission) + } + } + + 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 [Visa]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .networkEvents() + * .requiredUserSubmissionCategory() + * .userSubmissions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Visa = + Visa( + checkRequired("networkEvents", networkEvents).map { it.toImmutable() }, + checkRequired("requiredUserSubmissionCategory", requiredUserSubmissionCategory), + checkRequired("userSubmissions", userSubmissions).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Visa = apply { + if (validated) { + return@apply + } + + networkEvents().forEach { it.validate() } + requiredUserSubmissionCategory().ifPresent { it.validate() } + userSubmissions().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (networkEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (requiredUserSubmissionCategory.asKnown().getOrNull()?.validity() ?: 0) + + (userSubmissions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class NetworkEvent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attachmentFiles: JsonField>, + private val category: JsonField, + private val chargebackAccepted: JsonValue, + private val chargebackSubmitted: JsonValue, + private val chargebackTimedOut: JsonValue, + private val createdAt: JsonField, + private val disputeFinancialTransactionId: JsonField, + private val merchantPrearbitrationDeclineSubmitted: JsonValue, + private val merchantPrearbitrationReceived: JsonField, + private val merchantPrearbitrationTimedOut: JsonValue, + private val represented: JsonField, + private val representmentTimedOut: JsonValue, + private val userPrearbitrationAccepted: JsonValue, + private val userPrearbitrationDeclined: JsonValue, + private val userPrearbitrationSubmitted: JsonValue, + private val userPrearbitrationTimedOut: JsonValue, + private val userWithdrawalSubmitted: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attachment_files") + @ExcludeMissing + attachmentFiles: JsonField> = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("chargeback_accepted") + @ExcludeMissing + chargebackAccepted: JsonValue = JsonMissing.of(), + @JsonProperty("chargeback_submitted") + @ExcludeMissing + chargebackSubmitted: JsonValue = JsonMissing.of(), + @JsonProperty("chargeback_timed_out") + @ExcludeMissing + chargebackTimedOut: JsonValue = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("dispute_financial_transaction_id") + @ExcludeMissing + disputeFinancialTransactionId: JsonField = JsonMissing.of(), + @JsonProperty("merchant_prearbitration_decline_submitted") + @ExcludeMissing + merchantPrearbitrationDeclineSubmitted: JsonValue = JsonMissing.of(), + @JsonProperty("merchant_prearbitration_received") + @ExcludeMissing + merchantPrearbitrationReceived: JsonField = + JsonMissing.of(), + @JsonProperty("merchant_prearbitration_timed_out") + @ExcludeMissing + merchantPrearbitrationTimedOut: JsonValue = JsonMissing.of(), + @JsonProperty("represented") + @ExcludeMissing + represented: JsonField = JsonMissing.of(), + @JsonProperty("representment_timed_out") + @ExcludeMissing + representmentTimedOut: JsonValue = JsonMissing.of(), + @JsonProperty("user_prearbitration_accepted") + @ExcludeMissing + userPrearbitrationAccepted: JsonValue = JsonMissing.of(), + @JsonProperty("user_prearbitration_declined") + @ExcludeMissing + userPrearbitrationDeclined: JsonValue = JsonMissing.of(), + @JsonProperty("user_prearbitration_submitted") + @ExcludeMissing + userPrearbitrationSubmitted: JsonValue = JsonMissing.of(), + @JsonProperty("user_prearbitration_timed_out") + @ExcludeMissing + userPrearbitrationTimedOut: JsonValue = JsonMissing.of(), + @JsonProperty("user_withdrawal_submitted") + @ExcludeMissing + userWithdrawalSubmitted: JsonValue = JsonMissing.of(), + ) : this( + attachmentFiles, + category, + chargebackAccepted, + chargebackSubmitted, + chargebackTimedOut, + createdAt, + disputeFinancialTransactionId, + merchantPrearbitrationDeclineSubmitted, + merchantPrearbitrationReceived, + merchantPrearbitrationTimedOut, + represented, + representmentTimedOut, + userPrearbitrationAccepted, + userPrearbitrationDeclined, + userPrearbitrationSubmitted, + userPrearbitrationTimedOut, + userWithdrawalSubmitted, + mutableMapOf(), + ) + + /** + * The files attached to the Visa Card Dispute User Submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun attachmentFiles(): List = + attachmentFiles.getRequired("attachment_files") + + /** + * The category of the user submission. We may add additional possible values for this + * enum over time; your application should be able to handle such additions gracefully. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun category(): Category = category.getRequired("category") + + /** + * A Card Dispute Chargeback Accepted Visa Network Event object. This field will be + * present in the JSON response if and only if `category` is equal to + * `chargeback_accepted`. Contains the details specific to a chargeback accepted Visa + * Card Dispute Network Event, which represents that a chargeback has been accepted by + * the merchant. + */ + @JsonProperty("chargeback_accepted") + @ExcludeMissing + fun _chargebackAccepted(): JsonValue = chargebackAccepted + + /** + * A Card Dispute Chargeback Submitted Visa Network Event object. This field will be + * present in the JSON response if and only if `category` is equal to + * `chargeback_submitted`. Contains the details specific to a chargeback submitted Visa + * Card Dispute Network Event, which represents that a chargeback has been submitted to + * the network. + */ + @JsonProperty("chargeback_submitted") + @ExcludeMissing + fun _chargebackSubmitted(): JsonValue = chargebackSubmitted + + /** + * A Card Dispute Chargeback Timed Out Visa Network Event object. This field will be + * present in the JSON response if and only if `category` is equal to + * `chargeback_timed_out`. Contains the details specific to a chargeback timed out Visa + * Card Dispute Network Event, which represents that the chargeback has timed out in the + * user's favor. + */ + @JsonProperty("chargeback_timed_out") + @ExcludeMissing + fun _chargebackTimedOut(): JsonValue = chargebackTimedOut + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Visa Card Dispute Network Event was created. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The dispute financial transaction that resulted from the network event, if any. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun disputeFinancialTransactionId(): Optional = + disputeFinancialTransactionId.getOptional("dispute_financial_transaction_id") + + /** + * A Card Dispute Merchant Pre-Arbitration Decline Submitted Visa Network Event object. + * This field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_decline_submitted`. Contains the details specific to a + * merchant prearbitration decline submitted Visa Card Dispute Network Event, which + * represents that the user has declined the merchant's request for a prearbitration + * request decision in their favor. + */ + @JsonProperty("merchant_prearbitration_decline_submitted") + @ExcludeMissing + fun _merchantPrearbitrationDeclineSubmitted(): JsonValue = + merchantPrearbitrationDeclineSubmitted + + /** + * A Card Dispute Merchant Pre-Arbitration Received Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_received`. Contains the details specific to a merchant + * prearbitration received Visa Card Dispute Network Event, which represents that the + * merchant has issued a prearbitration request in the user's favor. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun merchantPrearbitrationReceived(): Optional = + merchantPrearbitrationReceived.getOptional("merchant_prearbitration_received") + + /** + * A Card Dispute Merchant Pre-Arbitration Timed Out Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_timed_out`. Contains the details specific to a merchant + * prearbitration timed out Visa Card Dispute Network Event, which represents that the + * user has timed out responding to the merchant's prearbitration request. + */ + @JsonProperty("merchant_prearbitration_timed_out") + @ExcludeMissing + fun _merchantPrearbitrationTimedOut(): JsonValue = merchantPrearbitrationTimedOut + + /** + * A Card Dispute Re-presented Visa Network Event object. This field will be present in + * the JSON response if and only if `category` is equal to `represented`. Contains the + * details specific to a re-presented Visa Card Dispute Network Event, which represents + * that the merchant has declined the user's chargeback and has re-presented the + * payment. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun represented(): Optional = represented.getOptional("represented") + + /** + * A Card Dispute Re-presentment Timed Out Visa Network Event object. This field will be + * present in the JSON response if and only if `category` is equal to + * `representment_timed_out`. Contains the details specific to a re-presentment time-out + * Visa Card Dispute Network Event, which represents that the user did not respond to + * the re-presentment by the merchant within the time limit. + */ + @JsonProperty("representment_timed_out") + @ExcludeMissing + fun _representmentTimedOut(): JsonValue = representmentTimedOut + + /** + * A Card Dispute User Pre-Arbitration Accepted Visa Network Event object. This field + * will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration_accepted`. Contains the details specific to a user + * prearbitration accepted Visa Card Dispute Network Event, which represents that the + * merchant has accepted the user's prearbitration request in the user's favor. + */ + @JsonProperty("user_prearbitration_accepted") + @ExcludeMissing + fun _userPrearbitrationAccepted(): JsonValue = userPrearbitrationAccepted + + /** + * A Card Dispute User Pre-Arbitration Declined Visa Network Event object. This field + * will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration_declined`. Contains the details specific to a user + * prearbitration declined Visa Card Dispute Network Event, which represents that the + * merchant has declined the user's prearbitration request. + */ + @JsonProperty("user_prearbitration_declined") + @ExcludeMissing + fun _userPrearbitrationDeclined(): JsonValue = userPrearbitrationDeclined + + /** + * A Card Dispute User Pre-Arbitration Submitted Visa Network Event object. This field + * will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration_submitted`. Contains the details specific to a user + * prearbitration submitted Visa Card Dispute Network Event, which represents that the + * user's request for prearbitration has been submitted to the network. + */ + @JsonProperty("user_prearbitration_submitted") + @ExcludeMissing + fun _userPrearbitrationSubmitted(): JsonValue = userPrearbitrationSubmitted + + /** + * A Card Dispute User Pre-Arbitration Timed Out Visa Network Event object. This field + * will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration_timed_out`. Contains the details specific to a user + * prearbitration timed out Visa Card Dispute Network Event, which represents that the + * merchant has timed out responding to the user's prearbitration request. + */ + @JsonProperty("user_prearbitration_timed_out") + @ExcludeMissing + fun _userPrearbitrationTimedOut(): JsonValue = userPrearbitrationTimedOut + + /** + * A Card Dispute User Withdrawal Submitted Visa Network Event object. This field will + * be present in the JSON response if and only if `category` is equal to + * `user_withdrawal_submitted`. Contains the details specific to a user withdrawal + * submitted Visa Card Dispute Network Event, which represents that the user's request + * to withdraw the dispute has been submitted to the network. + */ + @JsonProperty("user_withdrawal_submitted") + @ExcludeMissing + fun _userWithdrawalSubmitted(): JsonValue = userWithdrawalSubmitted + + /** + * Returns the raw JSON value of [attachmentFiles]. + * + * Unlike [attachmentFiles], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attachment_files") + @ExcludeMissing + fun _attachmentFiles(): JsonField> = attachmentFiles + + /** + * 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 [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [disputeFinancialTransactionId]. + * + * Unlike [disputeFinancialTransactionId], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("dispute_financial_transaction_id") + @ExcludeMissing + fun _disputeFinancialTransactionId(): JsonField = disputeFinancialTransactionId + + /** + * Returns the raw JSON value of [merchantPrearbitrationReceived]. + * + * Unlike [merchantPrearbitrationReceived], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_prearbitration_received") + @ExcludeMissing + fun _merchantPrearbitrationReceived(): JsonField = + merchantPrearbitrationReceived + + /** + * Returns the raw JSON value of [represented]. + * + * Unlike [represented], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("represented") + @ExcludeMissing + fun _represented(): JsonField = represented + + @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 [NetworkEvent]. + * + * The following fields are required: + * ```java + * .attachmentFiles() + * .category() + * .chargebackAccepted() + * .chargebackSubmitted() + * .chargebackTimedOut() + * .createdAt() + * .disputeFinancialTransactionId() + * .merchantPrearbitrationDeclineSubmitted() + * .merchantPrearbitrationReceived() + * .merchantPrearbitrationTimedOut() + * .represented() + * .representmentTimedOut() + * .userPrearbitrationAccepted() + * .userPrearbitrationDeclined() + * .userPrearbitrationSubmitted() + * .userPrearbitrationTimedOut() + * .userWithdrawalSubmitted() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NetworkEvent]. */ + class Builder internal constructor() { + + private var attachmentFiles: JsonField>? = null + private var category: JsonField? = null + private var chargebackAccepted: JsonValue? = null + private var chargebackSubmitted: JsonValue? = null + private var chargebackTimedOut: JsonValue? = null + private var createdAt: JsonField? = null + private var disputeFinancialTransactionId: JsonField? = null + private var merchantPrearbitrationDeclineSubmitted: JsonValue? = null + private var merchantPrearbitrationReceived: + JsonField? = + null + private var merchantPrearbitrationTimedOut: JsonValue? = null + private var represented: JsonField? = null + private var representmentTimedOut: JsonValue? = null + private var userPrearbitrationAccepted: JsonValue? = null + private var userPrearbitrationDeclined: JsonValue? = null + private var userPrearbitrationSubmitted: JsonValue? = null + private var userPrearbitrationTimedOut: JsonValue? = null + private var userWithdrawalSubmitted: JsonValue? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(networkEvent: NetworkEvent) = apply { + attachmentFiles = networkEvent.attachmentFiles.map { it.toMutableList() } + category = networkEvent.category + chargebackAccepted = networkEvent.chargebackAccepted + chargebackSubmitted = networkEvent.chargebackSubmitted + chargebackTimedOut = networkEvent.chargebackTimedOut + createdAt = networkEvent.createdAt + disputeFinancialTransactionId = networkEvent.disputeFinancialTransactionId + merchantPrearbitrationDeclineSubmitted = + networkEvent.merchantPrearbitrationDeclineSubmitted + merchantPrearbitrationReceived = networkEvent.merchantPrearbitrationReceived + merchantPrearbitrationTimedOut = networkEvent.merchantPrearbitrationTimedOut + represented = networkEvent.represented + representmentTimedOut = networkEvent.representmentTimedOut + userPrearbitrationAccepted = networkEvent.userPrearbitrationAccepted + userPrearbitrationDeclined = networkEvent.userPrearbitrationDeclined + userPrearbitrationSubmitted = networkEvent.userPrearbitrationSubmitted + userPrearbitrationTimedOut = networkEvent.userPrearbitrationTimedOut + userWithdrawalSubmitted = networkEvent.userWithdrawalSubmitted + additionalProperties = networkEvent.additionalProperties.toMutableMap() + } + + /** The files attached to the Visa Card Dispute User Submission. */ + fun attachmentFiles(attachmentFiles: List) = + attachmentFiles(JsonField.of(attachmentFiles)) + + /** + * Sets [Builder.attachmentFiles] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentFiles] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attachmentFiles(attachmentFiles: JsonField>) = apply { + this.attachmentFiles = attachmentFiles.map { it.toMutableList() } + } + + /** + * Adds a single [AttachmentFile] to [attachmentFiles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAttachmentFile(attachmentFile: AttachmentFile) = apply { + attachmentFiles = + (attachmentFiles ?: JsonField.of(mutableListOf())).also { + checkKnown("attachmentFiles", it).add(attachmentFile) + } + } + + /** + * The category of the user submission. We may add additional possible values for + * this enum over time; your application should be able to handle such additions + * gracefully. + */ + 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 } + + /** + * A Card Dispute Chargeback Accepted Visa Network Event object. This field will be + * present in the JSON response if and only if `category` is equal to + * `chargeback_accepted`. Contains the details specific to a chargeback accepted + * Visa Card Dispute Network Event, which represents that a chargeback has been + * accepted by the merchant. + */ + fun chargebackAccepted(chargebackAccepted: JsonValue) = apply { + this.chargebackAccepted = chargebackAccepted + } + + /** + * A Card Dispute Chargeback Submitted Visa Network Event object. This field will be + * present in the JSON response if and only if `category` is equal to + * `chargeback_submitted`. Contains the details specific to a chargeback submitted + * Visa Card Dispute Network Event, which represents that a chargeback has been + * submitted to the network. + */ + fun chargebackSubmitted(chargebackSubmitted: JsonValue) = apply { + this.chargebackSubmitted = chargebackSubmitted + } + + /** + * A Card Dispute Chargeback Timed Out Visa Network Event object. This field will be + * present in the JSON response if and only if `category` is equal to + * `chargeback_timed_out`. Contains the details specific to a chargeback timed out + * Visa Card Dispute Network Event, which represents that the chargeback has timed + * out in the user's favor. + */ + fun chargebackTimedOut(chargebackTimedOut: JsonValue) = apply { + this.chargebackTimedOut = chargebackTimedOut + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Visa Card Dispute Network Event was created. + */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** + * The dispute financial transaction that resulted from the network event, if any. + */ + fun disputeFinancialTransactionId(disputeFinancialTransactionId: String?) = + disputeFinancialTransactionId( + JsonField.ofNullable(disputeFinancialTransactionId) + ) + + /** + * Alias for calling [Builder.disputeFinancialTransactionId] with + * `disputeFinancialTransactionId.orElse(null)`. + */ + fun disputeFinancialTransactionId(disputeFinancialTransactionId: Optional) = + disputeFinancialTransactionId(disputeFinancialTransactionId.getOrNull()) + + /** + * Sets [Builder.disputeFinancialTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.disputeFinancialTransactionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun disputeFinancialTransactionId( + disputeFinancialTransactionId: JsonField + ) = apply { this.disputeFinancialTransactionId = disputeFinancialTransactionId } + + /** + * A Card Dispute Merchant Pre-Arbitration Decline Submitted Visa Network Event + * object. This field will be present in the JSON response if and only if `category` + * is equal to `merchant_prearbitration_decline_submitted`. Contains the details + * specific to a merchant prearbitration decline submitted Visa Card Dispute Network + * Event, which represents that the user has declined the merchant's request for a + * prearbitration request decision in their favor. + */ + fun merchantPrearbitrationDeclineSubmitted( + merchantPrearbitrationDeclineSubmitted: JsonValue + ) = apply { + this.merchantPrearbitrationDeclineSubmitted = + merchantPrearbitrationDeclineSubmitted + } + + /** + * A Card Dispute Merchant Pre-Arbitration Received Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_received`. Contains the details specific to a merchant + * prearbitration received Visa Card Dispute Network Event, which represents that + * the merchant has issued a prearbitration request in the user's favor. + */ + fun merchantPrearbitrationReceived( + merchantPrearbitrationReceived: MerchantPrearbitrationReceived? + ) = + merchantPrearbitrationReceived( + JsonField.ofNullable(merchantPrearbitrationReceived) + ) + + /** + * Alias for calling [Builder.merchantPrearbitrationReceived] with + * `merchantPrearbitrationReceived.orElse(null)`. + */ + fun merchantPrearbitrationReceived( + merchantPrearbitrationReceived: Optional + ) = merchantPrearbitrationReceived(merchantPrearbitrationReceived.getOrNull()) + + /** + * Sets [Builder.merchantPrearbitrationReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPrearbitrationReceived] with a + * well-typed [MerchantPrearbitrationReceived] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun merchantPrearbitrationReceived( + merchantPrearbitrationReceived: JsonField + ) = apply { this.merchantPrearbitrationReceived = merchantPrearbitrationReceived } + + /** + * A Card Dispute Merchant Pre-Arbitration Timed Out Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_timed_out`. Contains the details specific to a merchant + * prearbitration timed out Visa Card Dispute Network Event, which represents that + * the user has timed out responding to the merchant's prearbitration request. + */ + fun merchantPrearbitrationTimedOut(merchantPrearbitrationTimedOut: JsonValue) = + apply { + this.merchantPrearbitrationTimedOut = merchantPrearbitrationTimedOut + } + + /** + * A Card Dispute Re-presented Visa Network Event object. This field will be present + * in the JSON response if and only if `category` is equal to `represented`. + * Contains the details specific to a re-presented Visa Card Dispute Network Event, + * which represents that the merchant has declined the user's chargeback and has + * re-presented the payment. + */ + fun represented(represented: Represented?) = + represented(JsonField.ofNullable(represented)) + + /** Alias for calling [Builder.represented] with `represented.orElse(null)`. */ + fun represented(represented: Optional) = + represented(represented.getOrNull()) + + /** + * Sets [Builder.represented] to an arbitrary JSON value. + * + * You should usually call [Builder.represented] with a well-typed [Represented] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun represented(represented: JsonField) = apply { + this.represented = represented + } + + /** + * A Card Dispute Re-presentment Timed Out Visa Network Event object. This field + * will be present in the JSON response if and only if `category` is equal to + * `representment_timed_out`. Contains the details specific to a re-presentment + * time-out Visa Card Dispute Network Event, which represents that the user did not + * respond to the re-presentment by the merchant within the time limit. + */ + fun representmentTimedOut(representmentTimedOut: JsonValue) = apply { + this.representmentTimedOut = representmentTimedOut + } + + /** + * A Card Dispute User Pre-Arbitration Accepted Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration_accepted`. Contains the details specific to a user + * prearbitration accepted Visa Card Dispute Network Event, which represents that + * the merchant has accepted the user's prearbitration request in the user's favor. + */ + fun userPrearbitrationAccepted(userPrearbitrationAccepted: JsonValue) = apply { + this.userPrearbitrationAccepted = userPrearbitrationAccepted + } + + /** + * A Card Dispute User Pre-Arbitration Declined Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration_declined`. Contains the details specific to a user + * prearbitration declined Visa Card Dispute Network Event, which represents that + * the merchant has declined the user's prearbitration request. + */ + fun userPrearbitrationDeclined(userPrearbitrationDeclined: JsonValue) = apply { + this.userPrearbitrationDeclined = userPrearbitrationDeclined + } + + /** + * A Card Dispute User Pre-Arbitration Submitted Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration_submitted`. Contains the details specific to a user + * prearbitration submitted Visa Card Dispute Network Event, which represents that + * the user's request for prearbitration has been submitted to the network. + */ + fun userPrearbitrationSubmitted(userPrearbitrationSubmitted: JsonValue) = apply { + this.userPrearbitrationSubmitted = userPrearbitrationSubmitted + } + + /** + * A Card Dispute User Pre-Arbitration Timed Out Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration_timed_out`. Contains the details specific to a user + * prearbitration timed out Visa Card Dispute Network Event, which represents that + * the merchant has timed out responding to the user's prearbitration request. + */ + fun userPrearbitrationTimedOut(userPrearbitrationTimedOut: JsonValue) = apply { + this.userPrearbitrationTimedOut = userPrearbitrationTimedOut + } + + /** + * A Card Dispute User Withdrawal Submitted Visa Network Event object. This field + * will be present in the JSON response if and only if `category` is equal to + * `user_withdrawal_submitted`. Contains the details specific to a user withdrawal + * submitted Visa Card Dispute Network Event, which represents that the user's + * request to withdraw the dispute has been submitted to the network. + */ + fun userWithdrawalSubmitted(userWithdrawalSubmitted: JsonValue) = apply { + this.userWithdrawalSubmitted = userWithdrawalSubmitted + } + + 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 [NetworkEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attachmentFiles() + * .category() + * .chargebackAccepted() + * .chargebackSubmitted() + * .chargebackTimedOut() + * .createdAt() + * .disputeFinancialTransactionId() + * .merchantPrearbitrationDeclineSubmitted() + * .merchantPrearbitrationReceived() + * .merchantPrearbitrationTimedOut() + * .represented() + * .representmentTimedOut() + * .userPrearbitrationAccepted() + * .userPrearbitrationDeclined() + * .userPrearbitrationSubmitted() + * .userPrearbitrationTimedOut() + * .userWithdrawalSubmitted() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NetworkEvent = + NetworkEvent( + checkRequired("attachmentFiles", attachmentFiles).map { it.toImmutable() }, + checkRequired("category", category), + checkRequired("chargebackAccepted", chargebackAccepted), + checkRequired("chargebackSubmitted", chargebackSubmitted), + checkRequired("chargebackTimedOut", chargebackTimedOut), + checkRequired("createdAt", createdAt), + checkRequired( + "disputeFinancialTransactionId", + disputeFinancialTransactionId, + ), + checkRequired( + "merchantPrearbitrationDeclineSubmitted", + merchantPrearbitrationDeclineSubmitted, + ), + checkRequired( + "merchantPrearbitrationReceived", + merchantPrearbitrationReceived, + ), + checkRequired( + "merchantPrearbitrationTimedOut", + merchantPrearbitrationTimedOut, + ), + checkRequired("represented", represented), + checkRequired("representmentTimedOut", representmentTimedOut), + checkRequired("userPrearbitrationAccepted", userPrearbitrationAccepted), + checkRequired("userPrearbitrationDeclined", userPrearbitrationDeclined), + checkRequired("userPrearbitrationSubmitted", userPrearbitrationSubmitted), + checkRequired("userPrearbitrationTimedOut", userPrearbitrationTimedOut), + checkRequired("userWithdrawalSubmitted", userWithdrawalSubmitted), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NetworkEvent = apply { + if (validated) { + return@apply + } + + attachmentFiles().forEach { it.validate() } + category().validate() + createdAt() + disputeFinancialTransactionId() + merchantPrearbitrationReceived().ifPresent { it.validate() } + represented().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (attachmentFiles.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (disputeFinancialTransactionId.asKnown().isPresent) 1 else 0) + + (merchantPrearbitrationReceived.asKnown().getOrNull()?.validity() ?: 0) + + (represented.asKnown().getOrNull()?.validity() ?: 0) + + class AttachmentFile + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of() + ) : this(fileId, mutableMapOf()) + + /** + * The ID of the file attached to the Card Dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + @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 [AttachmentFile]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentFile]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentFile: AttachmentFile) = apply { + fileId = attachmentFile.fileId + additionalProperties = attachmentFile.additionalProperties.toMutableMap() + } + + /** The ID of the file attached to the Card Dispute. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + 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 [AttachmentFile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AttachmentFile = + AttachmentFile( + checkRequired("fileId", fileId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AttachmentFile = apply { + if (validated) { + return@apply + } + + fileId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (fileId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentFile && + fileId == other.fileId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AttachmentFile{fileId=$fileId, additionalProperties=$additionalProperties}" + } + + /** + * The category of the user submission. We may add additional possible values for this + * enum over time; your application should be able to handle such additions gracefully. + */ + 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 { + + /** + * Card Dispute Chargeback Accepted Visa Network Event: details will be under + * the `chargeback_accepted` object. + */ + @JvmField val CHARGEBACK_ACCEPTED = of("chargeback_accepted") + + /** + * Card Dispute Chargeback Submitted Visa Network Event: details will be under + * the `chargeback_submitted` object. + */ + @JvmField val CHARGEBACK_SUBMITTED = of("chargeback_submitted") + + /** + * Card Dispute Chargeback Timed Out Visa Network Event: details will be under + * the `chargeback_timed_out` object. + */ + @JvmField val CHARGEBACK_TIMED_OUT = of("chargeback_timed_out") + + /** + * Card Dispute Merchant Pre-Arbitration Decline Submitted Visa Network Event: + * details will be under the `merchant_prearbitration_decline_submitted` object. + */ + @JvmField + val MERCHANT_PREARBITRATION_DECLINE_SUBMITTED = + of("merchant_prearbitration_decline_submitted") + + /** + * Card Dispute Merchant Pre-Arbitration Received Visa Network Event: details + * will be under the `merchant_prearbitration_received` object. + */ + @JvmField + val MERCHANT_PREARBITRATION_RECEIVED = of("merchant_prearbitration_received") + + /** + * Card Dispute Merchant Pre-Arbitration Timed Out Visa Network Event: details + * will be under the `merchant_prearbitration_timed_out` object. + */ + @JvmField + val MERCHANT_PREARBITRATION_TIMED_OUT = of("merchant_prearbitration_timed_out") + + /** + * Card Dispute Re-presented Visa Network Event: details will be under the + * `represented` object. + */ + @JvmField val REPRESENTED = of("represented") + + /** + * Card Dispute Re-presentment Timed Out Visa Network Event: details will be + * under the `representment_timed_out` object. + */ + @JvmField val REPRESENTMENT_TIMED_OUT = of("representment_timed_out") + + /** + * Card Dispute User Pre-Arbitration Accepted Visa Network Event: details will + * be under the `user_prearbitration_accepted` object. + */ + @JvmField val USER_PREARBITRATION_ACCEPTED = of("user_prearbitration_accepted") + + /** + * Card Dispute User Pre-Arbitration Declined Visa Network Event: details will + * be under the `user_prearbitration_declined` object. + */ + @JvmField val USER_PREARBITRATION_DECLINED = of("user_prearbitration_declined") + + /** + * Card Dispute User Pre-Arbitration Submitted Visa Network Event: details will + * be under the `user_prearbitration_submitted` object. + */ + @JvmField + val USER_PREARBITRATION_SUBMITTED = of("user_prearbitration_submitted") + + /** + * Card Dispute User Pre-Arbitration Timed Out Visa Network Event: details will + * be under the `user_prearbitration_timed_out` object. + */ + @JvmField + val USER_PREARBITRATION_TIMED_OUT = of("user_prearbitration_timed_out") + + /** + * Card Dispute User Withdrawal Submitted Visa Network Event: details will be + * under the `user_withdrawal_submitted` object. + */ + @JvmField val USER_WITHDRAWAL_SUBMITTED = of("user_withdrawal_submitted") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** + * Card Dispute Chargeback Accepted Visa Network Event: details will be under + * the `chargeback_accepted` object. + */ + CHARGEBACK_ACCEPTED, + /** + * Card Dispute Chargeback Submitted Visa Network Event: details will be under + * the `chargeback_submitted` object. + */ + CHARGEBACK_SUBMITTED, + /** + * Card Dispute Chargeback Timed Out Visa Network Event: details will be under + * the `chargeback_timed_out` object. + */ + CHARGEBACK_TIMED_OUT, + /** + * Card Dispute Merchant Pre-Arbitration Decline Submitted Visa Network Event: + * details will be under the `merchant_prearbitration_decline_submitted` object. + */ + MERCHANT_PREARBITRATION_DECLINE_SUBMITTED, + /** + * Card Dispute Merchant Pre-Arbitration Received Visa Network Event: details + * will be under the `merchant_prearbitration_received` object. + */ + MERCHANT_PREARBITRATION_RECEIVED, + /** + * Card Dispute Merchant Pre-Arbitration Timed Out Visa Network Event: details + * will be under the `merchant_prearbitration_timed_out` object. + */ + MERCHANT_PREARBITRATION_TIMED_OUT, + /** + * Card Dispute Re-presented Visa Network Event: details will be under the + * `represented` object. + */ + REPRESENTED, + /** + * Card Dispute Re-presentment Timed Out Visa Network Event: details will be + * under the `representment_timed_out` object. + */ + REPRESENTMENT_TIMED_OUT, + /** + * Card Dispute User Pre-Arbitration Accepted Visa Network Event: details will + * be under the `user_prearbitration_accepted` object. + */ + USER_PREARBITRATION_ACCEPTED, + /** + * Card Dispute User Pre-Arbitration Declined Visa Network Event: details will + * be under the `user_prearbitration_declined` object. + */ + USER_PREARBITRATION_DECLINED, + /** + * Card Dispute User Pre-Arbitration Submitted Visa Network Event: details will + * be under the `user_prearbitration_submitted` object. + */ + USER_PREARBITRATION_SUBMITTED, + /** + * Card Dispute User Pre-Arbitration Timed Out Visa Network Event: details will + * be under the `user_prearbitration_timed_out` object. + */ + USER_PREARBITRATION_TIMED_OUT, + /** + * Card Dispute User Withdrawal Submitted Visa Network Event: details will be + * under the `user_withdrawal_submitted` object. + */ + USER_WITHDRAWAL_SUBMITTED, + } + + /** + * 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 { + /** + * Card Dispute Chargeback Accepted Visa Network Event: details will be under + * the `chargeback_accepted` object. + */ + CHARGEBACK_ACCEPTED, + /** + * Card Dispute Chargeback Submitted Visa Network Event: details will be under + * the `chargeback_submitted` object. + */ + CHARGEBACK_SUBMITTED, + /** + * Card Dispute Chargeback Timed Out Visa Network Event: details will be under + * the `chargeback_timed_out` object. + */ + CHARGEBACK_TIMED_OUT, + /** + * Card Dispute Merchant Pre-Arbitration Decline Submitted Visa Network Event: + * details will be under the `merchant_prearbitration_decline_submitted` object. + */ + MERCHANT_PREARBITRATION_DECLINE_SUBMITTED, + /** + * Card Dispute Merchant Pre-Arbitration Received Visa Network Event: details + * will be under the `merchant_prearbitration_received` object. + */ + MERCHANT_PREARBITRATION_RECEIVED, + /** + * Card Dispute Merchant Pre-Arbitration Timed Out Visa Network Event: details + * will be under the `merchant_prearbitration_timed_out` object. + */ + MERCHANT_PREARBITRATION_TIMED_OUT, + /** + * Card Dispute Re-presented Visa Network Event: details will be under the + * `represented` object. + */ + REPRESENTED, + /** + * Card Dispute Re-presentment Timed Out Visa Network Event: details will be + * under the `representment_timed_out` object. + */ + REPRESENTMENT_TIMED_OUT, + /** + * Card Dispute User Pre-Arbitration Accepted Visa Network Event: details will + * be under the `user_prearbitration_accepted` object. + */ + USER_PREARBITRATION_ACCEPTED, + /** + * Card Dispute User Pre-Arbitration Declined Visa Network Event: details will + * be under the `user_prearbitration_declined` object. + */ + USER_PREARBITRATION_DECLINED, + /** + * Card Dispute User Pre-Arbitration Submitted Visa Network Event: details will + * be under the `user_prearbitration_submitted` object. + */ + USER_PREARBITRATION_SUBMITTED, + /** + * Card Dispute User Pre-Arbitration Timed Out Visa Network Event: details will + * be under the `user_prearbitration_timed_out` object. + */ + USER_PREARBITRATION_TIMED_OUT, + /** + * Card Dispute User Withdrawal Submitted Visa Network Event: details will be + * under the `user_withdrawal_submitted` object. + */ + USER_WITHDRAWAL_SUBMITTED, + /** + * 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) { + CHARGEBACK_ACCEPTED -> Value.CHARGEBACK_ACCEPTED + CHARGEBACK_SUBMITTED -> Value.CHARGEBACK_SUBMITTED + CHARGEBACK_TIMED_OUT -> Value.CHARGEBACK_TIMED_OUT + MERCHANT_PREARBITRATION_DECLINE_SUBMITTED -> + Value.MERCHANT_PREARBITRATION_DECLINE_SUBMITTED + MERCHANT_PREARBITRATION_RECEIVED -> Value.MERCHANT_PREARBITRATION_RECEIVED + MERCHANT_PREARBITRATION_TIMED_OUT -> Value.MERCHANT_PREARBITRATION_TIMED_OUT + REPRESENTED -> Value.REPRESENTED + REPRESENTMENT_TIMED_OUT -> Value.REPRESENTMENT_TIMED_OUT + USER_PREARBITRATION_ACCEPTED -> Value.USER_PREARBITRATION_ACCEPTED + USER_PREARBITRATION_DECLINED -> Value.USER_PREARBITRATION_DECLINED + USER_PREARBITRATION_SUBMITTED -> Value.USER_PREARBITRATION_SUBMITTED + USER_PREARBITRATION_TIMED_OUT -> Value.USER_PREARBITRATION_TIMED_OUT + USER_WITHDRAWAL_SUBMITTED -> Value.USER_WITHDRAWAL_SUBMITTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CHARGEBACK_ACCEPTED -> Known.CHARGEBACK_ACCEPTED + CHARGEBACK_SUBMITTED -> Known.CHARGEBACK_SUBMITTED + CHARGEBACK_TIMED_OUT -> Known.CHARGEBACK_TIMED_OUT + MERCHANT_PREARBITRATION_DECLINE_SUBMITTED -> + Known.MERCHANT_PREARBITRATION_DECLINE_SUBMITTED + MERCHANT_PREARBITRATION_RECEIVED -> Known.MERCHANT_PREARBITRATION_RECEIVED + MERCHANT_PREARBITRATION_TIMED_OUT -> Known.MERCHANT_PREARBITRATION_TIMED_OUT + REPRESENTED -> Known.REPRESENTED + REPRESENTMENT_TIMED_OUT -> Known.REPRESENTMENT_TIMED_OUT + USER_PREARBITRATION_ACCEPTED -> Known.USER_PREARBITRATION_ACCEPTED + USER_PREARBITRATION_DECLINED -> Known.USER_PREARBITRATION_DECLINED + USER_PREARBITRATION_SUBMITTED -> Known.USER_PREARBITRATION_SUBMITTED + USER_PREARBITRATION_TIMED_OUT -> Known.USER_PREARBITRATION_TIMED_OUT + USER_WITHDRAWAL_SUBMITTED -> Known.USER_WITHDRAWAL_SUBMITTED + else -> throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * A Card Dispute Merchant Pre-Arbitration Received Visa Network Event object. This + * field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_received`. Contains the details specific to a merchant + * prearbitration received Visa Card Dispute Network Event, which represents that the + * merchant has issued a prearbitration request in the user's favor. + */ + class MerchantPrearbitrationReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderNoLongerDisputes: JsonField, + private val compellingEvidence: JsonField, + private val creditOrReversalProcessed: JsonField, + private val delayedChargeTransaction: JsonField, + private val evidenceOfImprint: JsonField, + private val invalidDispute: JsonField, + private val nonFiatCurrencyOrNonFungibleTokenReceived: + JsonField, + private val priorUndisputedNonFraudTransactions: + JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_no_longer_disputes") + @ExcludeMissing + cardholderNoLongerDisputes: JsonField = + JsonMissing.of(), + @JsonProperty("compelling_evidence") + @ExcludeMissing + compellingEvidence: JsonField = JsonMissing.of(), + @JsonProperty("credit_or_reversal_processed") + @ExcludeMissing + creditOrReversalProcessed: JsonField = + JsonMissing.of(), + @JsonProperty("delayed_charge_transaction") + @ExcludeMissing + delayedChargeTransaction: JsonField = + JsonMissing.of(), + @JsonProperty("evidence_of_imprint") + @ExcludeMissing + evidenceOfImprint: JsonField = JsonMissing.of(), + @JsonProperty("invalid_dispute") + @ExcludeMissing + invalidDispute: JsonField = JsonMissing.of(), + @JsonProperty("non_fiat_currency_or_non_fungible_token_received") + @ExcludeMissing + nonFiatCurrencyOrNonFungibleTokenReceived: + JsonField = + JsonMissing.of(), + @JsonProperty("prior_undisputed_non_fraud_transactions") + @ExcludeMissing + priorUndisputedNonFraudTransactions: + JsonField = + JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + cardholderNoLongerDisputes, + compellingEvidence, + creditOrReversalProcessed, + delayedChargeTransaction, + evidenceOfImprint, + invalidDispute, + nonFiatCurrencyOrNonFungibleTokenReceived, + priorUndisputedNonFraudTransactions, + reason, + mutableMapOf(), + ) + + /** + * Cardholder no longer disputes details. Present if and only if `reason` is + * `cardholder_no_longer_disputes`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderNoLongerDisputes(): Optional = + cardholderNoLongerDisputes.getOptional("cardholder_no_longer_disputes") + + /** + * Compelling evidence details. Present if and only if `reason` is + * `compelling_evidence`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun compellingEvidence(): Optional = + compellingEvidence.getOptional("compelling_evidence") + + /** + * Credit or reversal processed details. Present if and only if `reason` is + * `credit_or_reversal_processed`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun creditOrReversalProcessed(): Optional = + creditOrReversalProcessed.getOptional("credit_or_reversal_processed") + + /** + * Delayed charge transaction details. Present if and only if `reason` is + * `delayed_charge_transaction`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun delayedChargeTransaction(): Optional = + delayedChargeTransaction.getOptional("delayed_charge_transaction") + + /** + * Evidence of imprint details. Present if and only if `reason` is + * `evidence_of_imprint`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun evidenceOfImprint(): Optional = + evidenceOfImprint.getOptional("evidence_of_imprint") + + /** + * Invalid dispute details. Present if and only if `reason` is `invalid_dispute`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun invalidDispute(): Optional = + invalidDispute.getOptional("invalid_dispute") + + /** + * Non-fiat currency or non-fungible token received details. Present if and only if + * `reason` is `non_fiat_currency_or_non_fungible_token_received`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nonFiatCurrencyOrNonFungibleTokenReceived(): + Optional = + nonFiatCurrencyOrNonFungibleTokenReceived.getOptional( + "non_fiat_currency_or_non_fungible_token_received" + ) + + /** + * Prior undisputed non-fraud transactions details. Present if and only if `reason` + * is `prior_undisputed_non_fraud_transactions`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun priorUndisputedNonFraudTransactions(): + Optional = + priorUndisputedNonFraudTransactions.getOptional( + "prior_undisputed_non_fraud_transactions" + ) + + /** + * The reason the merchant re-presented the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): Reason = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [cardholderNoLongerDisputes]. + * + * Unlike [cardholderNoLongerDisputes], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cardholder_no_longer_disputes") + @ExcludeMissing + fun _cardholderNoLongerDisputes(): JsonField = + cardholderNoLongerDisputes + + /** + * Returns the raw JSON value of [compellingEvidence]. + * + * Unlike [compellingEvidence], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("compelling_evidence") + @ExcludeMissing + fun _compellingEvidence(): JsonField = compellingEvidence + + /** + * Returns the raw JSON value of [creditOrReversalProcessed]. + * + * Unlike [creditOrReversalProcessed], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("credit_or_reversal_processed") + @ExcludeMissing + fun _creditOrReversalProcessed(): JsonField = + creditOrReversalProcessed + + /** + * Returns the raw JSON value of [delayedChargeTransaction]. + * + * Unlike [delayedChargeTransaction], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("delayed_charge_transaction") + @ExcludeMissing + fun _delayedChargeTransaction(): JsonField = + delayedChargeTransaction + + /** + * Returns the raw JSON value of [evidenceOfImprint]. + * + * Unlike [evidenceOfImprint], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("evidence_of_imprint") + @ExcludeMissing + fun _evidenceOfImprint(): JsonField = evidenceOfImprint + + /** + * Returns the raw JSON value of [invalidDispute]. + * + * Unlike [invalidDispute], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invalid_dispute") + @ExcludeMissing + fun _invalidDispute(): JsonField = invalidDispute + + /** + * Returns the raw JSON value of [nonFiatCurrencyOrNonFungibleTokenReceived]. + * + * Unlike [nonFiatCurrencyOrNonFungibleTokenReceived], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("non_fiat_currency_or_non_fungible_token_received") + @ExcludeMissing + fun _nonFiatCurrencyOrNonFungibleTokenReceived(): + JsonField = + nonFiatCurrencyOrNonFungibleTokenReceived + + /** + * Returns the raw JSON value of [priorUndisputedNonFraudTransactions]. + * + * Unlike [priorUndisputedNonFraudTransactions], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("prior_undisputed_non_fraud_transactions") + @ExcludeMissing + fun _priorUndisputedNonFraudTransactions(): + JsonField = + priorUndisputedNonFraudTransactions + + /** + * 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 + + @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 + * [MerchantPrearbitrationReceived]. + * + * The following fields are required: + * ```java + * .cardholderNoLongerDisputes() + * .compellingEvidence() + * .creditOrReversalProcessed() + * .delayedChargeTransaction() + * .evidenceOfImprint() + * .invalidDispute() + * .nonFiatCurrencyOrNonFungibleTokenReceived() + * .priorUndisputedNonFraudTransactions() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantPrearbitrationReceived]. */ + class Builder internal constructor() { + + private var cardholderNoLongerDisputes: JsonField? = + null + private var compellingEvidence: JsonField? = null + private var creditOrReversalProcessed: JsonField? = + null + private var delayedChargeTransaction: JsonField? = + null + private var evidenceOfImprint: JsonField? = null + private var invalidDispute: JsonField? = null + private var nonFiatCurrencyOrNonFungibleTokenReceived: + JsonField? = + null + private var priorUndisputedNonFraudTransactions: + JsonField? = + null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + merchantPrearbitrationReceived: MerchantPrearbitrationReceived + ) = apply { + cardholderNoLongerDisputes = + merchantPrearbitrationReceived.cardholderNoLongerDisputes + compellingEvidence = merchantPrearbitrationReceived.compellingEvidence + creditOrReversalProcessed = + merchantPrearbitrationReceived.creditOrReversalProcessed + delayedChargeTransaction = + merchantPrearbitrationReceived.delayedChargeTransaction + evidenceOfImprint = merchantPrearbitrationReceived.evidenceOfImprint + invalidDispute = merchantPrearbitrationReceived.invalidDispute + nonFiatCurrencyOrNonFungibleTokenReceived = + merchantPrearbitrationReceived.nonFiatCurrencyOrNonFungibleTokenReceived + priorUndisputedNonFraudTransactions = + merchantPrearbitrationReceived.priorUndisputedNonFraudTransactions + reason = merchantPrearbitrationReceived.reason + additionalProperties = + merchantPrearbitrationReceived.additionalProperties.toMutableMap() + } + + /** + * Cardholder no longer disputes details. Present if and only if `reason` is + * `cardholder_no_longer_disputes`. + */ + fun cardholderNoLongerDisputes( + cardholderNoLongerDisputes: CardholderNoLongerDisputes? + ) = cardholderNoLongerDisputes(JsonField.ofNullable(cardholderNoLongerDisputes)) + + /** + * Alias for calling [Builder.cardholderNoLongerDisputes] with + * `cardholderNoLongerDisputes.orElse(null)`. + */ + fun cardholderNoLongerDisputes( + cardholderNoLongerDisputes: Optional + ) = cardholderNoLongerDisputes(cardholderNoLongerDisputes.getOrNull()) + + /** + * Sets [Builder.cardholderNoLongerDisputes] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderNoLongerDisputes] with a + * well-typed [CardholderNoLongerDisputes] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderNoLongerDisputes( + cardholderNoLongerDisputes: JsonField + ) = apply { this.cardholderNoLongerDisputes = cardholderNoLongerDisputes } + + /** + * Compelling evidence details. Present if and only if `reason` is + * `compelling_evidence`. + */ + fun compellingEvidence(compellingEvidence: CompellingEvidence?) = + compellingEvidence(JsonField.ofNullable(compellingEvidence)) + + /** + * Alias for calling [Builder.compellingEvidence] with + * `compellingEvidence.orElse(null)`. + */ + fun compellingEvidence(compellingEvidence: Optional) = + compellingEvidence(compellingEvidence.getOrNull()) + + /** + * Sets [Builder.compellingEvidence] to an arbitrary JSON value. + * + * You should usually call [Builder.compellingEvidence] with a well-typed + * [CompellingEvidence] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun compellingEvidence(compellingEvidence: JsonField) = + apply { + this.compellingEvidence = compellingEvidence + } + + /** + * Credit or reversal processed details. Present if and only if `reason` is + * `credit_or_reversal_processed`. + */ + fun creditOrReversalProcessed( + creditOrReversalProcessed: CreditOrReversalProcessed? + ) = creditOrReversalProcessed(JsonField.ofNullable(creditOrReversalProcessed)) + + /** + * Alias for calling [Builder.creditOrReversalProcessed] with + * `creditOrReversalProcessed.orElse(null)`. + */ + fun creditOrReversalProcessed( + creditOrReversalProcessed: Optional + ) = creditOrReversalProcessed(creditOrReversalProcessed.getOrNull()) + + /** + * Sets [Builder.creditOrReversalProcessed] to an arbitrary JSON value. + * + * You should usually call [Builder.creditOrReversalProcessed] with a well-typed + * [CreditOrReversalProcessed] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun creditOrReversalProcessed( + creditOrReversalProcessed: JsonField + ) = apply { this.creditOrReversalProcessed = creditOrReversalProcessed } + + /** + * Delayed charge transaction details. Present if and only if `reason` is + * `delayed_charge_transaction`. + */ + fun delayedChargeTransaction( + delayedChargeTransaction: DelayedChargeTransaction? + ) = delayedChargeTransaction(JsonField.ofNullable(delayedChargeTransaction)) + + /** + * Alias for calling [Builder.delayedChargeTransaction] with + * `delayedChargeTransaction.orElse(null)`. + */ + fun delayedChargeTransaction( + delayedChargeTransaction: Optional + ) = delayedChargeTransaction(delayedChargeTransaction.getOrNull()) + + /** + * Sets [Builder.delayedChargeTransaction] to an arbitrary JSON value. + * + * You should usually call [Builder.delayedChargeTransaction] with a well-typed + * [DelayedChargeTransaction] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun delayedChargeTransaction( + delayedChargeTransaction: JsonField + ) = apply { this.delayedChargeTransaction = delayedChargeTransaction } + + /** + * Evidence of imprint details. Present if and only if `reason` is + * `evidence_of_imprint`. + */ + fun evidenceOfImprint(evidenceOfImprint: EvidenceOfImprint?) = + evidenceOfImprint(JsonField.ofNullable(evidenceOfImprint)) + + /** + * Alias for calling [Builder.evidenceOfImprint] with + * `evidenceOfImprint.orElse(null)`. + */ + fun evidenceOfImprint(evidenceOfImprint: Optional) = + evidenceOfImprint(evidenceOfImprint.getOrNull()) + + /** + * Sets [Builder.evidenceOfImprint] to an arbitrary JSON value. + * + * You should usually call [Builder.evidenceOfImprint] with a well-typed + * [EvidenceOfImprint] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun evidenceOfImprint(evidenceOfImprint: JsonField) = apply { + this.evidenceOfImprint = evidenceOfImprint + } + + /** + * Invalid dispute details. Present if and only if `reason` is + * `invalid_dispute`. + */ + fun invalidDispute(invalidDispute: InvalidDispute?) = + invalidDispute(JsonField.ofNullable(invalidDispute)) + + /** + * Alias for calling [Builder.invalidDispute] with + * `invalidDispute.orElse(null)`. + */ + fun invalidDispute(invalidDispute: Optional) = + invalidDispute(invalidDispute.getOrNull()) + + /** + * Sets [Builder.invalidDispute] to an arbitrary JSON value. + * + * You should usually call [Builder.invalidDispute] with a well-typed + * [InvalidDispute] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invalidDispute(invalidDispute: JsonField) = apply { + this.invalidDispute = invalidDispute + } + + /** + * Non-fiat currency or non-fungible token received details. Present if and only + * if `reason` is `non_fiat_currency_or_non_fungible_token_received`. + */ + fun nonFiatCurrencyOrNonFungibleTokenReceived( + nonFiatCurrencyOrNonFungibleTokenReceived: + NonFiatCurrencyOrNonFungibleTokenReceived? + ) = + nonFiatCurrencyOrNonFungibleTokenReceived( + JsonField.ofNullable(nonFiatCurrencyOrNonFungibleTokenReceived) + ) + + /** + * Alias for calling [Builder.nonFiatCurrencyOrNonFungibleTokenReceived] with + * `nonFiatCurrencyOrNonFungibleTokenReceived.orElse(null)`. + */ + fun nonFiatCurrencyOrNonFungibleTokenReceived( + nonFiatCurrencyOrNonFungibleTokenReceived: + Optional + ) = + nonFiatCurrencyOrNonFungibleTokenReceived( + nonFiatCurrencyOrNonFungibleTokenReceived.getOrNull() + ) + + /** + * Sets [Builder.nonFiatCurrencyOrNonFungibleTokenReceived] to an arbitrary JSON + * value. + * + * You should usually call [Builder.nonFiatCurrencyOrNonFungibleTokenReceived] + * with a well-typed [NonFiatCurrencyOrNonFungibleTokenReceived] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun nonFiatCurrencyOrNonFungibleTokenReceived( + nonFiatCurrencyOrNonFungibleTokenReceived: + JsonField + ) = apply { + this.nonFiatCurrencyOrNonFungibleTokenReceived = + nonFiatCurrencyOrNonFungibleTokenReceived + } + + /** + * Prior undisputed non-fraud transactions details. Present if and only if + * `reason` is `prior_undisputed_non_fraud_transactions`. + */ + fun priorUndisputedNonFraudTransactions( + priorUndisputedNonFraudTransactions: PriorUndisputedNonFraudTransactions? + ) = + priorUndisputedNonFraudTransactions( + JsonField.ofNullable(priorUndisputedNonFraudTransactions) + ) + + /** + * Alias for calling [Builder.priorUndisputedNonFraudTransactions] with + * `priorUndisputedNonFraudTransactions.orElse(null)`. + */ + fun priorUndisputedNonFraudTransactions( + priorUndisputedNonFraudTransactions: + Optional + ) = + priorUndisputedNonFraudTransactions( + priorUndisputedNonFraudTransactions.getOrNull() + ) + + /** + * Sets [Builder.priorUndisputedNonFraudTransactions] to an arbitrary JSON + * value. + * + * You should usually call [Builder.priorUndisputedNonFraudTransactions] with a + * well-typed [PriorUndisputedNonFraudTransactions] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun priorUndisputedNonFraudTransactions( + priorUndisputedNonFraudTransactions: + JsonField + ) = apply { + this.priorUndisputedNonFraudTransactions = + priorUndisputedNonFraudTransactions + } + + /** The reason the merchant re-presented the dispute. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [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 } + + 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 [MerchantPrearbitrationReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderNoLongerDisputes() + * .compellingEvidence() + * .creditOrReversalProcessed() + * .delayedChargeTransaction() + * .evidenceOfImprint() + * .invalidDispute() + * .nonFiatCurrencyOrNonFungibleTokenReceived() + * .priorUndisputedNonFraudTransactions() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantPrearbitrationReceived = + MerchantPrearbitrationReceived( + checkRequired("cardholderNoLongerDisputes", cardholderNoLongerDisputes), + checkRequired("compellingEvidence", compellingEvidence), + checkRequired("creditOrReversalProcessed", creditOrReversalProcessed), + checkRequired("delayedChargeTransaction", delayedChargeTransaction), + checkRequired("evidenceOfImprint", evidenceOfImprint), + checkRequired("invalidDispute", invalidDispute), + checkRequired( + "nonFiatCurrencyOrNonFungibleTokenReceived", + nonFiatCurrencyOrNonFungibleTokenReceived, + ), + checkRequired( + "priorUndisputedNonFraudTransactions", + priorUndisputedNonFraudTransactions, + ), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantPrearbitrationReceived = apply { + if (validated) { + return@apply + } + + cardholderNoLongerDisputes().ifPresent { it.validate() } + compellingEvidence().ifPresent { it.validate() } + creditOrReversalProcessed().ifPresent { it.validate() } + delayedChargeTransaction().ifPresent { it.validate() } + evidenceOfImprint().ifPresent { it.validate() } + invalidDispute().ifPresent { it.validate() } + nonFiatCurrencyOrNonFungibleTokenReceived().ifPresent { it.validate() } + priorUndisputedNonFraudTransactions().ifPresent { it.validate() } + reason().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderNoLongerDisputes.asKnown().getOrNull()?.validity() ?: 0) + + (compellingEvidence.asKnown().getOrNull()?.validity() ?: 0) + + (creditOrReversalProcessed.asKnown().getOrNull()?.validity() ?: 0) + + (delayedChargeTransaction.asKnown().getOrNull()?.validity() ?: 0) + + (evidenceOfImprint.asKnown().getOrNull()?.validity() ?: 0) + + (invalidDispute.asKnown().getOrNull()?.validity() ?: 0) + + (nonFiatCurrencyOrNonFungibleTokenReceived.asKnown().getOrNull()?.validity() + ?: 0) + + (priorUndisputedNonFraudTransactions.asKnown().getOrNull()?.validity() + ?: 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Cardholder no longer disputes details. Present if and only if `reason` is + * `cardholder_no_longer_disputes`. + */ + class CardholderNoLongerDisputes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation for why the merchant believes the cardholder no longer disputes + * the transaction. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * 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 + + @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 + * [CardholderNoLongerDisputes]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderNoLongerDisputes]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderNoLongerDisputes: CardholderNoLongerDisputes) = + apply { + explanation = cardholderNoLongerDisputes.explanation + additionalProperties = + cardholderNoLongerDisputes.additionalProperties.toMutableMap() + } + + /** + * Explanation for why the merchant believes the cardholder no longer + * disputes the transaction. + */ + 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 + } + + 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 [CardholderNoLongerDisputes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderNoLongerDisputes = + CardholderNoLongerDisputes( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderNoLongerDisputes = apply { + if (validated) { + return@apply + } + + explanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (explanation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderNoLongerDisputes && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderNoLongerDisputes{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + /** + * Compelling evidence details. Present if and only if `reason` is + * `compelling_evidence`. + */ + class CompellingEvidence + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val category: JsonField, + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + ) : this(category, explanation, mutableMapOf()) + + /** + * The category of compelling evidence provided by the merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun category(): Category = category.getRequired("category") + + /** + * Explanation of the compelling evidence provided by the merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * 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 [explanation]. + * + * Unlike [explanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("explanation") + @ExcludeMissing + fun _explanation(): JsonField = explanation + + @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 + * [CompellingEvidence]. + * + * The following fields are required: + * ```java + * .category() + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CompellingEvidence]. */ + class Builder internal constructor() { + + private var category: JsonField? = null + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(compellingEvidence: CompellingEvidence) = apply { + category = compellingEvidence.category + explanation = compellingEvidence.explanation + additionalProperties = + compellingEvidence.additionalProperties.toMutableMap() + } + + /** The category of compelling evidence provided by the merchant. */ + 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 + } + + /** Explanation of the compelling evidence provided by the merchant. */ + 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 + } + + 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 [CompellingEvidence]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .category() + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CompellingEvidence = + CompellingEvidence( + checkRequired("category", category), + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CompellingEvidence = apply { + if (validated) { + return@apply + } + + category().validate() + explanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (explanation.asKnown().isPresent) 1 else 0) + + /** The category of compelling evidence provided by the merchant. */ + 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 { + + /** Authorized signer known by the cardholder. */ + @JvmField val AUTHORIZED_SIGNER = of("authorized_signer") + + /** Proof of delivery. */ + @JvmField val DELIVERY = of("delivery") + + /** Proof of delivery to cardholder at place of employment. */ + @JvmField + val DELIVERY_AT_PLACE_OF_EMPLOYMENT = + of("delivery_at_place_of_employment") + + /** Proof of digital goods download. */ + @JvmField val DIGITAL_GOODS_DOWNLOAD = of("digital_goods_download") + + /** Dynamic Currency Conversion actively chosen by cardholder. */ + @JvmField + val DYNAMIC_CURRENCY_CONVERSION_ACTIVELY_CHOSEN = + of("dynamic_currency_conversion_actively_chosen") + + /** Flight manifest with corresponding purchase itinerary record. */ + @JvmField + val FLIGHT_MANIFEST_AND_PURCHASE_ITINERARY = + of("flight_manifest_and_purchase_itinerary") + + /** Signer is member of cardholder's household. */ + @JvmField val HOUSEHOLD_MEMBER_SIGNER = of("household_member_signer") + + /** + * Legitimate spend across multiple payment types for same merchandise. + */ + @JvmField + val LEGITIMATE_SPEND_ACROSS_PAYMENT_TYPES_FOR_SAME_MERCHANDISE = + of("legitimate_spend_across_payment_types_for_same_merchandise") + + /** + * Documentation to prove the cardholder is in possession of and/or + * using the merchandise. + */ + @JvmField val MERCHANDISE_USE = of("merchandise_use") + + /** + * Passenger transport: proof ticket was received, scanned at gate or + * other transaction related to original (for example, frequent flyer + * miles.) + */ + @JvmField + val PASSENGER_TRANSPORT_TICKET_USE = + of("passenger_transport_ticket_use") + + /** + * Recurring transaction with binding contract or previous undisputed + * recurring transactions and proof the cardholder is using the + * merchandise or service. + */ + @JvmField + val RECURRING_TRANSACTION_WITH_BINDING_CONTRACT_OR_PREVIOUS_UNDISPUTED_TRANSACTION = + of( + "recurring_transaction_with_binding_contract_or_previous_undisputed_transaction" + ) + + /** + * Signed delivery form, or copy of/details of identification from + * cardholder as proof goods were picked up at merchant location. + */ + @JvmField + val SIGNED_DELIVERY_OR_PICKUP_FORM = + of("signed_delivery_or_pickup_form") + + /** Signed Mail Order/Phone Order form. */ + @JvmField + val SIGNED_MAIL_ORDER_PHONE_ORDER_FORM = + of("signed_mail_order_phone_order_form") + + /** Travel & Expense: loyalty transactions related to purchase. */ + @JvmField + val TRAVEL_AND_EXPENSE_LOYALTY_TRANSACTION = + of("travel_and_expense_loyalty_transaction") + + /** + * Travel & Expense: subsequent purchases made throughout service + * period. + */ + @JvmField + val TRAVEL_AND_EXPENSE_SUBSEQUENT_PURCHASE = + of("travel_and_expense_subsequent_purchase") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** Authorized signer known by the cardholder. */ + AUTHORIZED_SIGNER, + /** Proof of delivery. */ + DELIVERY, + /** Proof of delivery to cardholder at place of employment. */ + DELIVERY_AT_PLACE_OF_EMPLOYMENT, + /** Proof of digital goods download. */ + DIGITAL_GOODS_DOWNLOAD, + /** Dynamic Currency Conversion actively chosen by cardholder. */ + DYNAMIC_CURRENCY_CONVERSION_ACTIVELY_CHOSEN, + /** Flight manifest with corresponding purchase itinerary record. */ + FLIGHT_MANIFEST_AND_PURCHASE_ITINERARY, + /** Signer is member of cardholder's household. */ + HOUSEHOLD_MEMBER_SIGNER, + /** + * Legitimate spend across multiple payment types for same merchandise. + */ + LEGITIMATE_SPEND_ACROSS_PAYMENT_TYPES_FOR_SAME_MERCHANDISE, + /** + * Documentation to prove the cardholder is in possession of and/or + * using the merchandise. + */ + MERCHANDISE_USE, + /** + * Passenger transport: proof ticket was received, scanned at gate or + * other transaction related to original (for example, frequent flyer + * miles.) + */ + PASSENGER_TRANSPORT_TICKET_USE, + /** + * Recurring transaction with binding contract or previous undisputed + * recurring transactions and proof the cardholder is using the + * merchandise or service. + */ + RECURRING_TRANSACTION_WITH_BINDING_CONTRACT_OR_PREVIOUS_UNDISPUTED_TRANSACTION, + /** + * Signed delivery form, or copy of/details of identification from + * cardholder as proof goods were picked up at merchant location. + */ + SIGNED_DELIVERY_OR_PICKUP_FORM, + /** Signed Mail Order/Phone Order form. */ + SIGNED_MAIL_ORDER_PHONE_ORDER_FORM, + /** Travel & Expense: loyalty transactions related to purchase. */ + TRAVEL_AND_EXPENSE_LOYALTY_TRANSACTION, + /** + * Travel & Expense: subsequent purchases made throughout service + * period. + */ + TRAVEL_AND_EXPENSE_SUBSEQUENT_PURCHASE, + } + + /** + * 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 { + /** Authorized signer known by the cardholder. */ + AUTHORIZED_SIGNER, + /** Proof of delivery. */ + DELIVERY, + /** Proof of delivery to cardholder at place of employment. */ + DELIVERY_AT_PLACE_OF_EMPLOYMENT, + /** Proof of digital goods download. */ + DIGITAL_GOODS_DOWNLOAD, + /** Dynamic Currency Conversion actively chosen by cardholder. */ + DYNAMIC_CURRENCY_CONVERSION_ACTIVELY_CHOSEN, + /** Flight manifest with corresponding purchase itinerary record. */ + FLIGHT_MANIFEST_AND_PURCHASE_ITINERARY, + /** Signer is member of cardholder's household. */ + HOUSEHOLD_MEMBER_SIGNER, + /** + * Legitimate spend across multiple payment types for same merchandise. + */ + LEGITIMATE_SPEND_ACROSS_PAYMENT_TYPES_FOR_SAME_MERCHANDISE, + /** + * Documentation to prove the cardholder is in possession of and/or + * using the merchandise. + */ + MERCHANDISE_USE, + /** + * Passenger transport: proof ticket was received, scanned at gate or + * other transaction related to original (for example, frequent flyer + * miles.) + */ + PASSENGER_TRANSPORT_TICKET_USE, + /** + * Recurring transaction with binding contract or previous undisputed + * recurring transactions and proof the cardholder is using the + * merchandise or service. + */ + RECURRING_TRANSACTION_WITH_BINDING_CONTRACT_OR_PREVIOUS_UNDISPUTED_TRANSACTION, + /** + * Signed delivery form, or copy of/details of identification from + * cardholder as proof goods were picked up at merchant location. + */ + SIGNED_DELIVERY_OR_PICKUP_FORM, + /** Signed Mail Order/Phone Order form. */ + SIGNED_MAIL_ORDER_PHONE_ORDER_FORM, + /** Travel & Expense: loyalty transactions related to purchase. */ + TRAVEL_AND_EXPENSE_LOYALTY_TRANSACTION, + /** + * Travel & Expense: subsequent purchases made throughout service + * period. + */ + TRAVEL_AND_EXPENSE_SUBSEQUENT_PURCHASE, + /** + * 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) { + AUTHORIZED_SIGNER -> Value.AUTHORIZED_SIGNER + DELIVERY -> Value.DELIVERY + DELIVERY_AT_PLACE_OF_EMPLOYMENT -> + Value.DELIVERY_AT_PLACE_OF_EMPLOYMENT + DIGITAL_GOODS_DOWNLOAD -> Value.DIGITAL_GOODS_DOWNLOAD + DYNAMIC_CURRENCY_CONVERSION_ACTIVELY_CHOSEN -> + Value.DYNAMIC_CURRENCY_CONVERSION_ACTIVELY_CHOSEN + FLIGHT_MANIFEST_AND_PURCHASE_ITINERARY -> + Value.FLIGHT_MANIFEST_AND_PURCHASE_ITINERARY + HOUSEHOLD_MEMBER_SIGNER -> Value.HOUSEHOLD_MEMBER_SIGNER + LEGITIMATE_SPEND_ACROSS_PAYMENT_TYPES_FOR_SAME_MERCHANDISE -> + Value.LEGITIMATE_SPEND_ACROSS_PAYMENT_TYPES_FOR_SAME_MERCHANDISE + MERCHANDISE_USE -> Value.MERCHANDISE_USE + PASSENGER_TRANSPORT_TICKET_USE -> + Value.PASSENGER_TRANSPORT_TICKET_USE + RECURRING_TRANSACTION_WITH_BINDING_CONTRACT_OR_PREVIOUS_UNDISPUTED_TRANSACTION -> + Value + .RECURRING_TRANSACTION_WITH_BINDING_CONTRACT_OR_PREVIOUS_UNDISPUTED_TRANSACTION + SIGNED_DELIVERY_OR_PICKUP_FORM -> + Value.SIGNED_DELIVERY_OR_PICKUP_FORM + SIGNED_MAIL_ORDER_PHONE_ORDER_FORM -> + Value.SIGNED_MAIL_ORDER_PHONE_ORDER_FORM + TRAVEL_AND_EXPENSE_LOYALTY_TRANSACTION -> + Value.TRAVEL_AND_EXPENSE_LOYALTY_TRANSACTION + TRAVEL_AND_EXPENSE_SUBSEQUENT_PURCHASE -> + Value.TRAVEL_AND_EXPENSE_SUBSEQUENT_PURCHASE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + AUTHORIZED_SIGNER -> Known.AUTHORIZED_SIGNER + DELIVERY -> Known.DELIVERY + DELIVERY_AT_PLACE_OF_EMPLOYMENT -> + Known.DELIVERY_AT_PLACE_OF_EMPLOYMENT + DIGITAL_GOODS_DOWNLOAD -> Known.DIGITAL_GOODS_DOWNLOAD + DYNAMIC_CURRENCY_CONVERSION_ACTIVELY_CHOSEN -> + Known.DYNAMIC_CURRENCY_CONVERSION_ACTIVELY_CHOSEN + FLIGHT_MANIFEST_AND_PURCHASE_ITINERARY -> + Known.FLIGHT_MANIFEST_AND_PURCHASE_ITINERARY + HOUSEHOLD_MEMBER_SIGNER -> Known.HOUSEHOLD_MEMBER_SIGNER + LEGITIMATE_SPEND_ACROSS_PAYMENT_TYPES_FOR_SAME_MERCHANDISE -> + Known.LEGITIMATE_SPEND_ACROSS_PAYMENT_TYPES_FOR_SAME_MERCHANDISE + MERCHANDISE_USE -> Known.MERCHANDISE_USE + PASSENGER_TRANSPORT_TICKET_USE -> + Known.PASSENGER_TRANSPORT_TICKET_USE + RECURRING_TRANSACTION_WITH_BINDING_CONTRACT_OR_PREVIOUS_UNDISPUTED_TRANSACTION -> + Known + .RECURRING_TRANSACTION_WITH_BINDING_CONTRACT_OR_PREVIOUS_UNDISPUTED_TRANSACTION + SIGNED_DELIVERY_OR_PICKUP_FORM -> + Known.SIGNED_DELIVERY_OR_PICKUP_FORM + SIGNED_MAIL_ORDER_PHONE_ORDER_FORM -> + Known.SIGNED_MAIL_ORDER_PHONE_ORDER_FORM + TRAVEL_AND_EXPENSE_LOYALTY_TRANSACTION -> + Known.TRAVEL_AND_EXPENSE_LOYALTY_TRANSACTION + TRAVEL_AND_EXPENSE_SUBSEQUENT_PURCHASE -> + Known.TRAVEL_AND_EXPENSE_SUBSEQUENT_PURCHASE + else -> + throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CompellingEvidence && + category == other.category && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(category, explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CompellingEvidence{category=$category, explanation=$explanation, additionalProperties=$additionalProperties}" + } + + /** + * Credit or reversal processed details. Present if and only if `reason` is + * `credit_or_reversal_processed`. + */ + class CreditOrReversalProcessed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val explanation: JsonField, + private val processedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("processed_at") + @ExcludeMissing + processedAt: JsonField = JsonMissing.of(), + ) : this(amount, currency, explanation, processedAt, mutableMapOf()) + + /** + * The amount of the credit or reversal in the minor unit of its currency. For + * dollars, for example, this is cents. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): Long = amount.getRequired("amount") + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the credit or + * reversal's currency. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Explanation for why the merchant believes the credit or reversal was + * processed. + * + * @throws IncreaseInvalidDataException 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 date the credit or reversal was processed. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun processedAt(): LocalDate = processedAt.getRequired("processed_at") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * 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 [processedAt]. + * + * Unlike [processedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("processed_at") + @ExcludeMissing + fun _processedAt(): JsonField = processedAt + + @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 + * [CreditOrReversalProcessed]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .explanation() + * .processedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditOrReversalProcessed]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var explanation: JsonField? = null + private var processedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(creditOrReversalProcessed: CreditOrReversalProcessed) = + apply { + amount = creditOrReversalProcessed.amount + currency = creditOrReversalProcessed.currency + explanation = creditOrReversalProcessed.explanation + processedAt = creditOrReversalProcessed.processedAt + additionalProperties = + creditOrReversalProcessed.additionalProperties.toMutableMap() + } + + /** + * The amount of the credit or reversal in the minor unit of its currency. + * For dollars, for example, this is cents. + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the + * credit or reversal's currency. + */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** + * Explanation for why the merchant believes the credit or reversal was + * processed. + */ + 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 date the credit or reversal was processed. */ + fun processedAt(processedAt: LocalDate) = + processedAt(JsonField.of(processedAt)) + + /** + * Sets [Builder.processedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.processedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun processedAt(processedAt: JsonField) = apply { + this.processedAt = processedAt + } + + 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 [CreditOrReversalProcessed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .explanation() + * .processedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditOrReversalProcessed = + CreditOrReversalProcessed( + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("explanation", explanation), + checkRequired("processedAt", processedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditOrReversalProcessed = apply { + if (validated) { + return@apply + } + + amount() + currency() + explanation() + processedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (processedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditOrReversalProcessed && + amount == other.amount && + currency == other.currency && + explanation == other.explanation && + processedAt == other.processedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + currency, + explanation, + processedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditOrReversalProcessed{amount=$amount, currency=$currency, explanation=$explanation, processedAt=$processedAt, additionalProperties=$additionalProperties}" + } + + /** + * Delayed charge transaction details. Present if and only if `reason` is + * `delayed_charge_transaction`. + */ + class DelayedChargeTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Additional details about the delayed charge transaction. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * 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 + + @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 + * [DelayedChargeTransaction]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DelayedChargeTransaction]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(delayedChargeTransaction: DelayedChargeTransaction) = + apply { + explanation = delayedChargeTransaction.explanation + additionalProperties = + delayedChargeTransaction.additionalProperties.toMutableMap() + } + + /** Additional details about the delayed charge transaction. */ + 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 + } + + 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 [DelayedChargeTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DelayedChargeTransaction = + DelayedChargeTransaction( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DelayedChargeTransaction = apply { + if (validated) { + return@apply + } + + explanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (explanation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DelayedChargeTransaction && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DelayedChargeTransaction{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + /** + * Evidence of imprint details. Present if and only if `reason` is + * `evidence_of_imprint`. + */ + class EvidenceOfImprint + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation of the evidence of imprint. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * 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 + + @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 + * [EvidenceOfImprint]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EvidenceOfImprint]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(evidenceOfImprint: EvidenceOfImprint) = apply { + explanation = evidenceOfImprint.explanation + additionalProperties = + evidenceOfImprint.additionalProperties.toMutableMap() + } + + /** Explanation of the evidence of imprint. */ + 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 + } + + 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 [EvidenceOfImprint]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EvidenceOfImprint = + EvidenceOfImprint( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EvidenceOfImprint = apply { + if (validated) { + return@apply + } + + explanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (explanation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EvidenceOfImprint && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EvidenceOfImprint{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + /** + * Invalid dispute details. Present if and only if `reason` is `invalid_dispute`. + */ + class InvalidDispute + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(explanation, reason, mutableMapOf()) + + /** + * Explanation for why the dispute is considered invalid by the merchant. + * + * @throws IncreaseInvalidDataException 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 reason a merchant considers the dispute invalid. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): Reason = reason.getRequired("reason") + + /** + * 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 [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @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 + * [InvalidDispute]. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvalidDispute]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(invalidDispute: InvalidDispute) = apply { + explanation = invalidDispute.explanation + reason = invalidDispute.reason + additionalProperties = + invalidDispute.additionalProperties.toMutableMap() + } + + /** + * Explanation for why the dispute is considered invalid by the merchant. + */ + 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 reason a merchant considers the dispute invalid. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [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 } + + 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 [InvalidDispute]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvalidDispute = + InvalidDispute( + checkRequired("explanation", explanation), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvalidDispute = apply { + if (validated) { + return@apply + } + + explanation() + reason().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** The reason a merchant considers the dispute invalid. */ + class Reason + @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 { + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Special authorization procedures followed. */ + @JvmField + val SPECIAL_AUTHORIZATION_PROCEDURES_FOLLOWED = + of("special_authorization_procedures_followed") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** Other. */ + OTHER, + /** Special authorization procedures followed. */ + SPECIAL_AUTHORIZATION_PROCEDURES_FOLLOWED, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Reason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Other. */ + OTHER, + /** Special authorization procedures followed. */ + SPECIAL_AUTHORIZATION_PROCEDURES_FOLLOWED, + /** + * An enum member indicating that [Reason] 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) { + OTHER -> Value.OTHER + SPECIAL_AUTHORIZATION_PROCEDURES_FOLLOWED -> + Value.SPECIAL_AUTHORIZATION_PROCEDURES_FOLLOWED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + OTHER -> Known.OTHER + SPECIAL_AUTHORIZATION_PROCEDURES_FOLLOWED -> + Known.SPECIAL_AUTHORIZATION_PROCEDURES_FOLLOWED + else -> throw IncreaseInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && 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 InvalidDispute && + explanation == other.explanation && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvalidDispute{explanation=$explanation, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Non-fiat currency or non-fungible token received details. Present if and only if + * `reason` is `non_fiat_currency_or_non_fungible_token_received`. + */ + class NonFiatCurrencyOrNonFungibleTokenReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val blockchainTransactionHash: JsonField, + private val destinationWalletAddress: JsonField, + private val priorApprovedTransactions: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("blockchain_transaction_hash") + @ExcludeMissing + blockchainTransactionHash: JsonField = JsonMissing.of(), + @JsonProperty("destination_wallet_address") + @ExcludeMissing + destinationWalletAddress: JsonField = JsonMissing.of(), + @JsonProperty("prior_approved_transactions") + @ExcludeMissing + priorApprovedTransactions: JsonField = JsonMissing.of(), + ) : this( + blockchainTransactionHash, + destinationWalletAddress, + priorApprovedTransactions, + mutableMapOf(), + ) + + /** + * Blockchain transaction hash. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockchainTransactionHash(): String = + blockchainTransactionHash.getRequired("blockchain_transaction_hash") + + /** + * Destination wallet address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun destinationWalletAddress(): String = + destinationWalletAddress.getRequired("destination_wallet_address") + + /** + * Prior approved transactions. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun priorApprovedTransactions(): Optional = + priorApprovedTransactions.getOptional("prior_approved_transactions") + + /** + * Returns the raw JSON value of [blockchainTransactionHash]. + * + * Unlike [blockchainTransactionHash], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("blockchain_transaction_hash") + @ExcludeMissing + fun _blockchainTransactionHash(): JsonField = blockchainTransactionHash + + /** + * Returns the raw JSON value of [destinationWalletAddress]. + * + * Unlike [destinationWalletAddress], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("destination_wallet_address") + @ExcludeMissing + fun _destinationWalletAddress(): JsonField = destinationWalletAddress + + /** + * Returns the raw JSON value of [priorApprovedTransactions]. + * + * Unlike [priorApprovedTransactions], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("prior_approved_transactions") + @ExcludeMissing + fun _priorApprovedTransactions(): JsonField = priorApprovedTransactions + + @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 + * [NonFiatCurrencyOrNonFungibleTokenReceived]. + * + * The following fields are required: + * ```java + * .blockchainTransactionHash() + * .destinationWalletAddress() + * .priorApprovedTransactions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NonFiatCurrencyOrNonFungibleTokenReceived]. */ + class Builder internal constructor() { + + private var blockchainTransactionHash: JsonField? = null + private var destinationWalletAddress: JsonField? = null + private var priorApprovedTransactions: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + nonFiatCurrencyOrNonFungibleTokenReceived: + NonFiatCurrencyOrNonFungibleTokenReceived + ) = apply { + blockchainTransactionHash = + nonFiatCurrencyOrNonFungibleTokenReceived.blockchainTransactionHash + destinationWalletAddress = + nonFiatCurrencyOrNonFungibleTokenReceived.destinationWalletAddress + priorApprovedTransactions = + nonFiatCurrencyOrNonFungibleTokenReceived.priorApprovedTransactions + additionalProperties = + nonFiatCurrencyOrNonFungibleTokenReceived.additionalProperties + .toMutableMap() + } + + /** Blockchain transaction hash. */ + fun blockchainTransactionHash(blockchainTransactionHash: String) = + blockchainTransactionHash(JsonField.of(blockchainTransactionHash)) + + /** + * Sets [Builder.blockchainTransactionHash] to an arbitrary JSON value. + * + * You should usually call [Builder.blockchainTransactionHash] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun blockchainTransactionHash( + blockchainTransactionHash: JsonField + ) = apply { this.blockchainTransactionHash = blockchainTransactionHash } + + /** Destination wallet address. */ + fun destinationWalletAddress(destinationWalletAddress: String) = + destinationWalletAddress(JsonField.of(destinationWalletAddress)) + + /** + * Sets [Builder.destinationWalletAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationWalletAddress] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun destinationWalletAddress(destinationWalletAddress: JsonField) = + apply { + this.destinationWalletAddress = destinationWalletAddress + } + + /** Prior approved transactions. */ + fun priorApprovedTransactions(priorApprovedTransactions: String?) = + priorApprovedTransactions( + JsonField.ofNullable(priorApprovedTransactions) + ) + + /** + * Alias for calling [Builder.priorApprovedTransactions] with + * `priorApprovedTransactions.orElse(null)`. + */ + fun priorApprovedTransactions(priorApprovedTransactions: Optional) = + priorApprovedTransactions(priorApprovedTransactions.getOrNull()) + + /** + * Sets [Builder.priorApprovedTransactions] to an arbitrary JSON value. + * + * You should usually call [Builder.priorApprovedTransactions] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun priorApprovedTransactions( + priorApprovedTransactions: JsonField + ) = apply { this.priorApprovedTransactions = priorApprovedTransactions } + + 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 + * [NonFiatCurrencyOrNonFungibleTokenReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .blockchainTransactionHash() + * .destinationWalletAddress() + * .priorApprovedTransactions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NonFiatCurrencyOrNonFungibleTokenReceived = + NonFiatCurrencyOrNonFungibleTokenReceived( + checkRequired( + "blockchainTransactionHash", + blockchainTransactionHash, + ), + checkRequired("destinationWalletAddress", destinationWalletAddress), + checkRequired( + "priorApprovedTransactions", + priorApprovedTransactions, + ), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NonFiatCurrencyOrNonFungibleTokenReceived = apply { + if (validated) { + return@apply + } + + blockchainTransactionHash() + destinationWalletAddress() + priorApprovedTransactions() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (blockchainTransactionHash.asKnown().isPresent) 1 else 0) + + (if (destinationWalletAddress.asKnown().isPresent) 1 else 0) + + (if (priorApprovedTransactions.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NonFiatCurrencyOrNonFungibleTokenReceived && + blockchainTransactionHash == other.blockchainTransactionHash && + destinationWalletAddress == other.destinationWalletAddress && + priorApprovedTransactions == other.priorApprovedTransactions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + blockchainTransactionHash, + destinationWalletAddress, + priorApprovedTransactions, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NonFiatCurrencyOrNonFungibleTokenReceived{blockchainTransactionHash=$blockchainTransactionHash, destinationWalletAddress=$destinationWalletAddress, priorApprovedTransactions=$priorApprovedTransactions, additionalProperties=$additionalProperties}" + } + + /** + * Prior undisputed non-fraud transactions details. Present if and only if `reason` + * is `prior_undisputed_non_fraud_transactions`. + */ + class PriorUndisputedNonFraudTransactions + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation of the prior undisputed non-fraud transactions provided by the + * merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * 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 + + @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 + * [PriorUndisputedNonFraudTransactions]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PriorUndisputedNonFraudTransactions]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + priorUndisputedNonFraudTransactions: PriorUndisputedNonFraudTransactions + ) = apply { + explanation = priorUndisputedNonFraudTransactions.explanation + additionalProperties = + priorUndisputedNonFraudTransactions.additionalProperties + .toMutableMap() + } + + /** + * Explanation of the prior undisputed non-fraud transactions provided by + * the merchant. + */ + 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 + } + + 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 [PriorUndisputedNonFraudTransactions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PriorUndisputedNonFraudTransactions = + PriorUndisputedNonFraudTransactions( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PriorUndisputedNonFraudTransactions = apply { + if (validated) { + return@apply + } + + explanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (explanation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriorUndisputedNonFraudTransactions && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PriorUndisputedNonFraudTransactions{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + /** The reason the merchant re-presented the dispute. */ + class Reason + @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 { + + /** Cardholder no longer disputes the transaction. */ + @JvmField + val CARDHOLDER_NO_LONGER_DISPUTES = of("cardholder_no_longer_disputes") + + /** Compelling evidence. */ + @JvmField val COMPELLING_EVIDENCE = of("compelling_evidence") + + /** Credit or reversal was processed. */ + @JvmField + val CREDIT_OR_REVERSAL_PROCESSED = of("credit_or_reversal_processed") + + /** Delayed charge transaction. */ + @JvmField val DELAYED_CHARGE_TRANSACTION = of("delayed_charge_transaction") + + /** Evidence of imprint. */ + @JvmField val EVIDENCE_OF_IMPRINT = of("evidence_of_imprint") + + /** Invalid dispute. */ + @JvmField val INVALID_DISPUTE = of("invalid_dispute") + + /** + * Non-fiat currency or non-fungible token was received by the cardholder. + */ + @JvmField + val NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED = + of("non_fiat_currency_or_non_fungible_token_received") + + /** Prior undisputed non-fraud transactions. */ + @JvmField + val PRIOR_UNDISPUTED_NON_FRAUD_TRANSACTIONS = + of("prior_undisputed_non_fraud_transactions") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** Cardholder no longer disputes the transaction. */ + CARDHOLDER_NO_LONGER_DISPUTES, + /** Compelling evidence. */ + COMPELLING_EVIDENCE, + /** Credit or reversal was processed. */ + CREDIT_OR_REVERSAL_PROCESSED, + /** Delayed charge transaction. */ + DELAYED_CHARGE_TRANSACTION, + /** Evidence of imprint. */ + EVIDENCE_OF_IMPRINT, + /** Invalid dispute. */ + INVALID_DISPUTE, + /** + * Non-fiat currency or non-fungible token was received by the cardholder. + */ + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED, + /** Prior undisputed non-fraud transactions. */ + PRIOR_UNDISPUTED_NON_FRAUD_TRANSACTIONS, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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 no longer disputes the transaction. */ + CARDHOLDER_NO_LONGER_DISPUTES, + /** Compelling evidence. */ + COMPELLING_EVIDENCE, + /** Credit or reversal was processed. */ + CREDIT_OR_REVERSAL_PROCESSED, + /** Delayed charge transaction. */ + DELAYED_CHARGE_TRANSACTION, + /** Evidence of imprint. */ + EVIDENCE_OF_IMPRINT, + /** Invalid dispute. */ + INVALID_DISPUTE, + /** + * Non-fiat currency or non-fungible token was received by the cardholder. + */ + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED, + /** Prior undisputed non-fraud transactions. */ + PRIOR_UNDISPUTED_NON_FRAUD_TRANSACTIONS, + /** + * An enum member indicating that [Reason] 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_NO_LONGER_DISPUTES -> Value.CARDHOLDER_NO_LONGER_DISPUTES + COMPELLING_EVIDENCE -> Value.COMPELLING_EVIDENCE + CREDIT_OR_REVERSAL_PROCESSED -> Value.CREDIT_OR_REVERSAL_PROCESSED + DELAYED_CHARGE_TRANSACTION -> Value.DELAYED_CHARGE_TRANSACTION + EVIDENCE_OF_IMPRINT -> Value.EVIDENCE_OF_IMPRINT + INVALID_DISPUTE -> Value.INVALID_DISPUTE + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED -> + Value.NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED + PRIOR_UNDISPUTED_NON_FRAUD_TRANSACTIONS -> + Value.PRIOR_UNDISPUTED_NON_FRAUD_TRANSACTIONS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_NO_LONGER_DISPUTES -> Known.CARDHOLDER_NO_LONGER_DISPUTES + COMPELLING_EVIDENCE -> Known.COMPELLING_EVIDENCE + CREDIT_OR_REVERSAL_PROCESSED -> Known.CREDIT_OR_REVERSAL_PROCESSED + DELAYED_CHARGE_TRANSACTION -> Known.DELAYED_CHARGE_TRANSACTION + EVIDENCE_OF_IMPRINT -> Known.EVIDENCE_OF_IMPRINT + INVALID_DISPUTE -> Known.INVALID_DISPUTE + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED -> + Known.NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED + PRIOR_UNDISPUTED_NON_FRAUD_TRANSACTIONS -> + Known.PRIOR_UNDISPUTED_NON_FRAUD_TRANSACTIONS + else -> throw IncreaseInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && 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 MerchantPrearbitrationReceived && + cardholderNoLongerDisputes == other.cardholderNoLongerDisputes && + compellingEvidence == other.compellingEvidence && + creditOrReversalProcessed == other.creditOrReversalProcessed && + delayedChargeTransaction == other.delayedChargeTransaction && + evidenceOfImprint == other.evidenceOfImprint && + invalidDispute == other.invalidDispute && + nonFiatCurrencyOrNonFungibleTokenReceived == + other.nonFiatCurrencyOrNonFungibleTokenReceived && + priorUndisputedNonFraudTransactions == + other.priorUndisputedNonFraudTransactions && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderNoLongerDisputes, + compellingEvidence, + creditOrReversalProcessed, + delayedChargeTransaction, + evidenceOfImprint, + invalidDispute, + nonFiatCurrencyOrNonFungibleTokenReceived, + priorUndisputedNonFraudTransactions, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantPrearbitrationReceived{cardholderNoLongerDisputes=$cardholderNoLongerDisputes, compellingEvidence=$compellingEvidence, creditOrReversalProcessed=$creditOrReversalProcessed, delayedChargeTransaction=$delayedChargeTransaction, evidenceOfImprint=$evidenceOfImprint, invalidDispute=$invalidDispute, nonFiatCurrencyOrNonFungibleTokenReceived=$nonFiatCurrencyOrNonFungibleTokenReceived, priorUndisputedNonFraudTransactions=$priorUndisputedNonFraudTransactions, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * A Card Dispute Re-presented Visa Network Event object. This field will be present in + * the JSON response if and only if `category` is equal to `represented`. Contains the + * details specific to a re-presented Visa Card Dispute Network Event, which represents + * that the merchant has declined the user's chargeback and has re-presented the + * payment. + */ + class Represented + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderNoLongerDisputes: JsonField, + private val creditOrReversalProcessed: JsonField, + private val invalidDispute: JsonField, + private val nonFiatCurrencyOrNonFungibleTokenAsDescribed: JsonValue, + private val nonFiatCurrencyOrNonFungibleTokenReceived: + JsonField, + private val proofOfCashDisbursement: JsonField, + private val reason: JsonField, + private val reversalIssued: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_no_longer_disputes") + @ExcludeMissing + cardholderNoLongerDisputes: JsonField = + JsonMissing.of(), + @JsonProperty("credit_or_reversal_processed") + @ExcludeMissing + creditOrReversalProcessed: JsonField = + JsonMissing.of(), + @JsonProperty("invalid_dispute") + @ExcludeMissing + invalidDispute: JsonField = JsonMissing.of(), + @JsonProperty("non_fiat_currency_or_non_fungible_token_as_described") + @ExcludeMissing + nonFiatCurrencyOrNonFungibleTokenAsDescribed: JsonValue = JsonMissing.of(), + @JsonProperty("non_fiat_currency_or_non_fungible_token_received") + @ExcludeMissing + nonFiatCurrencyOrNonFungibleTokenReceived: + JsonField = + JsonMissing.of(), + @JsonProperty("proof_of_cash_disbursement") + @ExcludeMissing + proofOfCashDisbursement: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("reversal_issued") + @ExcludeMissing + reversalIssued: JsonField = JsonMissing.of(), + ) : this( + cardholderNoLongerDisputes, + creditOrReversalProcessed, + invalidDispute, + nonFiatCurrencyOrNonFungibleTokenAsDescribed, + nonFiatCurrencyOrNonFungibleTokenReceived, + proofOfCashDisbursement, + reason, + reversalIssued, + mutableMapOf(), + ) + + /** + * Cardholder no longer disputes details. Present if and only if `reason` is + * `cardholder_no_longer_disputes`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderNoLongerDisputes(): Optional = + cardholderNoLongerDisputes.getOptional("cardholder_no_longer_disputes") + + /** + * Credit or reversal processed details. Present if and only if `reason` is + * `credit_or_reversal_processed`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun creditOrReversalProcessed(): Optional = + creditOrReversalProcessed.getOptional("credit_or_reversal_processed") + + /** + * Invalid dispute details. Present if and only if `reason` is `invalid_dispute`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun invalidDispute(): Optional = + invalidDispute.getOptional("invalid_dispute") + + /** + * Non-fiat currency or non-fungible token as described details. Present if and only + * if `reason` is `non_fiat_currency_or_non_fungible_token_as_described`. + */ + @JsonProperty("non_fiat_currency_or_non_fungible_token_as_described") + @ExcludeMissing + fun _nonFiatCurrencyOrNonFungibleTokenAsDescribed(): JsonValue = + nonFiatCurrencyOrNonFungibleTokenAsDescribed + + /** + * Non-fiat currency or non-fungible token received details. Present if and only if + * `reason` is `non_fiat_currency_or_non_fungible_token_received`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun nonFiatCurrencyOrNonFungibleTokenReceived(): + Optional = + nonFiatCurrencyOrNonFungibleTokenReceived.getOptional( + "non_fiat_currency_or_non_fungible_token_received" + ) + + /** + * Proof of cash disbursement details. Present if and only if `reason` is + * `proof_of_cash_disbursement`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun proofOfCashDisbursement(): Optional = + proofOfCashDisbursement.getOptional("proof_of_cash_disbursement") + + /** + * The reason the merchant re-presented the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): Reason = reason.getRequired("reason") + + /** + * Reversal issued by merchant details. Present if and only if `reason` is + * `reversal_issued`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reversalIssued(): Optional = + reversalIssued.getOptional("reversal_issued") + + /** + * Returns the raw JSON value of [cardholderNoLongerDisputes]. + * + * Unlike [cardholderNoLongerDisputes], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cardholder_no_longer_disputes") + @ExcludeMissing + fun _cardholderNoLongerDisputes(): JsonField = + cardholderNoLongerDisputes + + /** + * Returns the raw JSON value of [creditOrReversalProcessed]. + * + * Unlike [creditOrReversalProcessed], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("credit_or_reversal_processed") + @ExcludeMissing + fun _creditOrReversalProcessed(): JsonField = + creditOrReversalProcessed + + /** + * Returns the raw JSON value of [invalidDispute]. + * + * Unlike [invalidDispute], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("invalid_dispute") + @ExcludeMissing + fun _invalidDispute(): JsonField = invalidDispute + + /** + * Returns the raw JSON value of [nonFiatCurrencyOrNonFungibleTokenReceived]. + * + * Unlike [nonFiatCurrencyOrNonFungibleTokenReceived], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("non_fiat_currency_or_non_fungible_token_received") + @ExcludeMissing + fun _nonFiatCurrencyOrNonFungibleTokenReceived(): + JsonField = + nonFiatCurrencyOrNonFungibleTokenReceived + + /** + * Returns the raw JSON value of [proofOfCashDisbursement]. + * + * Unlike [proofOfCashDisbursement], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("proof_of_cash_disbursement") + @ExcludeMissing + fun _proofOfCashDisbursement(): JsonField = + proofOfCashDisbursement + + /** + * 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 [reversalIssued]. + * + * Unlike [reversalIssued], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reversal_issued") + @ExcludeMissing + fun _reversalIssued(): JsonField = reversalIssued + + @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 [Represented]. + * + * The following fields are required: + * ```java + * .cardholderNoLongerDisputes() + * .creditOrReversalProcessed() + * .invalidDispute() + * .nonFiatCurrencyOrNonFungibleTokenAsDescribed() + * .nonFiatCurrencyOrNonFungibleTokenReceived() + * .proofOfCashDisbursement() + * .reason() + * .reversalIssued() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Represented]. */ + class Builder internal constructor() { + + private var cardholderNoLongerDisputes: JsonField? = + null + private var creditOrReversalProcessed: JsonField? = + null + private var invalidDispute: JsonField? = null + private var nonFiatCurrencyOrNonFungibleTokenAsDescribed: JsonValue? = null + private var nonFiatCurrencyOrNonFungibleTokenReceived: + JsonField? = + null + private var proofOfCashDisbursement: JsonField? = null + private var reason: JsonField? = null + private var reversalIssued: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(represented: Represented) = apply { + cardholderNoLongerDisputes = represented.cardholderNoLongerDisputes + creditOrReversalProcessed = represented.creditOrReversalProcessed + invalidDispute = represented.invalidDispute + nonFiatCurrencyOrNonFungibleTokenAsDescribed = + represented.nonFiatCurrencyOrNonFungibleTokenAsDescribed + nonFiatCurrencyOrNonFungibleTokenReceived = + represented.nonFiatCurrencyOrNonFungibleTokenReceived + proofOfCashDisbursement = represented.proofOfCashDisbursement + reason = represented.reason + reversalIssued = represented.reversalIssued + additionalProperties = represented.additionalProperties.toMutableMap() + } + + /** + * Cardholder no longer disputes details. Present if and only if `reason` is + * `cardholder_no_longer_disputes`. + */ + fun cardholderNoLongerDisputes( + cardholderNoLongerDisputes: CardholderNoLongerDisputes? + ) = cardholderNoLongerDisputes(JsonField.ofNullable(cardholderNoLongerDisputes)) + + /** + * Alias for calling [Builder.cardholderNoLongerDisputes] with + * `cardholderNoLongerDisputes.orElse(null)`. + */ + fun cardholderNoLongerDisputes( + cardholderNoLongerDisputes: Optional + ) = cardholderNoLongerDisputes(cardholderNoLongerDisputes.getOrNull()) + + /** + * Sets [Builder.cardholderNoLongerDisputes] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderNoLongerDisputes] with a + * well-typed [CardholderNoLongerDisputes] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderNoLongerDisputes( + cardholderNoLongerDisputes: JsonField + ) = apply { this.cardholderNoLongerDisputes = cardholderNoLongerDisputes } + + /** + * Credit or reversal processed details. Present if and only if `reason` is + * `credit_or_reversal_processed`. + */ + fun creditOrReversalProcessed( + creditOrReversalProcessed: CreditOrReversalProcessed? + ) = creditOrReversalProcessed(JsonField.ofNullable(creditOrReversalProcessed)) + + /** + * Alias for calling [Builder.creditOrReversalProcessed] with + * `creditOrReversalProcessed.orElse(null)`. + */ + fun creditOrReversalProcessed( + creditOrReversalProcessed: Optional + ) = creditOrReversalProcessed(creditOrReversalProcessed.getOrNull()) + + /** + * Sets [Builder.creditOrReversalProcessed] to an arbitrary JSON value. + * + * You should usually call [Builder.creditOrReversalProcessed] with a well-typed + * [CreditOrReversalProcessed] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun creditOrReversalProcessed( + creditOrReversalProcessed: JsonField + ) = apply { this.creditOrReversalProcessed = creditOrReversalProcessed } + + /** + * Invalid dispute details. Present if and only if `reason` is + * `invalid_dispute`. + */ + fun invalidDispute(invalidDispute: InvalidDispute?) = + invalidDispute(JsonField.ofNullable(invalidDispute)) + + /** + * Alias for calling [Builder.invalidDispute] with + * `invalidDispute.orElse(null)`. + */ + fun invalidDispute(invalidDispute: Optional) = + invalidDispute(invalidDispute.getOrNull()) + + /** + * Sets [Builder.invalidDispute] to an arbitrary JSON value. + * + * You should usually call [Builder.invalidDispute] with a well-typed + * [InvalidDispute] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun invalidDispute(invalidDispute: JsonField) = apply { + this.invalidDispute = invalidDispute + } + + /** + * Non-fiat currency or non-fungible token as described details. Present if and + * only if `reason` is `non_fiat_currency_or_non_fungible_token_as_described`. + */ + fun nonFiatCurrencyOrNonFungibleTokenAsDescribed( + nonFiatCurrencyOrNonFungibleTokenAsDescribed: JsonValue + ) = apply { + this.nonFiatCurrencyOrNonFungibleTokenAsDescribed = + nonFiatCurrencyOrNonFungibleTokenAsDescribed + } + + /** + * Non-fiat currency or non-fungible token received details. Present if and only + * if `reason` is `non_fiat_currency_or_non_fungible_token_received`. + */ + fun nonFiatCurrencyOrNonFungibleTokenReceived( + nonFiatCurrencyOrNonFungibleTokenReceived: + NonFiatCurrencyOrNonFungibleTokenReceived? + ) = + nonFiatCurrencyOrNonFungibleTokenReceived( + JsonField.ofNullable(nonFiatCurrencyOrNonFungibleTokenReceived) + ) + + /** + * Alias for calling [Builder.nonFiatCurrencyOrNonFungibleTokenReceived] with + * `nonFiatCurrencyOrNonFungibleTokenReceived.orElse(null)`. + */ + fun nonFiatCurrencyOrNonFungibleTokenReceived( + nonFiatCurrencyOrNonFungibleTokenReceived: + Optional + ) = + nonFiatCurrencyOrNonFungibleTokenReceived( + nonFiatCurrencyOrNonFungibleTokenReceived.getOrNull() + ) + + /** + * Sets [Builder.nonFiatCurrencyOrNonFungibleTokenReceived] to an arbitrary JSON + * value. + * + * You should usually call [Builder.nonFiatCurrencyOrNonFungibleTokenReceived] + * with a well-typed [NonFiatCurrencyOrNonFungibleTokenReceived] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun nonFiatCurrencyOrNonFungibleTokenReceived( + nonFiatCurrencyOrNonFungibleTokenReceived: + JsonField + ) = apply { + this.nonFiatCurrencyOrNonFungibleTokenReceived = + nonFiatCurrencyOrNonFungibleTokenReceived + } + + /** + * Proof of cash disbursement details. Present if and only if `reason` is + * `proof_of_cash_disbursement`. + */ + fun proofOfCashDisbursement(proofOfCashDisbursement: ProofOfCashDisbursement?) = + proofOfCashDisbursement(JsonField.ofNullable(proofOfCashDisbursement)) + + /** + * Alias for calling [Builder.proofOfCashDisbursement] with + * `proofOfCashDisbursement.orElse(null)`. + */ + fun proofOfCashDisbursement( + proofOfCashDisbursement: Optional + ) = proofOfCashDisbursement(proofOfCashDisbursement.getOrNull()) + + /** + * Sets [Builder.proofOfCashDisbursement] to an arbitrary JSON value. + * + * You should usually call [Builder.proofOfCashDisbursement] with a well-typed + * [ProofOfCashDisbursement] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun proofOfCashDisbursement( + proofOfCashDisbursement: JsonField + ) = apply { this.proofOfCashDisbursement = proofOfCashDisbursement } + + /** The reason the merchant re-presented the dispute. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [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 } + + /** + * Reversal issued by merchant details. Present if and only if `reason` is + * `reversal_issued`. + */ + fun reversalIssued(reversalIssued: ReversalIssued?) = + reversalIssued(JsonField.ofNullable(reversalIssued)) + + /** + * Alias for calling [Builder.reversalIssued] with + * `reversalIssued.orElse(null)`. + */ + fun reversalIssued(reversalIssued: Optional) = + reversalIssued(reversalIssued.getOrNull()) + + /** + * Sets [Builder.reversalIssued] to an arbitrary JSON value. + * + * You should usually call [Builder.reversalIssued] with a well-typed + * [ReversalIssued] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun reversalIssued(reversalIssued: JsonField) = apply { + this.reversalIssued = reversalIssued + } + + 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 [Represented]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderNoLongerDisputes() + * .creditOrReversalProcessed() + * .invalidDispute() + * .nonFiatCurrencyOrNonFungibleTokenAsDescribed() + * .nonFiatCurrencyOrNonFungibleTokenReceived() + * .proofOfCashDisbursement() + * .reason() + * .reversalIssued() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Represented = + Represented( + checkRequired("cardholderNoLongerDisputes", cardholderNoLongerDisputes), + checkRequired("creditOrReversalProcessed", creditOrReversalProcessed), + checkRequired("invalidDispute", invalidDispute), + checkRequired( + "nonFiatCurrencyOrNonFungibleTokenAsDescribed", + nonFiatCurrencyOrNonFungibleTokenAsDescribed, + ), + checkRequired( + "nonFiatCurrencyOrNonFungibleTokenReceived", + nonFiatCurrencyOrNonFungibleTokenReceived, + ), + checkRequired("proofOfCashDisbursement", proofOfCashDisbursement), + checkRequired("reason", reason), + checkRequired("reversalIssued", reversalIssued), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Represented = apply { + if (validated) { + return@apply + } + + cardholderNoLongerDisputes().ifPresent { it.validate() } + creditOrReversalProcessed().ifPresent { it.validate() } + invalidDispute().ifPresent { it.validate() } + nonFiatCurrencyOrNonFungibleTokenReceived().ifPresent { it.validate() } + proofOfCashDisbursement().ifPresent { it.validate() } + reason().validate() + reversalIssued().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderNoLongerDisputes.asKnown().getOrNull()?.validity() ?: 0) + + (creditOrReversalProcessed.asKnown().getOrNull()?.validity() ?: 0) + + (invalidDispute.asKnown().getOrNull()?.validity() ?: 0) + + (nonFiatCurrencyOrNonFungibleTokenReceived.asKnown().getOrNull()?.validity() + ?: 0) + + (proofOfCashDisbursement.asKnown().getOrNull()?.validity() ?: 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + (reversalIssued.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Cardholder no longer disputes details. Present if and only if `reason` is + * `cardholder_no_longer_disputes`. + */ + class CardholderNoLongerDisputes + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation for why the merchant believes the cardholder no longer disputes + * the transaction. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * 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 + + @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 + * [CardholderNoLongerDisputes]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderNoLongerDisputes]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderNoLongerDisputes: CardholderNoLongerDisputes) = + apply { + explanation = cardholderNoLongerDisputes.explanation + additionalProperties = + cardholderNoLongerDisputes.additionalProperties.toMutableMap() + } + + /** + * Explanation for why the merchant believes the cardholder no longer + * disputes the transaction. + */ + 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 + } + + 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 [CardholderNoLongerDisputes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderNoLongerDisputes = + CardholderNoLongerDisputes( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderNoLongerDisputes = apply { + if (validated) { + return@apply + } + + explanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (explanation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderNoLongerDisputes && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderNoLongerDisputes{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + /** + * Credit or reversal processed details. Present if and only if `reason` is + * `credit_or_reversal_processed`. + */ + class CreditOrReversalProcessed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val explanation: JsonField, + private val processedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("processed_at") + @ExcludeMissing + processedAt: JsonField = JsonMissing.of(), + ) : this(amount, currency, explanation, processedAt, mutableMapOf()) + + /** + * The amount of the credit or reversal in the minor unit of its currency. For + * dollars, for example, this is cents. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun amount(): Long = amount.getRequired("amount") + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the credit or + * reversal's currency. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Explanation for why the merchant believes the credit or reversal was + * processed. + * + * @throws IncreaseInvalidDataException 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 date the credit or reversal was processed. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun processedAt(): LocalDate = processedAt.getRequired("processed_at") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * 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 [processedAt]. + * + * Unlike [processedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("processed_at") + @ExcludeMissing + fun _processedAt(): JsonField = processedAt + + @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 + * [CreditOrReversalProcessed]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .explanation() + * .processedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditOrReversalProcessed]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var explanation: JsonField? = null + private var processedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(creditOrReversalProcessed: CreditOrReversalProcessed) = + apply { + amount = creditOrReversalProcessed.amount + currency = creditOrReversalProcessed.currency + explanation = creditOrReversalProcessed.explanation + processedAt = creditOrReversalProcessed.processedAt + additionalProperties = + creditOrReversalProcessed.additionalProperties.toMutableMap() + } + + /** + * The amount of the credit or reversal in the minor unit of its currency. + * For dollars, for example, this is cents. + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) code for the + * credit or reversal's currency. + */ + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun currency(currency: JsonField) = apply { + this.currency = currency + } + + /** + * Explanation for why the merchant believes the credit or reversal was + * processed. + */ + 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 date the credit or reversal was processed. */ + fun processedAt(processedAt: LocalDate) = + processedAt(JsonField.of(processedAt)) + + /** + * Sets [Builder.processedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.processedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun processedAt(processedAt: JsonField) = apply { + this.processedAt = processedAt + } + + 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 [CreditOrReversalProcessed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .explanation() + * .processedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreditOrReversalProcessed = + CreditOrReversalProcessed( + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("explanation", explanation), + checkRequired("processedAt", processedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditOrReversalProcessed = apply { + if (validated) { + return@apply + } + + amount() + currency() + explanation() + processedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (processedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditOrReversalProcessed && + amount == other.amount && + currency == other.currency && + explanation == other.explanation && + processedAt == other.processedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + currency, + explanation, + processedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditOrReversalProcessed{amount=$amount, currency=$currency, explanation=$explanation, processedAt=$processedAt, additionalProperties=$additionalProperties}" + } + + /** + * Invalid dispute details. Present if and only if `reason` is `invalid_dispute`. + */ + class InvalidDispute + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(explanation, reason, mutableMapOf()) + + /** + * Explanation for why the dispute is considered invalid by the merchant. + * + * @throws IncreaseInvalidDataException 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 reason a merchant considers the dispute invalid. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): Reason = reason.getRequired("reason") + + /** + * 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 [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @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 + * [InvalidDispute]. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InvalidDispute]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(invalidDispute: InvalidDispute) = apply { + explanation = invalidDispute.explanation + reason = invalidDispute.reason + additionalProperties = + invalidDispute.additionalProperties.toMutableMap() + } + + /** + * Explanation for why the dispute is considered invalid by the merchant. + */ + 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 reason a merchant considers the dispute invalid. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [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 } + + 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 [InvalidDispute]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InvalidDispute = + InvalidDispute( + checkRequired("explanation", explanation), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InvalidDispute = apply { + if (validated) { + return@apply + } + + explanation() + reason().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** The reason a merchant considers the dispute invalid. */ + class Reason + @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 { + + /** Automatic Teller Machine (ATM) transaction proof provided. */ + @JvmField + val AUTOMATIC_TELLER_MACHINE_TRANSACTION_PROOF_PROVIDED = + of("automatic_teller_machine_transaction_proof_provided") + + /** Balance of partial prepayment not paid. */ + @JvmField + val BALANCE_OF_PARTIAL_PREPAYMENT_NOT_PAID = + of("balance_of_partial_prepayment_not_paid") + + /** + * Cardholder canceled before expected receipt date of the merchandise. + */ + @JvmField + val CARDHOLDER_CANCELED_BEFORE_EXPECTED_MERCHANDISE_RECEIPT_DATE = + of("cardholder_canceled_before_expected_merchandise_receipt_date") + + /** Cardholder canceled before expected receipt date of the services. */ + @JvmField + val CARDHOLDER_CANCELED_BEFORE_EXPECTED_SERVICES_RECEIPT_DATE = + of("cardholder_canceled_before_expected_services_receipt_date") + + /** Cardholder canceled on a different date than claimed. */ + @JvmField + val CARDHOLDER_CANCELED_DIFFERENT_DATE = + of("cardholder_canceled_different_date") + + /** Cardholder received did not cancel according to policy. */ + @JvmField + val CARDHOLDER_DID_NOT_CANCEL_ACCORDING_TO_POLICY = + of("cardholder_did_not_cancel_according_to_policy") + + /** Cardholder received the merchandise. */ + @JvmField + val CARDHOLDER_RECEIVED_MERCHANDISE = + of("cardholder_received_merchandise") + + /** Country code is correct. */ + @JvmField val COUNTRY_CODE_CORRECT = of("country_code_correct") + + /** Credit was processed correctly. */ + @JvmField + val CREDIT_PROCESSED_CORRECTLY = of("credit_processed_correctly") + + /** Currency is correct. */ + @JvmField val CURRENCY_CORRECT = of("currency_correct") + + /** Dispute is for quality. */ + @JvmField val DISPUTE_IS_FOR_QUALITY = of("dispute_is_for_quality") + + /** Dispute is for Visa Cash Back transaction portion. */ + @JvmField + val DISPUTE_IS_FOR_VISA_CASH_BACK_TRANSACTION_PORTION = + of("dispute_is_for_visa_cash_back_transaction_portion") + + /** Disputed amount is Value Added Tax (VAT). */ + @JvmField + val DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX = + of("disputed_amount_is_value_added_tax") + + /** + * Disputed amount is Value Added Tax (VAT) but no credit receipt was + * provided by the cardholder. + */ + @JvmField + val DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX_NO_CREDIT_RECEIPT_PROVIDED = + of("disputed_amount_is_value_added_tax_no_credit_receipt_provided") + + /** Limited return or cancellation policy was properly disclosed. */ + @JvmField + val LIMITED_RETURN_OR_CANCELLATION_POLICY_PROPERLY_DISCLOSED = + of("limited_return_or_cancellation_policy_properly_disclosed") + + /** Merchandise held at cardholder customs agency. */ + @JvmField + val MERCHANDISE_HELD_AT_CARDHOLDER_CUSTOMS_AGENCY = + of("merchandise_held_at_cardholder_customs_agency") + + /** Merchandise matches the merchant's description. */ + @JvmField + val MERCHANDISE_MATCHES_DESCRIPTION = + of("merchandise_matches_description") + + /** Merchandise is not counterfeit. */ + @JvmField + val MERCHANDISE_NOT_COUNTERFEIT = of("merchandise_not_counterfeit") + + /** Merchandise is not damaged. */ + @JvmField val MERCHANDISE_NOT_DAMAGED = of("merchandise_not_damaged") + + /** Merchandise is not defective. */ + @JvmField + val MERCHANDISE_NOT_DEFECTIVE = of("merchandise_not_defective") + + /** Merchandise was provided prior to the cancellation date. */ + @JvmField + val MERCHANDISE_PROVIDED_PRIOR_TO_CANCELLATION_DATE = + of("merchandise_provided_prior_to_cancellation_date") + + /** Merchandise quality matches the merchant's description. */ + @JvmField + val MERCHANDISE_QUALITY_MATCHES_DESCRIPTION = + of("merchandise_quality_matches_description") + + /** Merchandise was not attempted returned to the merchant. */ + @JvmField + val MERCHANDISE_RETURN_NOT_ATTEMPTED = + of("merchandise_return_not_attempted") + + /** Merchant was not notified of the closed account. */ + @JvmField + val MERCHANT_NOT_NOTIFIED_OF_CLOSED_ACCOUNT = + of("merchant_not_notified_of_closed_account") + + /** + * Name on manifest of departed flight matches name on purchased + * itinerary. + */ + @JvmField + val NAME_ON_FLIGHT_MANIFEST_MATCHES_PURCHASE = + of("name_on_flight_manifest_matches_purchase") + + /** No credit receipt was provided by the cardholder. */ + @JvmField + val NO_CREDIT_RECEIPT_PROVIDED = of("no_credit_receipt_provided") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** The claimed processing error did not occur. */ + @JvmField + val PROCESSING_ERROR_INCORRECT = of("processing_error_incorrect") + + /** + * Returned merchandise held at customs agency outside the merchant's + * country. + */ + @JvmField + val RETURNED_MECHANDISE_HELD_AT_CUSTOMS_AGENCY_OUTSIDE_MERCHANT_COUNTRY = + of( + "returned_mechandise_held_at_customs_agency_outside_merchant_country" + ) + + /** Services match the merchant's description. */ + @JvmField + val SERVICES_MATCH_DESCRIPTION = of("services_match_description") + + /** Services were provided prior to the cancellation date. */ + @JvmField + val SERVICES_PROVIDED_PRIOR_TO_CANCELLATION_DATE = + of("services_provided_prior_to_cancellation_date") + + /** + * Services were used after the cancellation date and prior to the + * dispute submission date. + */ + @JvmField + val SERVICES_USED_AFTER_CANCELLATION_DATE = + of("services_used_after_cancellation_date") + + /** Terms of service were not misrepresented. */ + @JvmField + val TERMS_OF_SERVICE_NOT_MISREPRESENTED = + of("terms_of_service_not_misrepresented") + + /** Transaction code is correct. */ + @JvmField val TRANSACTION_CODE_CORRECT = of("transaction_code_correct") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** Automatic Teller Machine (ATM) transaction proof provided. */ + AUTOMATIC_TELLER_MACHINE_TRANSACTION_PROOF_PROVIDED, + /** Balance of partial prepayment not paid. */ + BALANCE_OF_PARTIAL_PREPAYMENT_NOT_PAID, + /** + * Cardholder canceled before expected receipt date of the merchandise. + */ + CARDHOLDER_CANCELED_BEFORE_EXPECTED_MERCHANDISE_RECEIPT_DATE, + /** Cardholder canceled before expected receipt date of the services. */ + CARDHOLDER_CANCELED_BEFORE_EXPECTED_SERVICES_RECEIPT_DATE, + /** Cardholder canceled on a different date than claimed. */ + CARDHOLDER_CANCELED_DIFFERENT_DATE, + /** Cardholder received did not cancel according to policy. */ + CARDHOLDER_DID_NOT_CANCEL_ACCORDING_TO_POLICY, + /** Cardholder received the merchandise. */ + CARDHOLDER_RECEIVED_MERCHANDISE, + /** Country code is correct. */ + COUNTRY_CODE_CORRECT, + /** Credit was processed correctly. */ + CREDIT_PROCESSED_CORRECTLY, + /** Currency is correct. */ + CURRENCY_CORRECT, + /** Dispute is for quality. */ + DISPUTE_IS_FOR_QUALITY, + /** Dispute is for Visa Cash Back transaction portion. */ + DISPUTE_IS_FOR_VISA_CASH_BACK_TRANSACTION_PORTION, + /** Disputed amount is Value Added Tax (VAT). */ + DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX, + /** + * Disputed amount is Value Added Tax (VAT) but no credit receipt was + * provided by the cardholder. + */ + DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX_NO_CREDIT_RECEIPT_PROVIDED, + /** Limited return or cancellation policy was properly disclosed. */ + LIMITED_RETURN_OR_CANCELLATION_POLICY_PROPERLY_DISCLOSED, + /** Merchandise held at cardholder customs agency. */ + MERCHANDISE_HELD_AT_CARDHOLDER_CUSTOMS_AGENCY, + /** Merchandise matches the merchant's description. */ + MERCHANDISE_MATCHES_DESCRIPTION, + /** Merchandise is not counterfeit. */ + MERCHANDISE_NOT_COUNTERFEIT, + /** Merchandise is not damaged. */ + MERCHANDISE_NOT_DAMAGED, + /** Merchandise is not defective. */ + MERCHANDISE_NOT_DEFECTIVE, + /** Merchandise was provided prior to the cancellation date. */ + MERCHANDISE_PROVIDED_PRIOR_TO_CANCELLATION_DATE, + /** Merchandise quality matches the merchant's description. */ + MERCHANDISE_QUALITY_MATCHES_DESCRIPTION, + /** Merchandise was not attempted returned to the merchant. */ + MERCHANDISE_RETURN_NOT_ATTEMPTED, + /** Merchant was not notified of the closed account. */ + MERCHANT_NOT_NOTIFIED_OF_CLOSED_ACCOUNT, + /** + * Name on manifest of departed flight matches name on purchased + * itinerary. + */ + NAME_ON_FLIGHT_MANIFEST_MATCHES_PURCHASE, + /** No credit receipt was provided by the cardholder. */ + NO_CREDIT_RECEIPT_PROVIDED, + /** Other. */ + OTHER, + /** The claimed processing error did not occur. */ + PROCESSING_ERROR_INCORRECT, + /** + * Returned merchandise held at customs agency outside the merchant's + * country. + */ + RETURNED_MECHANDISE_HELD_AT_CUSTOMS_AGENCY_OUTSIDE_MERCHANT_COUNTRY, + /** Services match the merchant's description. */ + SERVICES_MATCH_DESCRIPTION, + /** Services were provided prior to the cancellation date. */ + SERVICES_PROVIDED_PRIOR_TO_CANCELLATION_DATE, + /** + * Services were used after the cancellation date and prior to the + * dispute submission date. + */ + SERVICES_USED_AFTER_CANCELLATION_DATE, + /** Terms of service were not misrepresented. */ + TERMS_OF_SERVICE_NOT_MISREPRESENTED, + /** Transaction code is correct. */ + TRANSACTION_CODE_CORRECT, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Reason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Automatic Teller Machine (ATM) transaction proof provided. */ + AUTOMATIC_TELLER_MACHINE_TRANSACTION_PROOF_PROVIDED, + /** Balance of partial prepayment not paid. */ + BALANCE_OF_PARTIAL_PREPAYMENT_NOT_PAID, + /** + * Cardholder canceled before expected receipt date of the merchandise. + */ + CARDHOLDER_CANCELED_BEFORE_EXPECTED_MERCHANDISE_RECEIPT_DATE, + /** Cardholder canceled before expected receipt date of the services. */ + CARDHOLDER_CANCELED_BEFORE_EXPECTED_SERVICES_RECEIPT_DATE, + /** Cardholder canceled on a different date than claimed. */ + CARDHOLDER_CANCELED_DIFFERENT_DATE, + /** Cardholder received did not cancel according to policy. */ + CARDHOLDER_DID_NOT_CANCEL_ACCORDING_TO_POLICY, + /** Cardholder received the merchandise. */ + CARDHOLDER_RECEIVED_MERCHANDISE, + /** Country code is correct. */ + COUNTRY_CODE_CORRECT, + /** Credit was processed correctly. */ + CREDIT_PROCESSED_CORRECTLY, + /** Currency is correct. */ + CURRENCY_CORRECT, + /** Dispute is for quality. */ + DISPUTE_IS_FOR_QUALITY, + /** Dispute is for Visa Cash Back transaction portion. */ + DISPUTE_IS_FOR_VISA_CASH_BACK_TRANSACTION_PORTION, + /** Disputed amount is Value Added Tax (VAT). */ + DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX, + /** + * Disputed amount is Value Added Tax (VAT) but no credit receipt was + * provided by the cardholder. + */ + DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX_NO_CREDIT_RECEIPT_PROVIDED, + /** Limited return or cancellation policy was properly disclosed. */ + LIMITED_RETURN_OR_CANCELLATION_POLICY_PROPERLY_DISCLOSED, + /** Merchandise held at cardholder customs agency. */ + MERCHANDISE_HELD_AT_CARDHOLDER_CUSTOMS_AGENCY, + /** Merchandise matches the merchant's description. */ + MERCHANDISE_MATCHES_DESCRIPTION, + /** Merchandise is not counterfeit. */ + MERCHANDISE_NOT_COUNTERFEIT, + /** Merchandise is not damaged. */ + MERCHANDISE_NOT_DAMAGED, + /** Merchandise is not defective. */ + MERCHANDISE_NOT_DEFECTIVE, + /** Merchandise was provided prior to the cancellation date. */ + MERCHANDISE_PROVIDED_PRIOR_TO_CANCELLATION_DATE, + /** Merchandise quality matches the merchant's description. */ + MERCHANDISE_QUALITY_MATCHES_DESCRIPTION, + /** Merchandise was not attempted returned to the merchant. */ + MERCHANDISE_RETURN_NOT_ATTEMPTED, + /** Merchant was not notified of the closed account. */ + MERCHANT_NOT_NOTIFIED_OF_CLOSED_ACCOUNT, + /** + * Name on manifest of departed flight matches name on purchased + * itinerary. + */ + NAME_ON_FLIGHT_MANIFEST_MATCHES_PURCHASE, + /** No credit receipt was provided by the cardholder. */ + NO_CREDIT_RECEIPT_PROVIDED, + /** Other. */ + OTHER, + /** The claimed processing error did not occur. */ + PROCESSING_ERROR_INCORRECT, + /** + * Returned merchandise held at customs agency outside the merchant's + * country. + */ + RETURNED_MECHANDISE_HELD_AT_CUSTOMS_AGENCY_OUTSIDE_MERCHANT_COUNTRY, + /** Services match the merchant's description. */ + SERVICES_MATCH_DESCRIPTION, + /** Services were provided prior to the cancellation date. */ + SERVICES_PROVIDED_PRIOR_TO_CANCELLATION_DATE, + /** + * Services were used after the cancellation date and prior to the + * dispute submission date. + */ + SERVICES_USED_AFTER_CANCELLATION_DATE, + /** Terms of service were not misrepresented. */ + TERMS_OF_SERVICE_NOT_MISREPRESENTED, + /** Transaction code is correct. */ + TRANSACTION_CODE_CORRECT, + /** + * An enum member indicating that [Reason] 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) { + AUTOMATIC_TELLER_MACHINE_TRANSACTION_PROOF_PROVIDED -> + Value.AUTOMATIC_TELLER_MACHINE_TRANSACTION_PROOF_PROVIDED + BALANCE_OF_PARTIAL_PREPAYMENT_NOT_PAID -> + Value.BALANCE_OF_PARTIAL_PREPAYMENT_NOT_PAID + CARDHOLDER_CANCELED_BEFORE_EXPECTED_MERCHANDISE_RECEIPT_DATE -> + Value + .CARDHOLDER_CANCELED_BEFORE_EXPECTED_MERCHANDISE_RECEIPT_DATE + CARDHOLDER_CANCELED_BEFORE_EXPECTED_SERVICES_RECEIPT_DATE -> + Value.CARDHOLDER_CANCELED_BEFORE_EXPECTED_SERVICES_RECEIPT_DATE + CARDHOLDER_CANCELED_DIFFERENT_DATE -> + Value.CARDHOLDER_CANCELED_DIFFERENT_DATE + CARDHOLDER_DID_NOT_CANCEL_ACCORDING_TO_POLICY -> + Value.CARDHOLDER_DID_NOT_CANCEL_ACCORDING_TO_POLICY + CARDHOLDER_RECEIVED_MERCHANDISE -> + Value.CARDHOLDER_RECEIVED_MERCHANDISE + COUNTRY_CODE_CORRECT -> Value.COUNTRY_CODE_CORRECT + CREDIT_PROCESSED_CORRECTLY -> Value.CREDIT_PROCESSED_CORRECTLY + CURRENCY_CORRECT -> Value.CURRENCY_CORRECT + DISPUTE_IS_FOR_QUALITY -> Value.DISPUTE_IS_FOR_QUALITY + DISPUTE_IS_FOR_VISA_CASH_BACK_TRANSACTION_PORTION -> + Value.DISPUTE_IS_FOR_VISA_CASH_BACK_TRANSACTION_PORTION + DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX -> + Value.DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX + DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX_NO_CREDIT_RECEIPT_PROVIDED -> + Value + .DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX_NO_CREDIT_RECEIPT_PROVIDED + LIMITED_RETURN_OR_CANCELLATION_POLICY_PROPERLY_DISCLOSED -> + Value.LIMITED_RETURN_OR_CANCELLATION_POLICY_PROPERLY_DISCLOSED + MERCHANDISE_HELD_AT_CARDHOLDER_CUSTOMS_AGENCY -> + Value.MERCHANDISE_HELD_AT_CARDHOLDER_CUSTOMS_AGENCY + MERCHANDISE_MATCHES_DESCRIPTION -> + Value.MERCHANDISE_MATCHES_DESCRIPTION + MERCHANDISE_NOT_COUNTERFEIT -> Value.MERCHANDISE_NOT_COUNTERFEIT + MERCHANDISE_NOT_DAMAGED -> Value.MERCHANDISE_NOT_DAMAGED + MERCHANDISE_NOT_DEFECTIVE -> Value.MERCHANDISE_NOT_DEFECTIVE + MERCHANDISE_PROVIDED_PRIOR_TO_CANCELLATION_DATE -> + Value.MERCHANDISE_PROVIDED_PRIOR_TO_CANCELLATION_DATE + MERCHANDISE_QUALITY_MATCHES_DESCRIPTION -> + Value.MERCHANDISE_QUALITY_MATCHES_DESCRIPTION + MERCHANDISE_RETURN_NOT_ATTEMPTED -> + Value.MERCHANDISE_RETURN_NOT_ATTEMPTED + MERCHANT_NOT_NOTIFIED_OF_CLOSED_ACCOUNT -> + Value.MERCHANT_NOT_NOTIFIED_OF_CLOSED_ACCOUNT + NAME_ON_FLIGHT_MANIFEST_MATCHES_PURCHASE -> + Value.NAME_ON_FLIGHT_MANIFEST_MATCHES_PURCHASE + NO_CREDIT_RECEIPT_PROVIDED -> Value.NO_CREDIT_RECEIPT_PROVIDED + OTHER -> Value.OTHER + PROCESSING_ERROR_INCORRECT -> Value.PROCESSING_ERROR_INCORRECT + RETURNED_MECHANDISE_HELD_AT_CUSTOMS_AGENCY_OUTSIDE_MERCHANT_COUNTRY -> + Value + .RETURNED_MECHANDISE_HELD_AT_CUSTOMS_AGENCY_OUTSIDE_MERCHANT_COUNTRY + SERVICES_MATCH_DESCRIPTION -> Value.SERVICES_MATCH_DESCRIPTION + SERVICES_PROVIDED_PRIOR_TO_CANCELLATION_DATE -> + Value.SERVICES_PROVIDED_PRIOR_TO_CANCELLATION_DATE + SERVICES_USED_AFTER_CANCELLATION_DATE -> + Value.SERVICES_USED_AFTER_CANCELLATION_DATE + TERMS_OF_SERVICE_NOT_MISREPRESENTED -> + Value.TERMS_OF_SERVICE_NOT_MISREPRESENTED + TRANSACTION_CODE_CORRECT -> Value.TRANSACTION_CODE_CORRECT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + AUTOMATIC_TELLER_MACHINE_TRANSACTION_PROOF_PROVIDED -> + Known.AUTOMATIC_TELLER_MACHINE_TRANSACTION_PROOF_PROVIDED + BALANCE_OF_PARTIAL_PREPAYMENT_NOT_PAID -> + Known.BALANCE_OF_PARTIAL_PREPAYMENT_NOT_PAID + CARDHOLDER_CANCELED_BEFORE_EXPECTED_MERCHANDISE_RECEIPT_DATE -> + Known + .CARDHOLDER_CANCELED_BEFORE_EXPECTED_MERCHANDISE_RECEIPT_DATE + CARDHOLDER_CANCELED_BEFORE_EXPECTED_SERVICES_RECEIPT_DATE -> + Known.CARDHOLDER_CANCELED_BEFORE_EXPECTED_SERVICES_RECEIPT_DATE + CARDHOLDER_CANCELED_DIFFERENT_DATE -> + Known.CARDHOLDER_CANCELED_DIFFERENT_DATE + CARDHOLDER_DID_NOT_CANCEL_ACCORDING_TO_POLICY -> + Known.CARDHOLDER_DID_NOT_CANCEL_ACCORDING_TO_POLICY + CARDHOLDER_RECEIVED_MERCHANDISE -> + Known.CARDHOLDER_RECEIVED_MERCHANDISE + COUNTRY_CODE_CORRECT -> Known.COUNTRY_CODE_CORRECT + CREDIT_PROCESSED_CORRECTLY -> Known.CREDIT_PROCESSED_CORRECTLY + CURRENCY_CORRECT -> Known.CURRENCY_CORRECT + DISPUTE_IS_FOR_QUALITY -> Known.DISPUTE_IS_FOR_QUALITY + DISPUTE_IS_FOR_VISA_CASH_BACK_TRANSACTION_PORTION -> + Known.DISPUTE_IS_FOR_VISA_CASH_BACK_TRANSACTION_PORTION + DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX -> + Known.DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX + DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX_NO_CREDIT_RECEIPT_PROVIDED -> + Known + .DISPUTED_AMOUNT_IS_VALUE_ADDED_TAX_NO_CREDIT_RECEIPT_PROVIDED + LIMITED_RETURN_OR_CANCELLATION_POLICY_PROPERLY_DISCLOSED -> + Known.LIMITED_RETURN_OR_CANCELLATION_POLICY_PROPERLY_DISCLOSED + MERCHANDISE_HELD_AT_CARDHOLDER_CUSTOMS_AGENCY -> + Known.MERCHANDISE_HELD_AT_CARDHOLDER_CUSTOMS_AGENCY + MERCHANDISE_MATCHES_DESCRIPTION -> + Known.MERCHANDISE_MATCHES_DESCRIPTION + MERCHANDISE_NOT_COUNTERFEIT -> Known.MERCHANDISE_NOT_COUNTERFEIT + MERCHANDISE_NOT_DAMAGED -> Known.MERCHANDISE_NOT_DAMAGED + MERCHANDISE_NOT_DEFECTIVE -> Known.MERCHANDISE_NOT_DEFECTIVE + MERCHANDISE_PROVIDED_PRIOR_TO_CANCELLATION_DATE -> + Known.MERCHANDISE_PROVIDED_PRIOR_TO_CANCELLATION_DATE + MERCHANDISE_QUALITY_MATCHES_DESCRIPTION -> + Known.MERCHANDISE_QUALITY_MATCHES_DESCRIPTION + MERCHANDISE_RETURN_NOT_ATTEMPTED -> + Known.MERCHANDISE_RETURN_NOT_ATTEMPTED + MERCHANT_NOT_NOTIFIED_OF_CLOSED_ACCOUNT -> + Known.MERCHANT_NOT_NOTIFIED_OF_CLOSED_ACCOUNT + NAME_ON_FLIGHT_MANIFEST_MATCHES_PURCHASE -> + Known.NAME_ON_FLIGHT_MANIFEST_MATCHES_PURCHASE + NO_CREDIT_RECEIPT_PROVIDED -> Known.NO_CREDIT_RECEIPT_PROVIDED + OTHER -> Known.OTHER + PROCESSING_ERROR_INCORRECT -> Known.PROCESSING_ERROR_INCORRECT + RETURNED_MECHANDISE_HELD_AT_CUSTOMS_AGENCY_OUTSIDE_MERCHANT_COUNTRY -> + Known + .RETURNED_MECHANDISE_HELD_AT_CUSTOMS_AGENCY_OUTSIDE_MERCHANT_COUNTRY + SERVICES_MATCH_DESCRIPTION -> Known.SERVICES_MATCH_DESCRIPTION + SERVICES_PROVIDED_PRIOR_TO_CANCELLATION_DATE -> + Known.SERVICES_PROVIDED_PRIOR_TO_CANCELLATION_DATE + SERVICES_USED_AFTER_CANCELLATION_DATE -> + Known.SERVICES_USED_AFTER_CANCELLATION_DATE + TERMS_OF_SERVICE_NOT_MISREPRESENTED -> + Known.TERMS_OF_SERVICE_NOT_MISREPRESENTED + TRANSACTION_CODE_CORRECT -> Known.TRANSACTION_CODE_CORRECT + else -> throw IncreaseInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && 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 InvalidDispute && + explanation == other.explanation && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InvalidDispute{explanation=$explanation, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Non-fiat currency or non-fungible token received details. Present if and only if + * `reason` is `non_fiat_currency_or_non_fungible_token_received`. + */ + class NonFiatCurrencyOrNonFungibleTokenReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val blockchainTransactionHash: JsonField, + private val destinationWalletAddress: JsonField, + private val priorApprovedTransactions: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("blockchain_transaction_hash") + @ExcludeMissing + blockchainTransactionHash: JsonField = JsonMissing.of(), + @JsonProperty("destination_wallet_address") + @ExcludeMissing + destinationWalletAddress: JsonField = JsonMissing.of(), + @JsonProperty("prior_approved_transactions") + @ExcludeMissing + priorApprovedTransactions: JsonField = JsonMissing.of(), + ) : this( + blockchainTransactionHash, + destinationWalletAddress, + priorApprovedTransactions, + mutableMapOf(), + ) + + /** + * Blockchain transaction hash. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun blockchainTransactionHash(): String = + blockchainTransactionHash.getRequired("blockchain_transaction_hash") + + /** + * Destination wallet address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun destinationWalletAddress(): String = + destinationWalletAddress.getRequired("destination_wallet_address") + + /** + * Prior approved transactions. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun priorApprovedTransactions(): Optional = + priorApprovedTransactions.getOptional("prior_approved_transactions") + + /** + * Returns the raw JSON value of [blockchainTransactionHash]. + * + * Unlike [blockchainTransactionHash], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("blockchain_transaction_hash") + @ExcludeMissing + fun _blockchainTransactionHash(): JsonField = blockchainTransactionHash + + /** + * Returns the raw JSON value of [destinationWalletAddress]. + * + * Unlike [destinationWalletAddress], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("destination_wallet_address") + @ExcludeMissing + fun _destinationWalletAddress(): JsonField = destinationWalletAddress + + /** + * Returns the raw JSON value of [priorApprovedTransactions]. + * + * Unlike [priorApprovedTransactions], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("prior_approved_transactions") + @ExcludeMissing + fun _priorApprovedTransactions(): JsonField = priorApprovedTransactions + + @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 + * [NonFiatCurrencyOrNonFungibleTokenReceived]. + * + * The following fields are required: + * ```java + * .blockchainTransactionHash() + * .destinationWalletAddress() + * .priorApprovedTransactions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NonFiatCurrencyOrNonFungibleTokenReceived]. */ + class Builder internal constructor() { + + private var blockchainTransactionHash: JsonField? = null + private var destinationWalletAddress: JsonField? = null + private var priorApprovedTransactions: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + nonFiatCurrencyOrNonFungibleTokenReceived: + NonFiatCurrencyOrNonFungibleTokenReceived + ) = apply { + blockchainTransactionHash = + nonFiatCurrencyOrNonFungibleTokenReceived.blockchainTransactionHash + destinationWalletAddress = + nonFiatCurrencyOrNonFungibleTokenReceived.destinationWalletAddress + priorApprovedTransactions = + nonFiatCurrencyOrNonFungibleTokenReceived.priorApprovedTransactions + additionalProperties = + nonFiatCurrencyOrNonFungibleTokenReceived.additionalProperties + .toMutableMap() + } + + /** Blockchain transaction hash. */ + fun blockchainTransactionHash(blockchainTransactionHash: String) = + blockchainTransactionHash(JsonField.of(blockchainTransactionHash)) + + /** + * Sets [Builder.blockchainTransactionHash] to an arbitrary JSON value. + * + * You should usually call [Builder.blockchainTransactionHash] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun blockchainTransactionHash( + blockchainTransactionHash: JsonField + ) = apply { this.blockchainTransactionHash = blockchainTransactionHash } + + /** Destination wallet address. */ + fun destinationWalletAddress(destinationWalletAddress: String) = + destinationWalletAddress(JsonField.of(destinationWalletAddress)) + + /** + * Sets [Builder.destinationWalletAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.destinationWalletAddress] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun destinationWalletAddress(destinationWalletAddress: JsonField) = + apply { + this.destinationWalletAddress = destinationWalletAddress + } + + /** Prior approved transactions. */ + fun priorApprovedTransactions(priorApprovedTransactions: String?) = + priorApprovedTransactions( + JsonField.ofNullable(priorApprovedTransactions) + ) + + /** + * Alias for calling [Builder.priorApprovedTransactions] with + * `priorApprovedTransactions.orElse(null)`. + */ + fun priorApprovedTransactions(priorApprovedTransactions: Optional) = + priorApprovedTransactions(priorApprovedTransactions.getOrNull()) + + /** + * Sets [Builder.priorApprovedTransactions] to an arbitrary JSON value. + * + * You should usually call [Builder.priorApprovedTransactions] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun priorApprovedTransactions( + priorApprovedTransactions: JsonField + ) = apply { this.priorApprovedTransactions = priorApprovedTransactions } + + 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 + * [NonFiatCurrencyOrNonFungibleTokenReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .blockchainTransactionHash() + * .destinationWalletAddress() + * .priorApprovedTransactions() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NonFiatCurrencyOrNonFungibleTokenReceived = + NonFiatCurrencyOrNonFungibleTokenReceived( + checkRequired( + "blockchainTransactionHash", + blockchainTransactionHash, + ), + checkRequired("destinationWalletAddress", destinationWalletAddress), + checkRequired( + "priorApprovedTransactions", + priorApprovedTransactions, + ), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NonFiatCurrencyOrNonFungibleTokenReceived = apply { + if (validated) { + return@apply + } + + blockchainTransactionHash() + destinationWalletAddress() + priorApprovedTransactions() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (blockchainTransactionHash.asKnown().isPresent) 1 else 0) + + (if (destinationWalletAddress.asKnown().isPresent) 1 else 0) + + (if (priorApprovedTransactions.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NonFiatCurrencyOrNonFungibleTokenReceived && + blockchainTransactionHash == other.blockchainTransactionHash && + destinationWalletAddress == other.destinationWalletAddress && + priorApprovedTransactions == other.priorApprovedTransactions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + blockchainTransactionHash, + destinationWalletAddress, + priorApprovedTransactions, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NonFiatCurrencyOrNonFungibleTokenReceived{blockchainTransactionHash=$blockchainTransactionHash, destinationWalletAddress=$destinationWalletAddress, priorApprovedTransactions=$priorApprovedTransactions, additionalProperties=$additionalProperties}" + } + + /** + * Proof of cash disbursement details. Present if and only if `reason` is + * `proof_of_cash_disbursement`. + */ + class ProofOfCashDisbursement + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation for why the merchant believes the evidence provides proof of cash + * disbursement. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * 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 + + @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 + * [ProofOfCashDisbursement]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProofOfCashDisbursement]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(proofOfCashDisbursement: ProofOfCashDisbursement) = + apply { + explanation = proofOfCashDisbursement.explanation + additionalProperties = + proofOfCashDisbursement.additionalProperties.toMutableMap() + } + + /** + * Explanation for why the merchant believes the evidence provides proof of + * cash disbursement. + */ + 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 + } + + 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 [ProofOfCashDisbursement]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProofOfCashDisbursement = + ProofOfCashDisbursement( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProofOfCashDisbursement = apply { + if (validated) { + return@apply + } + + explanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (explanation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProofOfCashDisbursement && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProofOfCashDisbursement{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + /** The reason the merchant re-presented the dispute. */ + class Reason + @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 { + + /** Cardholder no longer disputes the transaction. */ + @JvmField + val CARDHOLDER_NO_LONGER_DISPUTES = of("cardholder_no_longer_disputes") + + /** Credit or reversal was processed. */ + @JvmField + val CREDIT_OR_REVERSAL_PROCESSED = of("credit_or_reversal_processed") + + /** Invalid dispute. */ + @JvmField val INVALID_DISPUTE = of("invalid_dispute") + + /** + * Non-fiat currency or non-fungible token is as described by the merchant. + */ + @JvmField + val NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_AS_DESCRIBED = + of("non_fiat_currency_or_non_fungible_token_as_described") + + /** + * Non-fiat currency or non-fungible token was received by the cardholder. + */ + @JvmField + val NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED = + of("non_fiat_currency_or_non_fungible_token_received") + + /** Proof of cash disbursement provided. */ + @JvmField val PROOF_OF_CASH_DISBURSEMENT = of("proof_of_cash_disbursement") + + /** Reversal issued by merchant. */ + @JvmField val REVERSAL_ISSUED = of("reversal_issued") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** Cardholder no longer disputes the transaction. */ + CARDHOLDER_NO_LONGER_DISPUTES, + /** Credit or reversal was processed. */ + CREDIT_OR_REVERSAL_PROCESSED, + /** Invalid dispute. */ + INVALID_DISPUTE, + /** + * Non-fiat currency or non-fungible token is as described by the merchant. + */ + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_AS_DESCRIBED, + /** + * Non-fiat currency or non-fungible token was received by the cardholder. + */ + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED, + /** Proof of cash disbursement provided. */ + PROOF_OF_CASH_DISBURSEMENT, + /** Reversal issued by merchant. */ + REVERSAL_ISSUED, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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 no longer disputes the transaction. */ + CARDHOLDER_NO_LONGER_DISPUTES, + /** Credit or reversal was processed. */ + CREDIT_OR_REVERSAL_PROCESSED, + /** Invalid dispute. */ + INVALID_DISPUTE, + /** + * Non-fiat currency or non-fungible token is as described by the merchant. + */ + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_AS_DESCRIBED, + /** + * Non-fiat currency or non-fungible token was received by the cardholder. + */ + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED, + /** Proof of cash disbursement provided. */ + PROOF_OF_CASH_DISBURSEMENT, + /** Reversal issued by merchant. */ + REVERSAL_ISSUED, + /** + * An enum member indicating that [Reason] 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_NO_LONGER_DISPUTES -> Value.CARDHOLDER_NO_LONGER_DISPUTES + CREDIT_OR_REVERSAL_PROCESSED -> Value.CREDIT_OR_REVERSAL_PROCESSED + INVALID_DISPUTE -> Value.INVALID_DISPUTE + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_AS_DESCRIBED -> + Value.NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_AS_DESCRIBED + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED -> + Value.NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED + PROOF_OF_CASH_DISBURSEMENT -> Value.PROOF_OF_CASH_DISBURSEMENT + REVERSAL_ISSUED -> Value.REVERSAL_ISSUED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_NO_LONGER_DISPUTES -> Known.CARDHOLDER_NO_LONGER_DISPUTES + CREDIT_OR_REVERSAL_PROCESSED -> Known.CREDIT_OR_REVERSAL_PROCESSED + INVALID_DISPUTE -> Known.INVALID_DISPUTE + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_AS_DESCRIBED -> + Known.NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_AS_DESCRIBED + NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED -> + Known.NON_FIAT_CURRENCY_OR_NON_FUNGIBLE_TOKEN_RECEIVED + PROOF_OF_CASH_DISBURSEMENT -> Known.PROOF_OF_CASH_DISBURSEMENT + REVERSAL_ISSUED -> Known.REVERSAL_ISSUED + else -> throw IncreaseInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Reversal issued by merchant details. Present if and only if `reason` is + * `reversal_issued`. + */ + class ReversalIssued + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation of the reversal issued by the merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * 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 + + @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 + * [ReversalIssued]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReversalIssued]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(reversalIssued: ReversalIssued) = apply { + explanation = reversalIssued.explanation + additionalProperties = + reversalIssued.additionalProperties.toMutableMap() + } + + /** Explanation of the reversal issued by the merchant. */ + 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 + } + + 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 [ReversalIssued]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReversalIssued = + ReversalIssued( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReversalIssued = apply { + if (validated) { + return@apply + } + + explanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (explanation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReversalIssued && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReversalIssued{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Represented && + cardholderNoLongerDisputes == other.cardholderNoLongerDisputes && + creditOrReversalProcessed == other.creditOrReversalProcessed && + invalidDispute == other.invalidDispute && + nonFiatCurrencyOrNonFungibleTokenAsDescribed == + other.nonFiatCurrencyOrNonFungibleTokenAsDescribed && + nonFiatCurrencyOrNonFungibleTokenReceived == + other.nonFiatCurrencyOrNonFungibleTokenReceived && + proofOfCashDisbursement == other.proofOfCashDisbursement && + reason == other.reason && + reversalIssued == other.reversalIssued && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderNoLongerDisputes, + creditOrReversalProcessed, + invalidDispute, + nonFiatCurrencyOrNonFungibleTokenAsDescribed, + nonFiatCurrencyOrNonFungibleTokenReceived, + proofOfCashDisbursement, + reason, + reversalIssued, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Represented{cardholderNoLongerDisputes=$cardholderNoLongerDisputes, creditOrReversalProcessed=$creditOrReversalProcessed, invalidDispute=$invalidDispute, nonFiatCurrencyOrNonFungibleTokenAsDescribed=$nonFiatCurrencyOrNonFungibleTokenAsDescribed, nonFiatCurrencyOrNonFungibleTokenReceived=$nonFiatCurrencyOrNonFungibleTokenReceived, proofOfCashDisbursement=$proofOfCashDisbursement, reason=$reason, reversalIssued=$reversalIssued, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NetworkEvent && + attachmentFiles == other.attachmentFiles && + category == other.category && + chargebackAccepted == other.chargebackAccepted && + chargebackSubmitted == other.chargebackSubmitted && + chargebackTimedOut == other.chargebackTimedOut && + createdAt == other.createdAt && + disputeFinancialTransactionId == other.disputeFinancialTransactionId && + merchantPrearbitrationDeclineSubmitted == + other.merchantPrearbitrationDeclineSubmitted && + merchantPrearbitrationReceived == other.merchantPrearbitrationReceived && + merchantPrearbitrationTimedOut == other.merchantPrearbitrationTimedOut && + represented == other.represented && + representmentTimedOut == other.representmentTimedOut && + userPrearbitrationAccepted == other.userPrearbitrationAccepted && + userPrearbitrationDeclined == other.userPrearbitrationDeclined && + userPrearbitrationSubmitted == other.userPrearbitrationSubmitted && + userPrearbitrationTimedOut == other.userPrearbitrationTimedOut && + userWithdrawalSubmitted == other.userWithdrawalSubmitted && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attachmentFiles, + category, + chargebackAccepted, + chargebackSubmitted, + chargebackTimedOut, + createdAt, + disputeFinancialTransactionId, + merchantPrearbitrationDeclineSubmitted, + merchantPrearbitrationReceived, + merchantPrearbitrationTimedOut, + represented, + representmentTimedOut, + userPrearbitrationAccepted, + userPrearbitrationDeclined, + userPrearbitrationSubmitted, + userPrearbitrationTimedOut, + userWithdrawalSubmitted, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NetworkEvent{attachmentFiles=$attachmentFiles, category=$category, chargebackAccepted=$chargebackAccepted, chargebackSubmitted=$chargebackSubmitted, chargebackTimedOut=$chargebackTimedOut, createdAt=$createdAt, disputeFinancialTransactionId=$disputeFinancialTransactionId, merchantPrearbitrationDeclineSubmitted=$merchantPrearbitrationDeclineSubmitted, merchantPrearbitrationReceived=$merchantPrearbitrationReceived, merchantPrearbitrationTimedOut=$merchantPrearbitrationTimedOut, represented=$represented, representmentTimedOut=$representmentTimedOut, userPrearbitrationAccepted=$userPrearbitrationAccepted, userPrearbitrationDeclined=$userPrearbitrationDeclined, userPrearbitrationSubmitted=$userPrearbitrationSubmitted, userPrearbitrationTimedOut=$userPrearbitrationTimedOut, userWithdrawalSubmitted=$userWithdrawalSubmitted, additionalProperties=$additionalProperties}" + } + + /** + * The category of the currently required user submission if the user wishes to proceed with + * the dispute. Present if and only if status is `user_submission_required`. Otherwise, this + * will be `nil`. + */ + class RequiredUserSubmissionCategory + @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 { + + /** A Chargeback User Submission is required. */ + @JvmField val CHARGEBACK = of("chargeback") + + /** A Merchant Pre Arbitration Decline User Submission is required. */ + @JvmField + val MERCHANT_PREARBITRATION_DECLINE = of("merchant_prearbitration_decline") + + /** A User Initiated Pre Arbitration User Submission is required. */ + @JvmField val USER_PREARBITRATION = of("user_prearbitration") + + @JvmStatic + fun of(value: String) = RequiredUserSubmissionCategory(JsonField.of(value)) + } + + /** An enum containing [RequiredUserSubmissionCategory]'s known values. */ + enum class Known { + /** A Chargeback User Submission is required. */ + CHARGEBACK, + /** A Merchant Pre Arbitration Decline User Submission is required. */ + MERCHANT_PREARBITRATION_DECLINE, + /** A User Initiated Pre Arbitration User Submission is required. */ + USER_PREARBITRATION, + } + + /** + * An enum containing [RequiredUserSubmissionCategory]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RequiredUserSubmissionCategory] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** A Chargeback User Submission is required. */ + CHARGEBACK, + /** A Merchant Pre Arbitration Decline User Submission is required. */ + MERCHANT_PREARBITRATION_DECLINE, + /** A User Initiated Pre Arbitration User Submission is required. */ + USER_PREARBITRATION, + /** + * An enum member indicating that [RequiredUserSubmissionCategory] 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) { + CHARGEBACK -> Value.CHARGEBACK + MERCHANT_PREARBITRATION_DECLINE -> Value.MERCHANT_PREARBITRATION_DECLINE + USER_PREARBITRATION -> Value.USER_PREARBITRATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHARGEBACK -> Known.CHARGEBACK + MERCHANT_PREARBITRATION_DECLINE -> Known.MERCHANT_PREARBITRATION_DECLINE + USER_PREARBITRATION -> Known.USER_PREARBITRATION + else -> + throw IncreaseInvalidDataException( + "Unknown RequiredUserSubmissionCategory: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RequiredUserSubmissionCategory = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RequiredUserSubmissionCategory && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class UserSubmission + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedAt: JsonField, + private val amount: JsonField, + private val attachmentFiles: JsonField>, + private val category: JsonField, + private val chargeback: JsonField, + private val createdAt: JsonField, + private val furtherInformationRequestedAt: JsonField, + private val furtherInformationRequestedReason: JsonField, + private val merchantPrearbitrationDecline: JsonField, + private val status: JsonField, + private val updatedAt: JsonField, + private val userPrearbitration: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_at") + @ExcludeMissing + acceptedAt: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attachment_files") + @ExcludeMissing + attachmentFiles: JsonField> = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("chargeback") + @ExcludeMissing + chargeback: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("further_information_requested_at") + @ExcludeMissing + furtherInformationRequestedAt: JsonField = JsonMissing.of(), + @JsonProperty("further_information_requested_reason") + @ExcludeMissing + furtherInformationRequestedReason: JsonField = JsonMissing.of(), + @JsonProperty("merchant_prearbitration_decline") + @ExcludeMissing + merchantPrearbitrationDecline: JsonField = + JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("user_prearbitration") + @ExcludeMissing + userPrearbitration: JsonField = JsonMissing.of(), + ) : this( + acceptedAt, + amount, + attachmentFiles, + category, + chargeback, + createdAt, + furtherInformationRequestedAt, + furtherInformationRequestedReason, + merchantPrearbitrationDecline, + status, + updatedAt, + userPrearbitration, + mutableMapOf(), + ) + + /** + * The date and time at which the Visa Card Dispute User Submission was reviewed and + * accepted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun acceptedAt(): Optional = acceptedAt.getOptional("accepted_at") + + /** + * The amount of the dispute if it is different from the amount of a prior user + * submission or the disputed transaction. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The files attached to the Visa Card Dispute User Submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun attachmentFiles(): List = + attachmentFiles.getRequired("attachment_files") + + /** + * The category of the user submission. We may add additional possible values for this + * enum over time; your application should be able to handle such additions gracefully. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun category(): Category = category.getRequired("category") + + /** + * A Visa Card Dispute Chargeback User Submission Chargeback Details object. This field + * will be present in the JSON response if and only if `category` is equal to + * `chargeback`. Contains the details specific to a Visa chargeback User Submission for + * a Card Dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun chargeback(): Optional = chargeback.getOptional("chargeback") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Visa Card Dispute User Submission was created. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + + /** + * The date and time at which Increase requested further information from the user for + * the Visa Card Dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun furtherInformationRequestedAt(): Optional = + furtherInformationRequestedAt.getOptional("further_information_requested_at") + + /** + * The reason for Increase requesting further information from the user for the Visa + * Card Dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun furtherInformationRequestedReason(): Optional = + furtherInformationRequestedReason.getOptional( + "further_information_requested_reason" + ) + + /** + * A Visa Card Dispute Merchant Pre-Arbitration Decline User Submission object. This + * field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_decline`. Contains the details specific to a merchant + * prearbitration decline Visa Card Dispute User Submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun merchantPrearbitrationDecline(): Optional = + merchantPrearbitrationDecline.getOptional("merchant_prearbitration_decline") + + /** + * The status of the Visa Card Dispute User Submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun status(): Status = status.getRequired("status") + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Visa Card Dispute User Submission was updated. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun updatedAt(): OffsetDateTime = updatedAt.getRequired("updated_at") + + /** + * A Visa Card Dispute User-Initiated Pre-Arbitration User Submission object. This field + * will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration`. Contains the details specific to a user-initiated + * pre-arbitration Visa Card Dispute User Submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun userPrearbitration(): Optional = + userPrearbitration.getOptional("user_prearbitration") + + /** + * Returns the raw JSON value of [acceptedAt]. + * + * Unlike [acceptedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("accepted_at") + @ExcludeMissing + fun _acceptedAt(): JsonField = acceptedAt + + /** + * 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 [attachmentFiles]. + * + * Unlike [attachmentFiles], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attachment_files") + @ExcludeMissing + fun _attachmentFiles(): JsonField> = attachmentFiles + + /** + * 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 [chargeback]. + * + * Unlike [chargeback], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("chargeback") + @ExcludeMissing + fun _chargeback(): JsonField = chargeback + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [furtherInformationRequestedAt]. + * + * Unlike [furtherInformationRequestedAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("further_information_requested_at") + @ExcludeMissing + fun _furtherInformationRequestedAt(): JsonField = + furtherInformationRequestedAt + + /** + * Returns the raw JSON value of [furtherInformationRequestedReason]. + * + * Unlike [furtherInformationRequestedReason], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("further_information_requested_reason") + @ExcludeMissing + fun _furtherInformationRequestedReason(): JsonField = + furtherInformationRequestedReason + + /** + * Returns the raw JSON value of [merchantPrearbitrationDecline]. + * + * Unlike [merchantPrearbitrationDecline], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_prearbitration_decline") + @ExcludeMissing + fun _merchantPrearbitrationDecline(): JsonField = + merchantPrearbitrationDecline + + /** + * 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 [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [userPrearbitration]. + * + * Unlike [userPrearbitration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("user_prearbitration") + @ExcludeMissing + fun _userPrearbitration(): JsonField = userPrearbitration + + @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 [UserSubmission]. + * + * The following fields are required: + * ```java + * .acceptedAt() + * .amount() + * .attachmentFiles() + * .category() + * .chargeback() + * .createdAt() + * .furtherInformationRequestedAt() + * .furtherInformationRequestedReason() + * .merchantPrearbitrationDecline() + * .status() + * .updatedAt() + * .userPrearbitration() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserSubmission]. */ + class Builder internal constructor() { + + private var acceptedAt: JsonField? = null + private var amount: JsonField? = null + private var attachmentFiles: JsonField>? = null + private var category: JsonField? = null + private var chargeback: JsonField? = null + private var createdAt: JsonField? = null + private var furtherInformationRequestedAt: JsonField? = null + private var furtherInformationRequestedReason: JsonField? = null + private var merchantPrearbitrationDecline: + JsonField? = + null + private var status: JsonField? = null + private var updatedAt: JsonField? = null + private var userPrearbitration: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userSubmission: UserSubmission) = apply { + acceptedAt = userSubmission.acceptedAt + amount = userSubmission.amount + attachmentFiles = userSubmission.attachmentFiles.map { it.toMutableList() } + category = userSubmission.category + chargeback = userSubmission.chargeback + createdAt = userSubmission.createdAt + furtherInformationRequestedAt = userSubmission.furtherInformationRequestedAt + furtherInformationRequestedReason = + userSubmission.furtherInformationRequestedReason + merchantPrearbitrationDecline = userSubmission.merchantPrearbitrationDecline + status = userSubmission.status + updatedAt = userSubmission.updatedAt + userPrearbitration = userSubmission.userPrearbitration + additionalProperties = userSubmission.additionalProperties.toMutableMap() + } + + /** + * The date and time at which the Visa Card Dispute User Submission was reviewed and + * accepted. + */ + fun acceptedAt(acceptedAt: OffsetDateTime?) = + acceptedAt(JsonField.ofNullable(acceptedAt)) + + /** Alias for calling [Builder.acceptedAt] with `acceptedAt.orElse(null)`. */ + fun acceptedAt(acceptedAt: Optional) = + acceptedAt(acceptedAt.getOrNull()) + + /** + * Sets [Builder.acceptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun acceptedAt(acceptedAt: JsonField) = apply { + this.acceptedAt = acceptedAt + } + + /** + * The amount of the dispute if it is different from the amount of a prior user + * submission or the disputed transaction. + */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The files attached to the Visa Card Dispute User Submission. */ + fun attachmentFiles(attachmentFiles: List) = + attachmentFiles(JsonField.of(attachmentFiles)) + + /** + * Sets [Builder.attachmentFiles] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentFiles] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attachmentFiles(attachmentFiles: JsonField>) = apply { + this.attachmentFiles = attachmentFiles.map { it.toMutableList() } + } + + /** + * Adds a single [AttachmentFile] to [attachmentFiles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAttachmentFile(attachmentFile: AttachmentFile) = apply { + attachmentFiles = + (attachmentFiles ?: JsonField.of(mutableListOf())).also { + checkKnown("attachmentFiles", it).add(attachmentFile) + } + } + + /** + * The category of the user submission. We may add additional possible values for + * this enum over time; your application should be able to handle such additions + * gracefully. + */ + 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 } + + /** + * A Visa Card Dispute Chargeback User Submission Chargeback Details object. This + * field will be present in the JSON response if and only if `category` is equal to + * `chargeback`. Contains the details specific to a Visa chargeback User Submission + * for a Card Dispute. + */ + fun chargeback(chargeback: Chargeback?) = + chargeback(JsonField.ofNullable(chargeback)) + + /** Alias for calling [Builder.chargeback] with `chargeback.orElse(null)`. */ + fun chargeback(chargeback: Optional) = + chargeback(chargeback.getOrNull()) + + /** + * Sets [Builder.chargeback] to an arbitrary JSON value. + * + * You should usually call [Builder.chargeback] with a well-typed [Chargeback] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun chargeback(chargeback: JsonField) = apply { + this.chargeback = chargeback + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Visa Card Dispute User Submission was created. + */ + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun createdAt(createdAt: JsonField) = apply { + this.createdAt = createdAt + } + + /** + * The date and time at which Increase requested further information from the user + * for the Visa Card Dispute. + */ + fun furtherInformationRequestedAt(furtherInformationRequestedAt: OffsetDateTime?) = + furtherInformationRequestedAt( + JsonField.ofNullable(furtherInformationRequestedAt) + ) + + /** + * Alias for calling [Builder.furtherInformationRequestedAt] with + * `furtherInformationRequestedAt.orElse(null)`. + */ + fun furtherInformationRequestedAt( + furtherInformationRequestedAt: Optional + ) = furtherInformationRequestedAt(furtherInformationRequestedAt.getOrNull()) + + /** + * Sets [Builder.furtherInformationRequestedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.furtherInformationRequestedAt] with a well-typed + * [OffsetDateTime] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun furtherInformationRequestedAt( + furtherInformationRequestedAt: JsonField + ) = apply { this.furtherInformationRequestedAt = furtherInformationRequestedAt } + + /** + * The reason for Increase requesting further information from the user for the Visa + * Card Dispute. + */ + fun furtherInformationRequestedReason(furtherInformationRequestedReason: String?) = + furtherInformationRequestedReason( + JsonField.ofNullable(furtherInformationRequestedReason) + ) + + /** + * Alias for calling [Builder.furtherInformationRequestedReason] with + * `furtherInformationRequestedReason.orElse(null)`. + */ + fun furtherInformationRequestedReason( + furtherInformationRequestedReason: Optional + ) = furtherInformationRequestedReason(furtherInformationRequestedReason.getOrNull()) + + /** + * Sets [Builder.furtherInformationRequestedReason] to an arbitrary JSON value. + * + * You should usually call [Builder.furtherInformationRequestedReason] with a + * well-typed [String] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun furtherInformationRequestedReason( + furtherInformationRequestedReason: JsonField + ) = apply { + this.furtherInformationRequestedReason = furtherInformationRequestedReason + } + + /** + * A Visa Card Dispute Merchant Pre-Arbitration Decline User Submission object. This + * field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_decline`. Contains the details specific to a merchant + * prearbitration decline Visa Card Dispute User Submission. + */ + fun merchantPrearbitrationDecline( + merchantPrearbitrationDecline: MerchantPrearbitrationDecline? + ) = + merchantPrearbitrationDecline( + JsonField.ofNullable(merchantPrearbitrationDecline) + ) + + /** + * Alias for calling [Builder.merchantPrearbitrationDecline] with + * `merchantPrearbitrationDecline.orElse(null)`. + */ + fun merchantPrearbitrationDecline( + merchantPrearbitrationDecline: Optional + ) = merchantPrearbitrationDecline(merchantPrearbitrationDecline.getOrNull()) + + /** + * Sets [Builder.merchantPrearbitrationDecline] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPrearbitrationDecline] with a well-typed + * [MerchantPrearbitrationDecline] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantPrearbitrationDecline( + merchantPrearbitrationDecline: JsonField + ) = apply { this.merchantPrearbitrationDecline = merchantPrearbitrationDecline } + + /** The status of the Visa Card Dispute User Submission. */ + 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 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Visa Card Dispute User Submission was updated. + */ + fun updatedAt(updatedAt: OffsetDateTime) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { + this.updatedAt = updatedAt + } + + /** + * A Visa Card Dispute User-Initiated Pre-Arbitration User Submission object. This + * field will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration`. Contains the details specific to a user-initiated + * pre-arbitration Visa Card Dispute User Submission. + */ + fun userPrearbitration(userPrearbitration: UserPrearbitration?) = + userPrearbitration(JsonField.ofNullable(userPrearbitration)) + + /** + * Alias for calling [Builder.userPrearbitration] with + * `userPrearbitration.orElse(null)`. + */ + fun userPrearbitration(userPrearbitration: Optional) = + userPrearbitration(userPrearbitration.getOrNull()) + + /** + * Sets [Builder.userPrearbitration] to an arbitrary JSON value. + * + * You should usually call [Builder.userPrearbitration] with a well-typed + * [UserPrearbitration] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun userPrearbitration(userPrearbitration: JsonField) = apply { + this.userPrearbitration = userPrearbitration + } + + 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 [UserSubmission]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedAt() + * .amount() + * .attachmentFiles() + * .category() + * .chargeback() + * .createdAt() + * .furtherInformationRequestedAt() + * .furtherInformationRequestedReason() + * .merchantPrearbitrationDecline() + * .status() + * .updatedAt() + * .userPrearbitration() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserSubmission = + UserSubmission( + checkRequired("acceptedAt", acceptedAt), + checkRequired("amount", amount), + checkRequired("attachmentFiles", attachmentFiles).map { it.toImmutable() }, + checkRequired("category", category), + checkRequired("chargeback", chargeback), + checkRequired("createdAt", createdAt), + checkRequired( + "furtherInformationRequestedAt", + furtherInformationRequestedAt, + ), + checkRequired( + "furtherInformationRequestedReason", + furtherInformationRequestedReason, + ), + checkRequired( + "merchantPrearbitrationDecline", + merchantPrearbitrationDecline, + ), + checkRequired("status", status), + checkRequired("updatedAt", updatedAt), + checkRequired("userPrearbitration", userPrearbitration), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserSubmission = apply { + if (validated) { + return@apply + } + + acceptedAt() + amount() + attachmentFiles().forEach { it.validate() } + category().validate() + chargeback().ifPresent { it.validate() } + createdAt() + furtherInformationRequestedAt() + furtherInformationRequestedReason() + merchantPrearbitrationDecline().ifPresent { it.validate() } + status().validate() + updatedAt() + userPrearbitration().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (acceptedAt.asKnown().isPresent) 1 else 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attachmentFiles.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (chargeback.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (furtherInformationRequestedAt.asKnown().isPresent) 1 else 0) + + (if (furtherInformationRequestedReason.asKnown().isPresent) 1 else 0) + + (merchantPrearbitrationDecline.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (userPrearbitration.asKnown().getOrNull()?.validity() ?: 0) + + class AttachmentFile + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") + @ExcludeMissing + fileId: JsonField = JsonMissing.of() + ) : this(fileId, mutableMapOf()) + + /** + * The ID of the file attached to the Card Dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + @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 [AttachmentFile]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentFile]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentFile: AttachmentFile) = apply { + fileId = attachmentFile.fileId + additionalProperties = attachmentFile.additionalProperties.toMutableMap() + } + + /** The ID of the file attached to the Card Dispute. */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + 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 [AttachmentFile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AttachmentFile = + AttachmentFile( + checkRequired("fileId", fileId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AttachmentFile = apply { + if (validated) { + return@apply + } + + fileId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (fileId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentFile && + fileId == other.fileId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AttachmentFile{fileId=$fileId, additionalProperties=$additionalProperties}" + } + + /** + * The category of the user submission. We may add additional possible values for this + * enum over time; your application should be able to handle such additions gracefully. + */ + 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 { + + /** + * Visa Card Dispute Chargeback User Submission Chargeback Details: details will + * be under the `chargeback` object. + */ + @JvmField val CHARGEBACK = of("chargeback") + + /** + * Visa Card Dispute Merchant Pre-Arbitration Decline User Submission: details + * will be under the `merchant_prearbitration_decline` object. + */ + @JvmField + val MERCHANT_PREARBITRATION_DECLINE = of("merchant_prearbitration_decline") + + /** + * Visa Card Dispute User-Initiated Pre-Arbitration User Submission: details + * will be under the `user_prearbitration` object. + */ + @JvmField val USER_PREARBITRATION = of("user_prearbitration") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** + * Visa Card Dispute Chargeback User Submission Chargeback Details: details will + * be under the `chargeback` object. + */ + CHARGEBACK, + /** + * Visa Card Dispute Merchant Pre-Arbitration Decline User Submission: details + * will be under the `merchant_prearbitration_decline` object. + */ + MERCHANT_PREARBITRATION_DECLINE, + /** + * Visa Card Dispute User-Initiated Pre-Arbitration User Submission: details + * will be under the `user_prearbitration` object. + */ + USER_PREARBITRATION, + } + + /** + * 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 { + /** + * Visa Card Dispute Chargeback User Submission Chargeback Details: details will + * be under the `chargeback` object. + */ + CHARGEBACK, + /** + * Visa Card Dispute Merchant Pre-Arbitration Decline User Submission: details + * will be under the `merchant_prearbitration_decline` object. + */ + MERCHANT_PREARBITRATION_DECLINE, + /** + * Visa Card Dispute User-Initiated Pre-Arbitration User Submission: details + * will be under the `user_prearbitration` object. + */ + USER_PREARBITRATION, + /** + * 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) { + CHARGEBACK -> Value.CHARGEBACK + MERCHANT_PREARBITRATION_DECLINE -> Value.MERCHANT_PREARBITRATION_DECLINE + USER_PREARBITRATION -> Value.USER_PREARBITRATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CHARGEBACK -> Known.CHARGEBACK + MERCHANT_PREARBITRATION_DECLINE -> Known.MERCHANT_PREARBITRATION_DECLINE + USER_PREARBITRATION -> Known.USER_PREARBITRATION + else -> throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * A Visa Card Dispute Chargeback User Submission Chargeback Details object. This field + * will be present in the JSON response if and only if `category` is equal to + * `chargeback`. Contains the details specific to a Visa chargeback User Submission for + * a Card Dispute. + */ + class Chargeback + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val authorization: JsonField, + private val category: JsonField, + private val consumerCanceledMerchandise: JsonField, + private val consumerCanceledRecurringTransaction: + JsonField, + private val consumerCanceledServices: JsonField, + private val consumerCounterfeitMerchandise: + JsonField, + private val consumerCreditNotProcessed: JsonField, + private val consumerDamagedOrDefectiveMerchandise: + JsonField, + private val consumerMerchandiseMisrepresentation: + JsonField, + private val consumerMerchandiseNotAsDescribed: + JsonField, + private val consumerMerchandiseNotReceived: + JsonField, + private val consumerNonReceiptOfCash: JsonValue, + private val consumerOriginalCreditTransactionNotAccepted: + JsonField, + private val consumerQualityMerchandise: JsonField, + private val consumerQualityServices: JsonField, + private val consumerServicesMisrepresentation: + JsonField, + private val consumerServicesNotAsDescribed: + JsonField, + private val consumerServicesNotReceived: JsonField, + private val fraud: JsonField, + private val processingError: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("authorization") + @ExcludeMissing + authorization: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("consumer_canceled_merchandise") + @ExcludeMissing + consumerCanceledMerchandise: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_canceled_recurring_transaction") + @ExcludeMissing + consumerCanceledRecurringTransaction: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_canceled_services") + @ExcludeMissing + consumerCanceledServices: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_counterfeit_merchandise") + @ExcludeMissing + consumerCounterfeitMerchandise: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_credit_not_processed") + @ExcludeMissing + consumerCreditNotProcessed: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_damaged_or_defective_merchandise") + @ExcludeMissing + consumerDamagedOrDefectiveMerchandise: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_misrepresentation") + @ExcludeMissing + consumerMerchandiseMisrepresentation: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_not_as_described") + @ExcludeMissing + consumerMerchandiseNotAsDescribed: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_not_received") + @ExcludeMissing + consumerMerchandiseNotReceived: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_non_receipt_of_cash") + @ExcludeMissing + consumerNonReceiptOfCash: JsonValue = JsonMissing.of(), + @JsonProperty("consumer_original_credit_transaction_not_accepted") + @ExcludeMissing + consumerOriginalCreditTransactionNotAccepted: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_quality_merchandise") + @ExcludeMissing + consumerQualityMerchandise: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_quality_services") + @ExcludeMissing + consumerQualityServices: JsonField = JsonMissing.of(), + @JsonProperty("consumer_services_misrepresentation") + @ExcludeMissing + consumerServicesMisrepresentation: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_services_not_as_described") + @ExcludeMissing + consumerServicesNotAsDescribed: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_services_not_received") + @ExcludeMissing + consumerServicesNotReceived: JsonField = + JsonMissing.of(), + @JsonProperty("fraud") + @ExcludeMissing + fraud: JsonField = JsonMissing.of(), + @JsonProperty("processing_error") + @ExcludeMissing + processingError: JsonField = JsonMissing.of(), + ) : this( + authorization, + category, + consumerCanceledMerchandise, + consumerCanceledRecurringTransaction, + consumerCanceledServices, + consumerCounterfeitMerchandise, + consumerCreditNotProcessed, + consumerDamagedOrDefectiveMerchandise, + consumerMerchandiseMisrepresentation, + consumerMerchandiseNotAsDescribed, + consumerMerchandiseNotReceived, + consumerNonReceiptOfCash, + consumerOriginalCreditTransactionNotAccepted, + consumerQualityMerchandise, + consumerQualityServices, + consumerServicesMisrepresentation, + consumerServicesNotAsDescribed, + consumerServicesNotReceived, + fraud, + processingError, + mutableMapOf(), + ) + + /** + * Authorization. Present if and only if `category` is `authorization`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun authorization(): Optional = + authorization.getOptional("authorization") + + /** + * Category. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun category(): Category = category.getRequired("category") + + /** + * Canceled merchandise. Present if and only if `category` is + * `consumer_canceled_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerCanceledMerchandise(): Optional = + consumerCanceledMerchandise.getOptional("consumer_canceled_merchandise") + + /** + * Canceled recurring transaction. Present if and only if `category` is + * `consumer_canceled_recurring_transaction`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerCanceledRecurringTransaction(): + Optional = + consumerCanceledRecurringTransaction.getOptional( + "consumer_canceled_recurring_transaction" + ) + + /** + * Canceled services. Present if and only if `category` is + * `consumer_canceled_services`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerCanceledServices(): Optional = + consumerCanceledServices.getOptional("consumer_canceled_services") + + /** + * Counterfeit merchandise. Present if and only if `category` is + * `consumer_counterfeit_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerCounterfeitMerchandise(): Optional = + consumerCounterfeitMerchandise.getOptional("consumer_counterfeit_merchandise") + + /** + * Credit not processed. Present if and only if `category` is + * `consumer_credit_not_processed`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerCreditNotProcessed(): Optional = + consumerCreditNotProcessed.getOptional("consumer_credit_not_processed") + + /** + * Damaged or defective merchandise. Present if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerDamagedOrDefectiveMerchandise(): + Optional = + consumerDamagedOrDefectiveMerchandise.getOptional( + "consumer_damaged_or_defective_merchandise" + ) + + /** + * Merchandise misrepresentation. Present if and only if `category` is + * `consumer_merchandise_misrepresentation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerMerchandiseMisrepresentation(): + Optional = + consumerMerchandiseMisrepresentation.getOptional( + "consumer_merchandise_misrepresentation" + ) + + /** + * Merchandise not as described. Present if and only if `category` is + * `consumer_merchandise_not_as_described`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerMerchandiseNotAsDescribed(): + Optional = + consumerMerchandiseNotAsDescribed.getOptional( + "consumer_merchandise_not_as_described" + ) + + /** + * Merchandise not received. Present if and only if `category` is + * `consumer_merchandise_not_received`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerMerchandiseNotReceived(): Optional = + consumerMerchandiseNotReceived.getOptional("consumer_merchandise_not_received") + + /** + * Non-receipt of cash. Present if and only if `category` is + * `consumer_non_receipt_of_cash`. + */ + @JsonProperty("consumer_non_receipt_of_cash") + @ExcludeMissing + fun _consumerNonReceiptOfCash(): JsonValue = consumerNonReceiptOfCash + + /** + * Original Credit Transaction (OCT) not accepted. Present if and only if `category` + * is `consumer_original_credit_transaction_not_accepted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerOriginalCreditTransactionNotAccepted(): + Optional = + consumerOriginalCreditTransactionNotAccepted.getOptional( + "consumer_original_credit_transaction_not_accepted" + ) + + /** + * Merchandise quality issue. Present if and only if `category` is + * `consumer_quality_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerQualityMerchandise(): Optional = + consumerQualityMerchandise.getOptional("consumer_quality_merchandise") + + /** + * Services quality issue. Present if and only if `category` is + * `consumer_quality_services`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerQualityServices(): Optional = + consumerQualityServices.getOptional("consumer_quality_services") + + /** + * Services misrepresentation. Present if and only if `category` is + * `consumer_services_misrepresentation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerServicesMisrepresentation(): + Optional = + consumerServicesMisrepresentation.getOptional( + "consumer_services_misrepresentation" + ) + + /** + * Services not as described. Present if and only if `category` is + * `consumer_services_not_as_described`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerServicesNotAsDescribed(): Optional = + consumerServicesNotAsDescribed.getOptional("consumer_services_not_as_described") + + /** + * Services not received. Present if and only if `category` is + * `consumer_services_not_received`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun consumerServicesNotReceived(): Optional = + consumerServicesNotReceived.getOptional("consumer_services_not_received") + + /** + * Fraud. Present if and only if `category` is `fraud`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun fraud(): Optional = fraud.getOptional("fraud") + + /** + * Processing error. Present if and only if `category` is `processing_error`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun processingError(): Optional = + processingError.getOptional("processing_error") + + /** + * Returns the raw JSON value of [authorization]. + * + * Unlike [authorization], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("authorization") + @ExcludeMissing + fun _authorization(): JsonField = authorization + + /** + * Returns the raw JSON value of [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 [consumerCanceledMerchandise]. + * + * Unlike [consumerCanceledMerchandise], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_canceled_merchandise") + @ExcludeMissing + fun _consumerCanceledMerchandise(): JsonField = + consumerCanceledMerchandise + + /** + * Returns the raw JSON value of [consumerCanceledRecurringTransaction]. + * + * Unlike [consumerCanceledRecurringTransaction], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("consumer_canceled_recurring_transaction") + @ExcludeMissing + fun _consumerCanceledRecurringTransaction(): + JsonField = + consumerCanceledRecurringTransaction + + /** + * Returns the raw JSON value of [consumerCanceledServices]. + * + * Unlike [consumerCanceledServices], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_canceled_services") + @ExcludeMissing + fun _consumerCanceledServices(): JsonField = + consumerCanceledServices + + /** + * Returns the raw JSON value of [consumerCounterfeitMerchandise]. + * + * Unlike [consumerCounterfeitMerchandise], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_counterfeit_merchandise") + @ExcludeMissing + fun _consumerCounterfeitMerchandise(): JsonField = + consumerCounterfeitMerchandise + + /** + * Returns the raw JSON value of [consumerCreditNotProcessed]. + * + * Unlike [consumerCreditNotProcessed], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_credit_not_processed") + @ExcludeMissing + fun _consumerCreditNotProcessed(): JsonField = + consumerCreditNotProcessed + + /** + * Returns the raw JSON value of [consumerDamagedOrDefectiveMerchandise]. + * + * Unlike [consumerDamagedOrDefectiveMerchandise], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("consumer_damaged_or_defective_merchandise") + @ExcludeMissing + fun _consumerDamagedOrDefectiveMerchandise(): + JsonField = + consumerDamagedOrDefectiveMerchandise + + /** + * Returns the raw JSON value of [consumerMerchandiseMisrepresentation]. + * + * Unlike [consumerMerchandiseMisrepresentation], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("consumer_merchandise_misrepresentation") + @ExcludeMissing + fun _consumerMerchandiseMisrepresentation(): + JsonField = + consumerMerchandiseMisrepresentation + + /** + * Returns the raw JSON value of [consumerMerchandiseNotAsDescribed]. + * + * Unlike [consumerMerchandiseNotAsDescribed], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_merchandise_not_as_described") + @ExcludeMissing + fun _consumerMerchandiseNotAsDescribed(): + JsonField = consumerMerchandiseNotAsDescribed + + /** + * Returns the raw JSON value of [consumerMerchandiseNotReceived]. + * + * Unlike [consumerMerchandiseNotReceived], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_merchandise_not_received") + @ExcludeMissing + fun _consumerMerchandiseNotReceived(): JsonField = + consumerMerchandiseNotReceived + + /** + * Returns the raw JSON value of [consumerOriginalCreditTransactionNotAccepted]. + * + * Unlike [consumerOriginalCreditTransactionNotAccepted], this method doesn't throw + * if the JSON field has an unexpected type. + */ + @JsonProperty("consumer_original_credit_transaction_not_accepted") + @ExcludeMissing + fun _consumerOriginalCreditTransactionNotAccepted(): + JsonField = + consumerOriginalCreditTransactionNotAccepted + + /** + * Returns the raw JSON value of [consumerQualityMerchandise]. + * + * Unlike [consumerQualityMerchandise], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_quality_merchandise") + @ExcludeMissing + fun _consumerQualityMerchandise(): JsonField = + consumerQualityMerchandise + + /** + * Returns the raw JSON value of [consumerQualityServices]. + * + * Unlike [consumerQualityServices], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumer_quality_services") + @ExcludeMissing + fun _consumerQualityServices(): JsonField = + consumerQualityServices + + /** + * Returns the raw JSON value of [consumerServicesMisrepresentation]. + * + * Unlike [consumerServicesMisrepresentation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_services_misrepresentation") + @ExcludeMissing + fun _consumerServicesMisrepresentation(): + JsonField = consumerServicesMisrepresentation + + /** + * Returns the raw JSON value of [consumerServicesNotAsDescribed]. + * + * Unlike [consumerServicesNotAsDescribed], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_services_not_as_described") + @ExcludeMissing + fun _consumerServicesNotAsDescribed(): JsonField = + consumerServicesNotAsDescribed + + /** + * Returns the raw JSON value of [consumerServicesNotReceived]. + * + * Unlike [consumerServicesNotReceived], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_services_not_received") + @ExcludeMissing + fun _consumerServicesNotReceived(): JsonField = + consumerServicesNotReceived + + /** + * Returns the raw JSON value of [fraud]. + * + * Unlike [fraud], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fraud") @ExcludeMissing fun _fraud(): JsonField = fraud + + /** + * Returns the raw JSON value of [processingError]. + * + * Unlike [processingError], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("processing_error") + @ExcludeMissing + fun _processingError(): JsonField = processingError + + @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 [Chargeback]. + * + * The following fields are required: + * ```java + * .authorization() + * .category() + * .consumerCanceledMerchandise() + * .consumerCanceledRecurringTransaction() + * .consumerCanceledServices() + * .consumerCounterfeitMerchandise() + * .consumerCreditNotProcessed() + * .consumerDamagedOrDefectiveMerchandise() + * .consumerMerchandiseMisrepresentation() + * .consumerMerchandiseNotAsDescribed() + * .consumerMerchandiseNotReceived() + * .consumerNonReceiptOfCash() + * .consumerOriginalCreditTransactionNotAccepted() + * .consumerQualityMerchandise() + * .consumerQualityServices() + * .consumerServicesMisrepresentation() + * .consumerServicesNotAsDescribed() + * .consumerServicesNotReceived() + * .fraud() + * .processingError() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Chargeback]. */ + class Builder internal constructor() { + + private var authorization: JsonField? = null + private var category: JsonField? = null + private var consumerCanceledMerchandise: + JsonField? = + null + private var consumerCanceledRecurringTransaction: + JsonField? = + null + private var consumerCanceledServices: JsonField? = + null + private var consumerCounterfeitMerchandise: + JsonField? = + null + private var consumerCreditNotProcessed: JsonField? = + null + private var consumerDamagedOrDefectiveMerchandise: + JsonField? = + null + private var consumerMerchandiseMisrepresentation: + JsonField? = + null + private var consumerMerchandiseNotAsDescribed: + JsonField? = + null + private var consumerMerchandiseNotReceived: + JsonField? = + null + private var consumerNonReceiptOfCash: JsonValue? = null + private var consumerOriginalCreditTransactionNotAccepted: + JsonField? = + null + private var consumerQualityMerchandise: JsonField? = + null + private var consumerQualityServices: JsonField? = null + private var consumerServicesMisrepresentation: + JsonField? = + null + private var consumerServicesNotAsDescribed: + JsonField? = + null + private var consumerServicesNotReceived: + JsonField? = + null + private var fraud: JsonField? = null + private var processingError: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chargeback: Chargeback) = apply { + authorization = chargeback.authorization + category = chargeback.category + consumerCanceledMerchandise = chargeback.consumerCanceledMerchandise + consumerCanceledRecurringTransaction = + chargeback.consumerCanceledRecurringTransaction + consumerCanceledServices = chargeback.consumerCanceledServices + consumerCounterfeitMerchandise = chargeback.consumerCounterfeitMerchandise + consumerCreditNotProcessed = chargeback.consumerCreditNotProcessed + consumerDamagedOrDefectiveMerchandise = + chargeback.consumerDamagedOrDefectiveMerchandise + consumerMerchandiseMisrepresentation = + chargeback.consumerMerchandiseMisrepresentation + consumerMerchandiseNotAsDescribed = + chargeback.consumerMerchandiseNotAsDescribed + consumerMerchandiseNotReceived = chargeback.consumerMerchandiseNotReceived + consumerNonReceiptOfCash = chargeback.consumerNonReceiptOfCash + consumerOriginalCreditTransactionNotAccepted = + chargeback.consumerOriginalCreditTransactionNotAccepted + consumerQualityMerchandise = chargeback.consumerQualityMerchandise + consumerQualityServices = chargeback.consumerQualityServices + consumerServicesMisrepresentation = + chargeback.consumerServicesMisrepresentation + consumerServicesNotAsDescribed = chargeback.consumerServicesNotAsDescribed + consumerServicesNotReceived = chargeback.consumerServicesNotReceived + fraud = chargeback.fraud + processingError = chargeback.processingError + additionalProperties = chargeback.additionalProperties.toMutableMap() + } + + /** Authorization. Present if and only if `category` is `authorization`. */ + fun authorization(authorization: Authorization?) = + authorization(JsonField.ofNullable(authorization)) + + /** + * Alias for calling [Builder.authorization] with `authorization.orElse(null)`. + */ + fun authorization(authorization: Optional) = + authorization(authorization.getOrNull()) + + /** + * Sets [Builder.authorization] to an arbitrary JSON value. + * + * You should usually call [Builder.authorization] with a well-typed + * [Authorization] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun authorization(authorization: JsonField) = apply { + this.authorization = authorization + } + + /** Category. */ + 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 } + + /** + * Canceled merchandise. Present if and only if `category` is + * `consumer_canceled_merchandise`. + */ + fun consumerCanceledMerchandise( + consumerCanceledMerchandise: ConsumerCanceledMerchandise? + ) = + consumerCanceledMerchandise( + JsonField.ofNullable(consumerCanceledMerchandise) + ) + + /** + * Alias for calling [Builder.consumerCanceledMerchandise] with + * `consumerCanceledMerchandise.orElse(null)`. + */ + fun consumerCanceledMerchandise( + consumerCanceledMerchandise: Optional + ) = consumerCanceledMerchandise(consumerCanceledMerchandise.getOrNull()) + + /** + * Sets [Builder.consumerCanceledMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCanceledMerchandise] with a + * well-typed [ConsumerCanceledMerchandise] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerCanceledMerchandise( + consumerCanceledMerchandise: JsonField + ) = apply { this.consumerCanceledMerchandise = consumerCanceledMerchandise } + + /** + * Canceled recurring transaction. Present if and only if `category` is + * `consumer_canceled_recurring_transaction`. + */ + fun consumerCanceledRecurringTransaction( + consumerCanceledRecurringTransaction: ConsumerCanceledRecurringTransaction? + ) = + consumerCanceledRecurringTransaction( + JsonField.ofNullable(consumerCanceledRecurringTransaction) + ) + + /** + * Alias for calling [Builder.consumerCanceledRecurringTransaction] with + * `consumerCanceledRecurringTransaction.orElse(null)`. + */ + fun consumerCanceledRecurringTransaction( + consumerCanceledRecurringTransaction: + Optional + ) = + consumerCanceledRecurringTransaction( + consumerCanceledRecurringTransaction.getOrNull() + ) + + /** + * Sets [Builder.consumerCanceledRecurringTransaction] to an arbitrary JSON + * value. + * + * You should usually call [Builder.consumerCanceledRecurringTransaction] with a + * well-typed [ConsumerCanceledRecurringTransaction] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerCanceledRecurringTransaction( + consumerCanceledRecurringTransaction: + JsonField + ) = apply { + this.consumerCanceledRecurringTransaction = + consumerCanceledRecurringTransaction + } + + /** + * Canceled services. Present if and only if `category` is + * `consumer_canceled_services`. + */ + fun consumerCanceledServices( + consumerCanceledServices: ConsumerCanceledServices? + ) = consumerCanceledServices(JsonField.ofNullable(consumerCanceledServices)) + + /** + * Alias for calling [Builder.consumerCanceledServices] with + * `consumerCanceledServices.orElse(null)`. + */ + fun consumerCanceledServices( + consumerCanceledServices: Optional + ) = consumerCanceledServices(consumerCanceledServices.getOrNull()) + + /** + * Sets [Builder.consumerCanceledServices] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCanceledServices] with a well-typed + * [ConsumerCanceledServices] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumerCanceledServices( + consumerCanceledServices: JsonField + ) = apply { this.consumerCanceledServices = consumerCanceledServices } + + /** + * Counterfeit merchandise. Present if and only if `category` is + * `consumer_counterfeit_merchandise`. + */ + fun consumerCounterfeitMerchandise( + consumerCounterfeitMerchandise: ConsumerCounterfeitMerchandise? + ) = + consumerCounterfeitMerchandise( + JsonField.ofNullable(consumerCounterfeitMerchandise) + ) + + /** + * Alias for calling [Builder.consumerCounterfeitMerchandise] with + * `consumerCounterfeitMerchandise.orElse(null)`. + */ + fun consumerCounterfeitMerchandise( + consumerCounterfeitMerchandise: Optional + ) = consumerCounterfeitMerchandise(consumerCounterfeitMerchandise.getOrNull()) + + /** + * Sets [Builder.consumerCounterfeitMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCounterfeitMerchandise] with a + * well-typed [ConsumerCounterfeitMerchandise] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerCounterfeitMerchandise( + consumerCounterfeitMerchandise: JsonField + ) = apply { + this.consumerCounterfeitMerchandise = consumerCounterfeitMerchandise + } + + /** + * Credit not processed. Present if and only if `category` is + * `consumer_credit_not_processed`. + */ + fun consumerCreditNotProcessed( + consumerCreditNotProcessed: ConsumerCreditNotProcessed? + ) = consumerCreditNotProcessed(JsonField.ofNullable(consumerCreditNotProcessed)) + + /** + * Alias for calling [Builder.consumerCreditNotProcessed] with + * `consumerCreditNotProcessed.orElse(null)`. + */ + fun consumerCreditNotProcessed( + consumerCreditNotProcessed: Optional + ) = consumerCreditNotProcessed(consumerCreditNotProcessed.getOrNull()) + + /** + * Sets [Builder.consumerCreditNotProcessed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCreditNotProcessed] with a + * well-typed [ConsumerCreditNotProcessed] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerCreditNotProcessed( + consumerCreditNotProcessed: JsonField + ) = apply { this.consumerCreditNotProcessed = consumerCreditNotProcessed } + + /** + * Damaged or defective merchandise. Present if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + */ + fun consumerDamagedOrDefectiveMerchandise( + consumerDamagedOrDefectiveMerchandise: + ConsumerDamagedOrDefectiveMerchandise? + ) = + consumerDamagedOrDefectiveMerchandise( + JsonField.ofNullable(consumerDamagedOrDefectiveMerchandise) + ) + + /** + * Alias for calling [Builder.consumerDamagedOrDefectiveMerchandise] with + * `consumerDamagedOrDefectiveMerchandise.orElse(null)`. + */ + fun consumerDamagedOrDefectiveMerchandise( + consumerDamagedOrDefectiveMerchandise: + Optional + ) = + consumerDamagedOrDefectiveMerchandise( + consumerDamagedOrDefectiveMerchandise.getOrNull() + ) + + /** + * Sets [Builder.consumerDamagedOrDefectiveMerchandise] to an arbitrary JSON + * value. + * + * You should usually call [Builder.consumerDamagedOrDefectiveMerchandise] with + * a well-typed [ConsumerDamagedOrDefectiveMerchandise] value instead. This + * method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumerDamagedOrDefectiveMerchandise( + consumerDamagedOrDefectiveMerchandise: + JsonField + ) = apply { + this.consumerDamagedOrDefectiveMerchandise = + consumerDamagedOrDefectiveMerchandise + } + + /** + * Merchandise misrepresentation. Present if and only if `category` is + * `consumer_merchandise_misrepresentation`. + */ + fun consumerMerchandiseMisrepresentation( + consumerMerchandiseMisrepresentation: ConsumerMerchandiseMisrepresentation? + ) = + consumerMerchandiseMisrepresentation( + JsonField.ofNullable(consumerMerchandiseMisrepresentation) + ) + + /** + * Alias for calling [Builder.consumerMerchandiseMisrepresentation] with + * `consumerMerchandiseMisrepresentation.orElse(null)`. + */ + fun consumerMerchandiseMisrepresentation( + consumerMerchandiseMisrepresentation: + Optional + ) = + consumerMerchandiseMisrepresentation( + consumerMerchandiseMisrepresentation.getOrNull() + ) + + /** + * Sets [Builder.consumerMerchandiseMisrepresentation] to an arbitrary JSON + * value. + * + * You should usually call [Builder.consumerMerchandiseMisrepresentation] with a + * well-typed [ConsumerMerchandiseMisrepresentation] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerMerchandiseMisrepresentation( + consumerMerchandiseMisrepresentation: + JsonField + ) = apply { + this.consumerMerchandiseMisrepresentation = + consumerMerchandiseMisrepresentation + } + + /** + * Merchandise not as described. Present if and only if `category` is + * `consumer_merchandise_not_as_described`. + */ + fun consumerMerchandiseNotAsDescribed( + consumerMerchandiseNotAsDescribed: ConsumerMerchandiseNotAsDescribed? + ) = + consumerMerchandiseNotAsDescribed( + JsonField.ofNullable(consumerMerchandiseNotAsDescribed) + ) + + /** + * Alias for calling [Builder.consumerMerchandiseNotAsDescribed] with + * `consumerMerchandiseNotAsDescribed.orElse(null)`. + */ + fun consumerMerchandiseNotAsDescribed( + consumerMerchandiseNotAsDescribed: + Optional + ) = + consumerMerchandiseNotAsDescribed( + consumerMerchandiseNotAsDescribed.getOrNull() + ) + + /** + * Sets [Builder.consumerMerchandiseNotAsDescribed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerMerchandiseNotAsDescribed] with a + * well-typed [ConsumerMerchandiseNotAsDescribed] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerMerchandiseNotAsDescribed( + consumerMerchandiseNotAsDescribed: + JsonField + ) = apply { + this.consumerMerchandiseNotAsDescribed = consumerMerchandiseNotAsDescribed + } + + /** + * Merchandise not received. Present if and only if `category` is + * `consumer_merchandise_not_received`. + */ + fun consumerMerchandiseNotReceived( + consumerMerchandiseNotReceived: ConsumerMerchandiseNotReceived? + ) = + consumerMerchandiseNotReceived( + JsonField.ofNullable(consumerMerchandiseNotReceived) + ) + + /** + * Alias for calling [Builder.consumerMerchandiseNotReceived] with + * `consumerMerchandiseNotReceived.orElse(null)`. + */ + fun consumerMerchandiseNotReceived( + consumerMerchandiseNotReceived: Optional + ) = consumerMerchandiseNotReceived(consumerMerchandiseNotReceived.getOrNull()) + + /** + * Sets [Builder.consumerMerchandiseNotReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerMerchandiseNotReceived] with a + * well-typed [ConsumerMerchandiseNotReceived] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerMerchandiseNotReceived( + consumerMerchandiseNotReceived: JsonField + ) = apply { + this.consumerMerchandiseNotReceived = consumerMerchandiseNotReceived + } + + /** + * Non-receipt of cash. Present if and only if `category` is + * `consumer_non_receipt_of_cash`. + */ + fun consumerNonReceiptOfCash(consumerNonReceiptOfCash: JsonValue) = apply { + this.consumerNonReceiptOfCash = consumerNonReceiptOfCash + } + + /** + * Original Credit Transaction (OCT) not accepted. Present if and only if + * `category` is `consumer_original_credit_transaction_not_accepted`. + */ + fun consumerOriginalCreditTransactionNotAccepted( + consumerOriginalCreditTransactionNotAccepted: + ConsumerOriginalCreditTransactionNotAccepted? + ) = + consumerOriginalCreditTransactionNotAccepted( + JsonField.ofNullable(consumerOriginalCreditTransactionNotAccepted) + ) + + /** + * Alias for calling [Builder.consumerOriginalCreditTransactionNotAccepted] with + * `consumerOriginalCreditTransactionNotAccepted.orElse(null)`. + */ + fun consumerOriginalCreditTransactionNotAccepted( + consumerOriginalCreditTransactionNotAccepted: + Optional + ) = + consumerOriginalCreditTransactionNotAccepted( + consumerOriginalCreditTransactionNotAccepted.getOrNull() + ) + + /** + * Sets [Builder.consumerOriginalCreditTransactionNotAccepted] to an arbitrary + * JSON value. + * + * You should usually call + * [Builder.consumerOriginalCreditTransactionNotAccepted] with a well-typed + * [ConsumerOriginalCreditTransactionNotAccepted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerOriginalCreditTransactionNotAccepted( + consumerOriginalCreditTransactionNotAccepted: + JsonField + ) = apply { + this.consumerOriginalCreditTransactionNotAccepted = + consumerOriginalCreditTransactionNotAccepted + } + + /** + * Merchandise quality issue. Present if and only if `category` is + * `consumer_quality_merchandise`. + */ + fun consumerQualityMerchandise( + consumerQualityMerchandise: ConsumerQualityMerchandise? + ) = consumerQualityMerchandise(JsonField.ofNullable(consumerQualityMerchandise)) + + /** + * Alias for calling [Builder.consumerQualityMerchandise] with + * `consumerQualityMerchandise.orElse(null)`. + */ + fun consumerQualityMerchandise( + consumerQualityMerchandise: Optional + ) = consumerQualityMerchandise(consumerQualityMerchandise.getOrNull()) + + /** + * Sets [Builder.consumerQualityMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerQualityMerchandise] with a + * well-typed [ConsumerQualityMerchandise] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerQualityMerchandise( + consumerQualityMerchandise: JsonField + ) = apply { this.consumerQualityMerchandise = consumerQualityMerchandise } + + /** + * Services quality issue. Present if and only if `category` is + * `consumer_quality_services`. + */ + fun consumerQualityServices(consumerQualityServices: ConsumerQualityServices?) = + consumerQualityServices(JsonField.ofNullable(consumerQualityServices)) + + /** + * Alias for calling [Builder.consumerQualityServices] with + * `consumerQualityServices.orElse(null)`. + */ + fun consumerQualityServices( + consumerQualityServices: Optional + ) = consumerQualityServices(consumerQualityServices.getOrNull()) + + /** + * Sets [Builder.consumerQualityServices] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerQualityServices] with a well-typed + * [ConsumerQualityServices] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerQualityServices( + consumerQualityServices: JsonField + ) = apply { this.consumerQualityServices = consumerQualityServices } + + /** + * Services misrepresentation. Present if and only if `category` is + * `consumer_services_misrepresentation`. + */ + fun consumerServicesMisrepresentation( + consumerServicesMisrepresentation: ConsumerServicesMisrepresentation? + ) = + consumerServicesMisrepresentation( + JsonField.ofNullable(consumerServicesMisrepresentation) + ) + + /** + * Alias for calling [Builder.consumerServicesMisrepresentation] with + * `consumerServicesMisrepresentation.orElse(null)`. + */ + fun consumerServicesMisrepresentation( + consumerServicesMisrepresentation: + Optional + ) = + consumerServicesMisrepresentation( + consumerServicesMisrepresentation.getOrNull() + ) + + /** + * Sets [Builder.consumerServicesMisrepresentation] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesMisrepresentation] with a + * well-typed [ConsumerServicesMisrepresentation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerServicesMisrepresentation( + consumerServicesMisrepresentation: + JsonField + ) = apply { + this.consumerServicesMisrepresentation = consumerServicesMisrepresentation + } + + /** + * Services not as described. Present if and only if `category` is + * `consumer_services_not_as_described`. + */ + fun consumerServicesNotAsDescribed( + consumerServicesNotAsDescribed: ConsumerServicesNotAsDescribed? + ) = + consumerServicesNotAsDescribed( + JsonField.ofNullable(consumerServicesNotAsDescribed) + ) + + /** + * Alias for calling [Builder.consumerServicesNotAsDescribed] with + * `consumerServicesNotAsDescribed.orElse(null)`. + */ + fun consumerServicesNotAsDescribed( + consumerServicesNotAsDescribed: Optional + ) = consumerServicesNotAsDescribed(consumerServicesNotAsDescribed.getOrNull()) + + /** + * Sets [Builder.consumerServicesNotAsDescribed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesNotAsDescribed] with a + * well-typed [ConsumerServicesNotAsDescribed] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerServicesNotAsDescribed( + consumerServicesNotAsDescribed: JsonField + ) = apply { + this.consumerServicesNotAsDescribed = consumerServicesNotAsDescribed + } + + /** + * Services not received. Present if and only if `category` is + * `consumer_services_not_received`. + */ + fun consumerServicesNotReceived( + consumerServicesNotReceived: ConsumerServicesNotReceived? + ) = + consumerServicesNotReceived( + JsonField.ofNullable(consumerServicesNotReceived) + ) + + /** + * Alias for calling [Builder.consumerServicesNotReceived] with + * `consumerServicesNotReceived.orElse(null)`. + */ + fun consumerServicesNotReceived( + consumerServicesNotReceived: Optional + ) = consumerServicesNotReceived(consumerServicesNotReceived.getOrNull()) + + /** + * Sets [Builder.consumerServicesNotReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesNotReceived] with a + * well-typed [ConsumerServicesNotReceived] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun consumerServicesNotReceived( + consumerServicesNotReceived: JsonField + ) = apply { this.consumerServicesNotReceived = consumerServicesNotReceived } + + /** Fraud. Present if and only if `category` is `fraud`. */ + fun fraud(fraud: Fraud?) = fraud(JsonField.ofNullable(fraud)) + + /** Alias for calling [Builder.fraud] with `fraud.orElse(null)`. */ + fun fraud(fraud: Optional) = fraud(fraud.getOrNull()) + + /** + * Sets [Builder.fraud] to an arbitrary JSON value. + * + * You should usually call [Builder.fraud] with a well-typed [Fraud] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun fraud(fraud: JsonField) = apply { this.fraud = fraud } + + /** + * Processing error. Present if and only if `category` is `processing_error`. + */ + fun processingError(processingError: ProcessingError?) = + processingError(JsonField.ofNullable(processingError)) + + /** + * Alias for calling [Builder.processingError] with + * `processingError.orElse(null)`. + */ + fun processingError(processingError: Optional) = + processingError(processingError.getOrNull()) + + /** + * Sets [Builder.processingError] to an arbitrary JSON value. + * + * You should usually call [Builder.processingError] with a well-typed + * [ProcessingError] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun processingError(processingError: JsonField) = apply { + this.processingError = processingError + } + + 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 [Chargeback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .authorization() + * .category() + * .consumerCanceledMerchandise() + * .consumerCanceledRecurringTransaction() + * .consumerCanceledServices() + * .consumerCounterfeitMerchandise() + * .consumerCreditNotProcessed() + * .consumerDamagedOrDefectiveMerchandise() + * .consumerMerchandiseMisrepresentation() + * .consumerMerchandiseNotAsDescribed() + * .consumerMerchandiseNotReceived() + * .consumerNonReceiptOfCash() + * .consumerOriginalCreditTransactionNotAccepted() + * .consumerQualityMerchandise() + * .consumerQualityServices() + * .consumerServicesMisrepresentation() + * .consumerServicesNotAsDescribed() + * .consumerServicesNotReceived() + * .fraud() + * .processingError() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Chargeback = + Chargeback( + checkRequired("authorization", authorization), + checkRequired("category", category), + checkRequired( + "consumerCanceledMerchandise", + consumerCanceledMerchandise, + ), + checkRequired( + "consumerCanceledRecurringTransaction", + consumerCanceledRecurringTransaction, + ), + checkRequired("consumerCanceledServices", consumerCanceledServices), + checkRequired( + "consumerCounterfeitMerchandise", + consumerCounterfeitMerchandise, + ), + checkRequired("consumerCreditNotProcessed", consumerCreditNotProcessed), + checkRequired( + "consumerDamagedOrDefectiveMerchandise", + consumerDamagedOrDefectiveMerchandise, + ), + checkRequired( + "consumerMerchandiseMisrepresentation", + consumerMerchandiseMisrepresentation, + ), + checkRequired( + "consumerMerchandiseNotAsDescribed", + consumerMerchandiseNotAsDescribed, + ), + checkRequired( + "consumerMerchandiseNotReceived", + consumerMerchandiseNotReceived, + ), + checkRequired("consumerNonReceiptOfCash", consumerNonReceiptOfCash), + checkRequired( + "consumerOriginalCreditTransactionNotAccepted", + consumerOriginalCreditTransactionNotAccepted, + ), + checkRequired("consumerQualityMerchandise", consumerQualityMerchandise), + checkRequired("consumerQualityServices", consumerQualityServices), + checkRequired( + "consumerServicesMisrepresentation", + consumerServicesMisrepresentation, + ), + checkRequired( + "consumerServicesNotAsDescribed", + consumerServicesNotAsDescribed, + ), + checkRequired( + "consumerServicesNotReceived", + consumerServicesNotReceived, + ), + checkRequired("fraud", fraud), + checkRequired("processingError", processingError), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Chargeback = apply { + if (validated) { + return@apply + } + + authorization().ifPresent { it.validate() } + category().validate() + consumerCanceledMerchandise().ifPresent { it.validate() } + consumerCanceledRecurringTransaction().ifPresent { it.validate() } + consumerCanceledServices().ifPresent { it.validate() } + consumerCounterfeitMerchandise().ifPresent { it.validate() } + consumerCreditNotProcessed().ifPresent { it.validate() } + consumerDamagedOrDefectiveMerchandise().ifPresent { it.validate() } + consumerMerchandiseMisrepresentation().ifPresent { it.validate() } + consumerMerchandiseNotAsDescribed().ifPresent { it.validate() } + consumerMerchandiseNotReceived().ifPresent { it.validate() } + consumerOriginalCreditTransactionNotAccepted().ifPresent { it.validate() } + consumerQualityMerchandise().ifPresent { it.validate() } + consumerQualityServices().ifPresent { it.validate() } + consumerServicesMisrepresentation().ifPresent { it.validate() } + consumerServicesNotAsDescribed().ifPresent { it.validate() } + consumerServicesNotReceived().ifPresent { it.validate() } + fraud().ifPresent { it.validate() } + processingError().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (authorization.asKnown().getOrNull()?.validity() ?: 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCanceledMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCanceledRecurringTransaction.asKnown().getOrNull()?.validity() + ?: 0) + + (consumerCanceledServices.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCounterfeitMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCreditNotProcessed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerDamagedOrDefectiveMerchandise.asKnown().getOrNull()?.validity() + ?: 0) + + (consumerMerchandiseMisrepresentation.asKnown().getOrNull()?.validity() + ?: 0) + + (consumerMerchandiseNotAsDescribed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerMerchandiseNotReceived.asKnown().getOrNull()?.validity() ?: 0) + + (consumerOriginalCreditTransactionNotAccepted + .asKnown() + .getOrNull() + ?.validity() ?: 0) + + (consumerQualityMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerQualityServices.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesMisrepresentation.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesNotAsDescribed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesNotReceived.asKnown().getOrNull()?.validity() ?: 0) + + (fraud.asKnown().getOrNull()?.validity() ?: 0) + + (processingError.asKnown().getOrNull()?.validity() ?: 0) + + /** Authorization. Present if and only if `category` is `authorization`. */ + class Authorization + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accountStatus: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_status") + @ExcludeMissing + accountStatus: JsonField = JsonMissing.of() + ) : this(accountStatus, mutableMapOf()) + + /** + * Account status. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accountStatus(): AccountStatus = accountStatus.getRequired("account_status") + + /** + * Returns the raw JSON value of [accountStatus]. + * + * Unlike [accountStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("account_status") + @ExcludeMissing + fun _accountStatus(): JsonField = accountStatus + + @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 + * [Authorization]. + * + * The following fields are required: + * ```java + * .accountStatus() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Authorization]. */ + class Builder internal constructor() { + + private var accountStatus: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(authorization: Authorization) = apply { + accountStatus = authorization.accountStatus + additionalProperties = authorization.additionalProperties.toMutableMap() + } + + /** Account status. */ + fun accountStatus(accountStatus: AccountStatus) = + accountStatus(JsonField.of(accountStatus)) + + /** + * Sets [Builder.accountStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.accountStatus] with a well-typed + * [AccountStatus] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun accountStatus(accountStatus: JsonField) = apply { + this.accountStatus = accountStatus + } + + 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 [Authorization]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountStatus() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Authorization = + Authorization( + checkRequired("accountStatus", accountStatus), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Authorization = apply { + if (validated) { + return@apply + } + + accountStatus().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accountStatus.asKnown().getOrNull()?.validity() ?: 0) + + /** Account status. */ + class AccountStatus + @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 { + + /** Account closed. */ + @JvmField val ACCOUNT_CLOSED = of("account_closed") + + /** Credit problem. */ + @JvmField val CREDIT_PROBLEM = of("credit_problem") + + /** Fraud. */ + @JvmField val FRAUD = of("fraud") + + @JvmStatic fun of(value: String) = AccountStatus(JsonField.of(value)) + } + + /** An enum containing [AccountStatus]'s known values. */ + enum class Known { + /** Account closed. */ + ACCOUNT_CLOSED, + /** Credit problem. */ + CREDIT_PROBLEM, + /** Fraud. */ + FRAUD, + } + + /** + * An enum containing [AccountStatus]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AccountStatus] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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 closed. */ + ACCOUNT_CLOSED, + /** Credit problem. */ + CREDIT_PROBLEM, + /** Fraud. */ + FRAUD, + /** + * An enum member indicating that [AccountStatus] 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_CLOSED -> Value.ACCOUNT_CLOSED + CREDIT_PROBLEM -> Value.CREDIT_PROBLEM + FRAUD -> Value.FRAUD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_CLOSED -> Known.ACCOUNT_CLOSED + CREDIT_PROBLEM -> Known.CREDIT_PROBLEM + FRAUD -> Known.FRAUD + else -> + throw IncreaseInvalidDataException( + "Unknown AccountStatus: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AccountStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountStatus && 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 Authorization && + accountStatus == other.accountStatus && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accountStatus, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Authorization{accountStatus=$accountStatus, additionalProperties=$additionalProperties}" + } + + /** Category. */ + 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 { + + /** Authorization. */ + @JvmField val AUTHORIZATION = of("authorization") + + /** Consumer: canceled merchandise. */ + @JvmField + val CONSUMER_CANCELED_MERCHANDISE = of("consumer_canceled_merchandise") + + /** Consumer: canceled recurring transaction. */ + @JvmField + val CONSUMER_CANCELED_RECURRING_TRANSACTION = + of("consumer_canceled_recurring_transaction") + + /** Consumer: canceled services. */ + @JvmField val CONSUMER_CANCELED_SERVICES = of("consumer_canceled_services") + + /** Consumer: counterfeit merchandise. */ + @JvmField + val CONSUMER_COUNTERFEIT_MERCHANDISE = + of("consumer_counterfeit_merchandise") + + /** Consumer: credit not processed. */ + @JvmField + val CONSUMER_CREDIT_NOT_PROCESSED = of("consumer_credit_not_processed") + + /** Consumer: damaged or defective merchandise. */ + @JvmField + val CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE = + of("consumer_damaged_or_defective_merchandise") + + /** Consumer: merchandise misrepresentation. */ + @JvmField + val CONSUMER_MERCHANDISE_MISREPRESENTATION = + of("consumer_merchandise_misrepresentation") + + /** Consumer: merchandise not as described. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED = + of("consumer_merchandise_not_as_described") + + /** Consumer: merchandise not received. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_RECEIVED = + of("consumer_merchandise_not_received") + + /** Consumer: non-receipt of cash. */ + @JvmField + val CONSUMER_NON_RECEIPT_OF_CASH = of("consumer_non_receipt_of_cash") + + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + @JvmField + val CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED = + of("consumer_original_credit_transaction_not_accepted") + + /** Consumer: merchandise quality issue. */ + @JvmField + val CONSUMER_QUALITY_MERCHANDISE = of("consumer_quality_merchandise") + + /** Consumer: services quality issue. */ + @JvmField val CONSUMER_QUALITY_SERVICES = of("consumer_quality_services") + + /** Consumer: services misrepresentation. */ + @JvmField + val CONSUMER_SERVICES_MISREPRESENTATION = + of("consumer_services_misrepresentation") + + /** Consumer: services not as described. */ + @JvmField + val CONSUMER_SERVICES_NOT_AS_DESCRIBED = + of("consumer_services_not_as_described") + + /** Consumer: services not received. */ + @JvmField + val CONSUMER_SERVICES_NOT_RECEIVED = of("consumer_services_not_received") + + /** Fraud. */ + @JvmField val FRAUD = of("fraud") + + /** Processing error. */ + @JvmField val PROCESSING_ERROR = of("processing_error") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + } + + /** + * 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 { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + /** + * 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) { + AUTHORIZATION -> Value.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Value.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Value.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Value.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> + Value.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Value.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Value.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Value.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Value.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> + Value.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Value.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Value.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Value.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Value.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> + Value.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> + Value.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> Value.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Value.FRAUD + PROCESSING_ERROR -> Value.PROCESSING_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 IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + AUTHORIZATION -> Known.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Known.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Known.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Known.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> + Known.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Known.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Known.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Known.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Known.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> + Known.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Known.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Known.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Known.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Known.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> + Known.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> + Known.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> Known.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Known.FRAUD + PROCESSING_ERROR -> Known.PROCESSING_ERROR + else -> throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Canceled merchandise. Present if and only if `category` is + * `consumer_canceled_merchandise`. + */ + class ConsumerCanceledMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val notReturned: JsonValue, + private val purchaseExplanation: JsonField, + private val receivedOrExpectedAt: JsonField, + private val returnAttempted: JsonField, + private val returnOutcome: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = + JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_or_expected_at") + @ExcludeMissing + receivedOrExpectedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + merchantResolutionAttempted, + notReturned, + purchaseExplanation, + receivedOrExpectedAt, + returnAttempted, + returnOutcome, + returned, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderCancellation(): Optional = + cardholderCancellation.getOptional("cardholder_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** Not returned. Present if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received or expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedOrExpectedAt(): LocalDate = + receivedOrExpectedAt.getRequired("received_or_expected_at") + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Returned. Present if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedOrExpectedAt]. + * + * Unlike [receivedOrExpectedAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("received_or_expected_at") + @ExcludeMissing + fun _receivedOrExpectedAt(): JsonField = receivedOrExpectedAt + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerCanceledMerchandise]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .notReturned() + * .purchaseExplanation() + * .receivedOrExpectedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledMerchandise]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = + null + private var merchantResolutionAttempted: + JsonField? = + null + private var notReturned: JsonValue? = null + private var purchaseExplanation: JsonField? = null + private var receivedOrExpectedAt: JsonField? = null + private var returnAttempted: JsonField? = null + private var returnOutcome: JsonField? = null + private var returned: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerCanceledMerchandise: ConsumerCanceledMerchandise + ) = apply { + cardholderCancellation = + consumerCanceledMerchandise.cardholderCancellation + merchantResolutionAttempted = + consumerCanceledMerchandise.merchantResolutionAttempted + notReturned = consumerCanceledMerchandise.notReturned + purchaseExplanation = consumerCanceledMerchandise.purchaseExplanation + receivedOrExpectedAt = consumerCanceledMerchandise.receivedOrExpectedAt + returnAttempted = consumerCanceledMerchandise.returnAttempted + returnOutcome = consumerCanceledMerchandise.returnOutcome + returned = consumerCanceledMerchandise.returned + additionalProperties = + consumerCanceledMerchandise.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation( + cardholderCancellation: CardholderCancellation? + ) = cardholderCancellation(JsonField.ofNullable(cardholderCancellation)) + + /** + * Alias for calling [Builder.cardholderCancellation] with + * `cardholderCancellation.orElse(null)`. + */ + fun cardholderCancellation( + cardholderCancellation: Optional + ) = cardholderCancellation(cardholderCancellation.getOrNull()) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a + * well-typed [CardholderCancellation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * Not returned. Present if and only if `return_outcome` is `not_returned`. + */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received or expected at. */ + fun receivedOrExpectedAt(receivedOrExpectedAt: LocalDate) = + receivedOrExpectedAt(JsonField.of(receivedOrExpectedAt)) + + /** + * Sets [Builder.receivedOrExpectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedOrExpectedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun receivedOrExpectedAt(receivedOrExpectedAt: JsonField) = + apply { + this.receivedOrExpectedAt = receivedOrExpectedAt + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted?) = + returnAttempted(JsonField.ofNullable(returnAttempted)) + + /** + * Alias for calling [Builder.returnAttempted] with + * `returnAttempted.orElse(null)`. + */ + fun returnAttempted(returnAttempted: Optional) = + returnAttempted(returnAttempted.getOrNull()) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned?) = returned(JsonField.ofNullable(returned)) + + /** Alias for calling [Builder.returned] with `returned.orElse(null)`. */ + fun returned(returned: Optional) = returned(returned.getOrNull()) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returned(returned: JsonField) = apply { + this.returned = returned + } + + 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 [ConsumerCanceledMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .notReturned() + * .purchaseExplanation() + * .receivedOrExpectedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledMerchandise = + ConsumerCanceledMerchandise( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("notReturned", notReturned), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedOrExpectedAt", receivedOrExpectedAt), + checkRequired("returnAttempted", returnAttempted), + checkRequired("returnOutcome", returnOutcome), + checkRequired("returned", returned), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledMerchandise = apply { + if (validated) { + return@apply + } + + cardholderCancellation().ifPresent { it.validate() } + merchantResolutionAttempted().validate() + purchaseExplanation() + receivedOrExpectedAt() + returnAttempted().ifPresent { it.validate() } + returnOutcome().validate() + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedOrExpectedAt.asKnown().isPresent) 1 else 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val canceledPriorToShipDate: JsonField, + private val cancellationPolicyProvided: + JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("canceled_prior_to_ship_date") + @ExcludeMissing + canceledPriorToShipDate: JsonField = + JsonMissing.of(), + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + cancellationPolicyProvided: JsonField = + JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + canceledAt, + canceledPriorToShipDate, + cancellationPolicyProvided, + reason, + mutableMapOf(), + ) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Canceled prior to ship date. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledPriorToShipDate(): CanceledPriorToShipDate = + canceledPriorToShipDate.getRequired("canceled_prior_to_ship_date") + + /** + * Cancellation policy provided. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun cancellationPolicyProvided(): CancellationPolicyProvided = + cancellationPolicyProvided.getRequired("cancellation_policy_provided") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * Returns the raw JSON value of [canceledPriorToShipDate]. + * + * Unlike [canceledPriorToShipDate], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("canceled_prior_to_ship_date") + @ExcludeMissing + fun _canceledPriorToShipDate(): JsonField = + canceledPriorToShipDate + + /** + * Returns the raw JSON value of [cancellationPolicyProvided]. + * + * Unlike [cancellationPolicyProvided], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + fun _cancellationPolicyProvided(): JsonField = + cancellationPolicyProvided + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .canceledPriorToShipDate() + * .cancellationPolicyProvided() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var canceledPriorToShipDate: + JsonField? = + null + private var cancellationPolicyProvided: + JsonField? = + null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = + apply { + canceledAt = cardholderCancellation.canceledAt + canceledPriorToShipDate = + cardholderCancellation.canceledPriorToShipDate + cancellationPolicyProvided = + cardholderCancellation.cancellationPolicyProvided + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Canceled prior to ship date. */ + fun canceledPriorToShipDate( + canceledPriorToShipDate: CanceledPriorToShipDate + ) = canceledPriorToShipDate(JsonField.of(canceledPriorToShipDate)) + + /** + * Sets [Builder.canceledPriorToShipDate] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledPriorToShipDate] with a + * well-typed [CanceledPriorToShipDate] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun canceledPriorToShipDate( + canceledPriorToShipDate: JsonField + ) = apply { this.canceledPriorToShipDate = canceledPriorToShipDate } + + /** Cancellation policy provided. */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: CancellationPolicyProvided + ) = cancellationPolicyProvided(JsonField.of(cancellationPolicyProvided)) + + /** + * Sets [Builder.cancellationPolicyProvided] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationPolicyProvided] with a + * well-typed [CancellationPolicyProvided] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: JsonField + ) = apply { + this.cancellationPolicyProvided = cancellationPolicyProvided + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] + * 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .canceledPriorToShipDate() + * .cancellationPolicyProvided() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("canceledAt", canceledAt), + checkRequired( + "canceledPriorToShipDate", + canceledPriorToShipDate, + ), + checkRequired( + "cancellationPolicyProvided", + cancellationPolicyProvided, + ), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + canceledPriorToShipDate().validate() + cancellationPolicyProvided().validate() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (canceledPriorToShipDate.asKnown().getOrNull()?.validity() ?: 0) + + (cancellationPolicyProvided.asKnown().getOrNull()?.validity() + ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Canceled prior to ship date. */ + class CanceledPriorToShipDate + @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 { + + /** Canceled prior to ship date. */ + @JvmField + val CANCELED_PRIOR_TO_SHIP_DATE = of("canceled_prior_to_ship_date") + + /** Not canceled prior to ship date. */ + @JvmField + val NOT_CANCELED_PRIOR_TO_SHIP_DATE = + of("not_canceled_prior_to_ship_date") + + @JvmStatic + fun of(value: String) = CanceledPriorToShipDate(JsonField.of(value)) + } + + /** An enum containing [CanceledPriorToShipDate]'s known values. */ + enum class Known { + /** Canceled prior to ship date. */ + CANCELED_PRIOR_TO_SHIP_DATE, + /** Not canceled prior to ship date. */ + NOT_CANCELED_PRIOR_TO_SHIP_DATE, + } + + /** + * An enum containing [CanceledPriorToShipDate]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [CanceledPriorToShipDate] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Canceled prior to ship date. */ + CANCELED_PRIOR_TO_SHIP_DATE, + /** Not canceled prior to ship date. */ + NOT_CANCELED_PRIOR_TO_SHIP_DATE, + /** + * An enum member indicating that [CanceledPriorToShipDate] 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) { + CANCELED_PRIOR_TO_SHIP_DATE -> Value.CANCELED_PRIOR_TO_SHIP_DATE + NOT_CANCELED_PRIOR_TO_SHIP_DATE -> + Value.NOT_CANCELED_PRIOR_TO_SHIP_DATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + CANCELED_PRIOR_TO_SHIP_DATE -> Known.CANCELED_PRIOR_TO_SHIP_DATE + NOT_CANCELED_PRIOR_TO_SHIP_DATE -> + Known.NOT_CANCELED_PRIOR_TO_SHIP_DATE + else -> + throw IncreaseInvalidDataException( + "Unknown CanceledPriorToShipDate: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CanceledPriorToShipDate = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CanceledPriorToShipDate && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Cancellation policy provided. */ + class CancellationPolicyProvided + @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 { + + /** Not provided. */ + @JvmField val NOT_PROVIDED = of("not_provided") + + /** Provided. */ + @JvmField val PROVIDED = of("provided") + + @JvmStatic + fun of(value: String) = + CancellationPolicyProvided(JsonField.of(value)) + } + + /** An enum containing [CancellationPolicyProvided]'s known values. */ + enum class Known { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + } + + /** + * An enum containing [CancellationPolicyProvided]'s known values, as + * well as an [_UNKNOWN] member. + * + * An instance of [CancellationPolicyProvided] can contain an unknown + * value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + /** + * An enum member indicating that [CancellationPolicyProvided] 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) { + NOT_PROVIDED -> Value.NOT_PROVIDED + PROVIDED -> Value.PROVIDED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + NOT_PROVIDED -> Known.NOT_PROVIDED + PROVIDED -> Known.PROVIDED + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationPolicyProvided: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationPolicyProvided = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationPolicyProvided && 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 CardholderCancellation && + canceledAt == other.canceledAt && + canceledPriorToShipDate == other.canceledPriorToShipDate && + cancellationPolicyProvided == other.cancellationPolicyProvided && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + canceledAt, + canceledPriorToShipDate, + cancellationPolicyProvided, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{canceledAt=$canceledAt, canceledPriorToShipDate=$canceledPriorToShipDate, cancellationPolicyProvided=$cancellationPolicyProvided, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptReason(): AttemptReason = + attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField + val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField + val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic + fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + mutableMapOf(), + ) + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = + merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * Returns the raw JSON value of [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var merchantReceivedReturnAt: JsonField? = null + private var otherExplanation: JsonField? = null + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var trackingNumber: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate?) = + merchantReceivedReturnAt( + JsonField.ofNullable(merchantReceivedReturnAt) + ) + + /** + * Alias for calling [Builder.merchantReceivedReturnAt] with + * `merchantReceivedReturnAt.orElse(null)`. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: Optional + ) = merchantReceivedReturnAt(merchantReceivedReturnAt.getOrNull()) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is + * `other`. + */ + fun otherExplanation(otherExplanation: String?) = + otherExplanation(JsonField.ofNullable(otherExplanation)) + + /** + * Alias for calling [Builder.otherExplanation] with + * `otherExplanation.orElse(null)`. + */ + fun otherExplanation(otherExplanation: Optional) = + otherExplanation(otherExplanation.getOrNull()) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = + returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Tracking number. */ + 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired( + "merchantReceivedReturnAt", + merchantReceivedReturnAt, + ), + checkRequired("otherExplanation", otherExplanation), + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + checkRequired("trackingNumber", trackingNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + merchantReceivedReturnAt() + otherExplanation() + returnMethod().validate() + returnedAt() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, returnMethod=$returnMethod, returnedAt=$returnedAt, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCanceledMerchandise && + cardholderCancellation == other.cardholderCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + notReturned == other.notReturned && + purchaseExplanation == other.purchaseExplanation && + receivedOrExpectedAt == other.receivedOrExpectedAt && + returnAttempted == other.returnAttempted && + returnOutcome == other.returnOutcome && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + merchantResolutionAttempted, + notReturned, + purchaseExplanation, + receivedOrExpectedAt, + returnAttempted, + returnOutcome, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledMerchandise{cardholderCancellation=$cardholderCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, notReturned=$notReturned, purchaseExplanation=$purchaseExplanation, receivedOrExpectedAt=$receivedOrExpectedAt, returnAttempted=$returnAttempted, returnOutcome=$returnOutcome, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Canceled recurring transaction. Present if and only if `category` is + * `consumer_canceled_recurring_transaction`. + */ + class ConsumerCanceledRecurringTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationTarget: JsonField, + private val merchantContactMethods: JsonField, + private val otherFormOfPaymentExplanation: JsonField, + private val transactionOrAccountCanceledAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_target") + @ExcludeMissing + cancellationTarget: JsonField = JsonMissing.of(), + @JsonProperty("merchant_contact_methods") + @ExcludeMissing + merchantContactMethods: JsonField = + JsonMissing.of(), + @JsonProperty("other_form_of_payment_explanation") + @ExcludeMissing + otherFormOfPaymentExplanation: JsonField = JsonMissing.of(), + @JsonProperty("transaction_or_account_canceled_at") + @ExcludeMissing + transactionOrAccountCanceledAt: JsonField = JsonMissing.of(), + ) : this( + cancellationTarget, + merchantContactMethods, + otherFormOfPaymentExplanation, + transactionOrAccountCanceledAt, + mutableMapOf(), + ) + + /** + * Cancellation target. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationTarget(): CancellationTarget = + cancellationTarget.getRequired("cancellation_target") + + /** + * Merchant contact methods. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantContactMethods(): MerchantContactMethods = + merchantContactMethods.getRequired("merchant_contact_methods") + + /** + * Other form of payment explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherFormOfPaymentExplanation(): Optional = + otherFormOfPaymentExplanation.getOptional( + "other_form_of_payment_explanation" + ) + + /** + * Transaction or account canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun transactionOrAccountCanceledAt(): LocalDate = + transactionOrAccountCanceledAt.getRequired( + "transaction_or_account_canceled_at" + ) + + /** + * Returns the raw JSON value of [cancellationTarget]. + * + * Unlike [cancellationTarget], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cancellation_target") + @ExcludeMissing + fun _cancellationTarget(): JsonField = cancellationTarget + + /** + * Returns the raw JSON value of [merchantContactMethods]. + * + * Unlike [merchantContactMethods], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_contact_methods") + @ExcludeMissing + fun _merchantContactMethods(): JsonField = + merchantContactMethods + + /** + * Returns the raw JSON value of [otherFormOfPaymentExplanation]. + * + * Unlike [otherFormOfPaymentExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("other_form_of_payment_explanation") + @ExcludeMissing + fun _otherFormOfPaymentExplanation(): JsonField = + otherFormOfPaymentExplanation + + /** + * Returns the raw JSON value of [transactionOrAccountCanceledAt]. + * + * Unlike [transactionOrAccountCanceledAt], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("transaction_or_account_canceled_at") + @ExcludeMissing + fun _transactionOrAccountCanceledAt(): JsonField = + transactionOrAccountCanceledAt + + @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 + * [ConsumerCanceledRecurringTransaction]. + * + * The following fields are required: + * ```java + * .cancellationTarget() + * .merchantContactMethods() + * .otherFormOfPaymentExplanation() + * .transactionOrAccountCanceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledRecurringTransaction]. */ + class Builder internal constructor() { + + private var cancellationTarget: JsonField? = null + private var merchantContactMethods: JsonField? = + null + private var otherFormOfPaymentExplanation: JsonField? = null + private var transactionOrAccountCanceledAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerCanceledRecurringTransaction: + ConsumerCanceledRecurringTransaction + ) = apply { + cancellationTarget = + consumerCanceledRecurringTransaction.cancellationTarget + merchantContactMethods = + consumerCanceledRecurringTransaction.merchantContactMethods + otherFormOfPaymentExplanation = + consumerCanceledRecurringTransaction.otherFormOfPaymentExplanation + transactionOrAccountCanceledAt = + consumerCanceledRecurringTransaction.transactionOrAccountCanceledAt + additionalProperties = + consumerCanceledRecurringTransaction.additionalProperties + .toMutableMap() + } + + /** Cancellation target. */ + fun cancellationTarget(cancellationTarget: CancellationTarget) = + cancellationTarget(JsonField.of(cancellationTarget)) + + /** + * Sets [Builder.cancellationTarget] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationTarget] with a well-typed + * [CancellationTarget] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cancellationTarget(cancellationTarget: JsonField) = + apply { + this.cancellationTarget = cancellationTarget + } + + /** Merchant contact methods. */ + fun merchantContactMethods(merchantContactMethods: MerchantContactMethods) = + merchantContactMethods(JsonField.of(merchantContactMethods)) + + /** + * Sets [Builder.merchantContactMethods] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantContactMethods] with a + * well-typed [MerchantContactMethods] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantContactMethods( + merchantContactMethods: JsonField + ) = apply { this.merchantContactMethods = merchantContactMethods } + + /** Other form of payment explanation. */ + fun otherFormOfPaymentExplanation(otherFormOfPaymentExplanation: String?) = + otherFormOfPaymentExplanation( + JsonField.ofNullable(otherFormOfPaymentExplanation) + ) + + /** + * Alias for calling [Builder.otherFormOfPaymentExplanation] with + * `otherFormOfPaymentExplanation.orElse(null)`. + */ + fun otherFormOfPaymentExplanation( + otherFormOfPaymentExplanation: Optional + ) = otherFormOfPaymentExplanation(otherFormOfPaymentExplanation.getOrNull()) + + /** + * Sets [Builder.otherFormOfPaymentExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherFormOfPaymentExplanation] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun otherFormOfPaymentExplanation( + otherFormOfPaymentExplanation: JsonField + ) = apply { + this.otherFormOfPaymentExplanation = otherFormOfPaymentExplanation + } + + /** Transaction or account canceled at. */ + fun transactionOrAccountCanceledAt( + transactionOrAccountCanceledAt: LocalDate + ) = + transactionOrAccountCanceledAt( + JsonField.of(transactionOrAccountCanceledAt) + ) + + /** + * Sets [Builder.transactionOrAccountCanceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionOrAccountCanceledAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun transactionOrAccountCanceledAt( + transactionOrAccountCanceledAt: JsonField + ) = apply { + this.transactionOrAccountCanceledAt = transactionOrAccountCanceledAt + } + + 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 [ConsumerCanceledRecurringTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationTarget() + * .merchantContactMethods() + * .otherFormOfPaymentExplanation() + * .transactionOrAccountCanceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledRecurringTransaction = + ConsumerCanceledRecurringTransaction( + checkRequired("cancellationTarget", cancellationTarget), + checkRequired("merchantContactMethods", merchantContactMethods), + checkRequired( + "otherFormOfPaymentExplanation", + otherFormOfPaymentExplanation, + ), + checkRequired( + "transactionOrAccountCanceledAt", + transactionOrAccountCanceledAt, + ), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledRecurringTransaction = apply { + if (validated) { + return@apply + } + + cancellationTarget().validate() + merchantContactMethods().validate() + otherFormOfPaymentExplanation() + transactionOrAccountCanceledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationTarget.asKnown().getOrNull()?.validity() ?: 0) + + (merchantContactMethods.asKnown().getOrNull()?.validity() ?: 0) + + (if (otherFormOfPaymentExplanation.asKnown().isPresent) 1 else 0) + + (if (transactionOrAccountCanceledAt.asKnown().isPresent) 1 else 0) + + /** Cancellation target. */ + class CancellationTarget + @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 { + + /** Account. */ + @JvmField val ACCOUNT = of("account") + + /** Transaction. */ + @JvmField val TRANSACTION = of("transaction") + + @JvmStatic + fun of(value: String) = CancellationTarget(JsonField.of(value)) + } + + /** An enum containing [CancellationTarget]'s known values. */ + enum class Known { + /** Account. */ + ACCOUNT, + /** Transaction. */ + TRANSACTION, + } + + /** + * An enum containing [CancellationTarget]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CancellationTarget] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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. */ + ACCOUNT, + /** Transaction. */ + TRANSACTION, + /** + * An enum member indicating that [CancellationTarget] 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 -> Value.ACCOUNT + 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 IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ACCOUNT -> Known.ACCOUNT + TRANSACTION -> Known.TRANSACTION + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationTarget: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationTarget = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationTarget && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant contact methods. */ + class MerchantContactMethods + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val applicationName: JsonField, + private val callCenterPhoneNumber: JsonField, + private val emailAddress: JsonField, + private val inPersonAddress: JsonField, + private val mailingAddress: JsonField, + private val textPhoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("application_name") + @ExcludeMissing + applicationName: JsonField = JsonMissing.of(), + @JsonProperty("call_center_phone_number") + @ExcludeMissing + callCenterPhoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("email_address") + @ExcludeMissing + emailAddress: JsonField = JsonMissing.of(), + @JsonProperty("in_person_address") + @ExcludeMissing + inPersonAddress: JsonField = JsonMissing.of(), + @JsonProperty("mailing_address") + @ExcludeMissing + mailingAddress: JsonField = JsonMissing.of(), + @JsonProperty("text_phone_number") + @ExcludeMissing + textPhoneNumber: JsonField = JsonMissing.of(), + ) : this( + applicationName, + callCenterPhoneNumber, + emailAddress, + inPersonAddress, + mailingAddress, + textPhoneNumber, + mutableMapOf(), + ) + + /** + * Application name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun applicationName(): Optional = + applicationName.getOptional("application_name") + + /** + * Call center phone number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun callCenterPhoneNumber(): Optional = + callCenterPhoneNumber.getOptional("call_center_phone_number") + + /** + * Email address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun emailAddress(): Optional = + emailAddress.getOptional("email_address") + + /** + * In person address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun inPersonAddress(): Optional = + inPersonAddress.getOptional("in_person_address") + + /** + * Mailing address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun mailingAddress(): Optional = + mailingAddress.getOptional("mailing_address") + + /** + * Text phone number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun textPhoneNumber(): Optional = + textPhoneNumber.getOptional("text_phone_number") + + /** + * Returns the raw JSON value of [applicationName]. + * + * Unlike [applicationName], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("application_name") + @ExcludeMissing + fun _applicationName(): JsonField = applicationName + + /** + * Returns the raw JSON value of [callCenterPhoneNumber]. + * + * Unlike [callCenterPhoneNumber], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("call_center_phone_number") + @ExcludeMissing + fun _callCenterPhoneNumber(): JsonField = callCenterPhoneNumber + + /** + * Returns the raw JSON value of [emailAddress]. + * + * Unlike [emailAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("email_address") + @ExcludeMissing + fun _emailAddress(): JsonField = emailAddress + + /** + * Returns the raw JSON value of [inPersonAddress]. + * + * Unlike [inPersonAddress], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("in_person_address") + @ExcludeMissing + fun _inPersonAddress(): JsonField = inPersonAddress + + /** + * Returns the raw JSON value of [mailingAddress]. + * + * Unlike [mailingAddress], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("mailing_address") + @ExcludeMissing + fun _mailingAddress(): JsonField = mailingAddress + + /** + * Returns the raw JSON value of [textPhoneNumber]. + * + * Unlike [textPhoneNumber], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("text_phone_number") + @ExcludeMissing + fun _textPhoneNumber(): JsonField = textPhoneNumber + + @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 + * [MerchantContactMethods]. + * + * The following fields are required: + * ```java + * .applicationName() + * .callCenterPhoneNumber() + * .emailAddress() + * .inPersonAddress() + * .mailingAddress() + * .textPhoneNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantContactMethods]. */ + class Builder internal constructor() { + + private var applicationName: JsonField? = null + private var callCenterPhoneNumber: JsonField? = null + private var emailAddress: JsonField? = null + private var inPersonAddress: JsonField? = null + private var mailingAddress: JsonField? = null + private var textPhoneNumber: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(merchantContactMethods: MerchantContactMethods) = + apply { + applicationName = merchantContactMethods.applicationName + callCenterPhoneNumber = + merchantContactMethods.callCenterPhoneNumber + emailAddress = merchantContactMethods.emailAddress + inPersonAddress = merchantContactMethods.inPersonAddress + mailingAddress = merchantContactMethods.mailingAddress + textPhoneNumber = merchantContactMethods.textPhoneNumber + additionalProperties = + merchantContactMethods.additionalProperties.toMutableMap() + } + + /** Application name. */ + fun applicationName(applicationName: String?) = + applicationName(JsonField.ofNullable(applicationName)) + + /** + * Alias for calling [Builder.applicationName] with + * `applicationName.orElse(null)`. + */ + fun applicationName(applicationName: Optional) = + applicationName(applicationName.getOrNull()) + + /** + * Sets [Builder.applicationName] to an arbitrary JSON value. + * + * You should usually call [Builder.applicationName] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun applicationName(applicationName: JsonField) = apply { + this.applicationName = applicationName + } + + /** Call center phone number. */ + fun callCenterPhoneNumber(callCenterPhoneNumber: String?) = + callCenterPhoneNumber(JsonField.ofNullable(callCenterPhoneNumber)) + + /** + * Alias for calling [Builder.callCenterPhoneNumber] with + * `callCenterPhoneNumber.orElse(null)`. + */ + fun callCenterPhoneNumber(callCenterPhoneNumber: Optional) = + callCenterPhoneNumber(callCenterPhoneNumber.getOrNull()) + + /** + * Sets [Builder.callCenterPhoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.callCenterPhoneNumber] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun callCenterPhoneNumber(callCenterPhoneNumber: JsonField) = + apply { + this.callCenterPhoneNumber = callCenterPhoneNumber + } + + /** Email address. */ + fun emailAddress(emailAddress: String?) = + emailAddress(JsonField.ofNullable(emailAddress)) + + /** + * Alias for calling [Builder.emailAddress] with + * `emailAddress.orElse(null)`. + */ + fun emailAddress(emailAddress: Optional) = + emailAddress(emailAddress.getOrNull()) + + /** + * Sets [Builder.emailAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.emailAddress] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun emailAddress(emailAddress: JsonField) = apply { + this.emailAddress = emailAddress + } + + /** In person address. */ + fun inPersonAddress(inPersonAddress: String?) = + inPersonAddress(JsonField.ofNullable(inPersonAddress)) + + /** + * Alias for calling [Builder.inPersonAddress] with + * `inPersonAddress.orElse(null)`. + */ + fun inPersonAddress(inPersonAddress: Optional) = + inPersonAddress(inPersonAddress.getOrNull()) + + /** + * Sets [Builder.inPersonAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.inPersonAddress] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun inPersonAddress(inPersonAddress: JsonField) = apply { + this.inPersonAddress = inPersonAddress + } + + /** Mailing address. */ + fun mailingAddress(mailingAddress: String?) = + mailingAddress(JsonField.ofNullable(mailingAddress)) + + /** + * Alias for calling [Builder.mailingAddress] with + * `mailingAddress.orElse(null)`. + */ + fun mailingAddress(mailingAddress: Optional) = + mailingAddress(mailingAddress.getOrNull()) + + /** + * Sets [Builder.mailingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.mailingAddress] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun mailingAddress(mailingAddress: JsonField) = apply { + this.mailingAddress = mailingAddress + } + + /** Text phone number. */ + fun textPhoneNumber(textPhoneNumber: String?) = + textPhoneNumber(JsonField.ofNullable(textPhoneNumber)) + + /** + * Alias for calling [Builder.textPhoneNumber] with + * `textPhoneNumber.orElse(null)`. + */ + fun textPhoneNumber(textPhoneNumber: Optional) = + textPhoneNumber(textPhoneNumber.getOrNull()) + + /** + * Sets [Builder.textPhoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.textPhoneNumber] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun textPhoneNumber(textPhoneNumber: JsonField) = apply { + this.textPhoneNumber = textPhoneNumber + } + + 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 [MerchantContactMethods]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .applicationName() + * .callCenterPhoneNumber() + * .emailAddress() + * .inPersonAddress() + * .mailingAddress() + * .textPhoneNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantContactMethods = + MerchantContactMethods( + checkRequired("applicationName", applicationName), + checkRequired("callCenterPhoneNumber", callCenterPhoneNumber), + checkRequired("emailAddress", emailAddress), + checkRequired("inPersonAddress", inPersonAddress), + checkRequired("mailingAddress", mailingAddress), + checkRequired("textPhoneNumber", textPhoneNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantContactMethods = apply { + if (validated) { + return@apply + } + + applicationName() + callCenterPhoneNumber() + emailAddress() + inPersonAddress() + mailingAddress() + textPhoneNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (applicationName.asKnown().isPresent) 1 else 0) + + (if (callCenterPhoneNumber.asKnown().isPresent) 1 else 0) + + (if (emailAddress.asKnown().isPresent) 1 else 0) + + (if (inPersonAddress.asKnown().isPresent) 1 else 0) + + (if (mailingAddress.asKnown().isPresent) 1 else 0) + + (if (textPhoneNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantContactMethods && + applicationName == other.applicationName && + callCenterPhoneNumber == other.callCenterPhoneNumber && + emailAddress == other.emailAddress && + inPersonAddress == other.inPersonAddress && + mailingAddress == other.mailingAddress && + textPhoneNumber == other.textPhoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + applicationName, + callCenterPhoneNumber, + emailAddress, + inPersonAddress, + mailingAddress, + textPhoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantContactMethods{applicationName=$applicationName, callCenterPhoneNumber=$callCenterPhoneNumber, emailAddress=$emailAddress, inPersonAddress=$inPersonAddress, mailingAddress=$mailingAddress, textPhoneNumber=$textPhoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCanceledRecurringTransaction && + cancellationTarget == other.cancellationTarget && + merchantContactMethods == other.merchantContactMethods && + otherFormOfPaymentExplanation == other.otherFormOfPaymentExplanation && + transactionOrAccountCanceledAt == + other.transactionOrAccountCanceledAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationTarget, + merchantContactMethods, + otherFormOfPaymentExplanation, + transactionOrAccountCanceledAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledRecurringTransaction{cancellationTarget=$cancellationTarget, merchantContactMethods=$merchantContactMethods, otherFormOfPaymentExplanation=$otherFormOfPaymentExplanation, transactionOrAccountCanceledAt=$transactionOrAccountCanceledAt, additionalProperties=$additionalProperties}" + } + + /** + * Canceled services. Present if and only if `category` is + * `consumer_canceled_services`. + */ + class ConsumerCanceledServices + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val contractedAt: JsonField, + private val guaranteedReservation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val other: JsonValue, + private val purchaseExplanation: JsonField, + private val serviceType: JsonField, + private val timeshare: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = + JsonMissing.of(), + @JsonProperty("contracted_at") + @ExcludeMissing + contractedAt: JsonField = JsonMissing.of(), + @JsonProperty("guaranteed_reservation") + @ExcludeMissing + guaranteedReservation: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("other") @ExcludeMissing other: JsonValue = JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("service_type") + @ExcludeMissing + serviceType: JsonField = JsonMissing.of(), + @JsonProperty("timeshare") + @ExcludeMissing + timeshare: JsonValue = JsonMissing.of(), + ) : this( + cardholderCancellation, + contractedAt, + guaranteedReservation, + merchantResolutionAttempted, + other, + purchaseExplanation, + serviceType, + timeshare, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Contracted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun contractedAt(): LocalDate = contractedAt.getRequired("contracted_at") + + /** + * Guaranteed reservation explanation. Present if and only if `service_type` is + * `guaranteed_reservation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun guaranteedReservation(): Optional = + guaranteedReservation.getOptional("guaranteed_reservation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Other service type explanation. Present if and only if `service_type` is + * `other`. + */ + @JsonProperty("other") @ExcludeMissing fun _other(): JsonValue = other + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Service type. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceType(): ServiceType = serviceType.getRequired("service_type") + + /** + * Timeshare explanation. Present if and only if `service_type` is `timeshare`. + */ + @JsonProperty("timeshare") + @ExcludeMissing + fun _timeshare(): JsonValue = timeshare + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [contractedAt]. + * + * Unlike [contractedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("contracted_at") + @ExcludeMissing + fun _contractedAt(): JsonField = contractedAt + + /** + * Returns the raw JSON value of [guaranteedReservation]. + * + * Unlike [guaranteedReservation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("guaranteed_reservation") + @ExcludeMissing + fun _guaranteedReservation(): JsonField = + guaranteedReservation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [serviceType]. + * + * Unlike [serviceType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_type") + @ExcludeMissing + fun _serviceType(): JsonField = serviceType + + @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 + * [ConsumerCanceledServices]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .contractedAt() + * .guaranteedReservation() + * .merchantResolutionAttempted() + * .other() + * .purchaseExplanation() + * .serviceType() + * .timeshare() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledServices]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = + null + private var contractedAt: JsonField? = null + private var guaranteedReservation: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var other: JsonValue? = null + private var purchaseExplanation: JsonField? = null + private var serviceType: JsonField? = null + private var timeshare: JsonValue? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCanceledServices: ConsumerCanceledServices) = + apply { + cardholderCancellation = + consumerCanceledServices.cardholderCancellation + contractedAt = consumerCanceledServices.contractedAt + guaranteedReservation = + consumerCanceledServices.guaranteedReservation + merchantResolutionAttempted = + consumerCanceledServices.merchantResolutionAttempted + other = consumerCanceledServices.other + purchaseExplanation = consumerCanceledServices.purchaseExplanation + serviceType = consumerCanceledServices.serviceType + timeshare = consumerCanceledServices.timeshare + additionalProperties = + consumerCanceledServices.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a + * well-typed [CardholderCancellation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Contracted at. */ + fun contractedAt(contractedAt: LocalDate) = + contractedAt(JsonField.of(contractedAt)) + + /** + * Sets [Builder.contractedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.contractedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun contractedAt(contractedAt: JsonField) = apply { + this.contractedAt = contractedAt + } + + /** + * Guaranteed reservation explanation. Present if and only if `service_type` + * is `guaranteed_reservation`. + */ + fun guaranteedReservation(guaranteedReservation: GuaranteedReservation?) = + guaranteedReservation(JsonField.ofNullable(guaranteedReservation)) + + /** + * Alias for calling [Builder.guaranteedReservation] with + * `guaranteedReservation.orElse(null)`. + */ + fun guaranteedReservation( + guaranteedReservation: Optional + ) = guaranteedReservation(guaranteedReservation.getOrNull()) + + /** + * Sets [Builder.guaranteedReservation] to an arbitrary JSON value. + * + * You should usually call [Builder.guaranteedReservation] with a well-typed + * [GuaranteedReservation] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun guaranteedReservation( + guaranteedReservation: JsonField + ) = apply { this.guaranteedReservation = guaranteedReservation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * Other service type explanation. Present if and only if `service_type` is + * `other`. + */ + fun other(other: JsonValue) = apply { this.other = other } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Service type. */ + fun serviceType(serviceType: ServiceType) = + serviceType(JsonField.of(serviceType)) + + /** + * Sets [Builder.serviceType] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceType] with a well-typed + * [ServiceType] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun serviceType(serviceType: JsonField) = apply { + this.serviceType = serviceType + } + + /** + * Timeshare explanation. Present if and only if `service_type` is + * `timeshare`. + */ + fun timeshare(timeshare: JsonValue) = apply { this.timeshare = timeshare } + + 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 [ConsumerCanceledServices]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .contractedAt() + * .guaranteedReservation() + * .merchantResolutionAttempted() + * .other() + * .purchaseExplanation() + * .serviceType() + * .timeshare() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledServices = + ConsumerCanceledServices( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired("contractedAt", contractedAt), + checkRequired("guaranteedReservation", guaranteedReservation), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("other", other), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("serviceType", serviceType), + checkRequired("timeshare", timeshare), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledServices = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + contractedAt() + guaranteedReservation().ifPresent { it.validate() } + merchantResolutionAttempted().validate() + purchaseExplanation() + serviceType().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (if (contractedAt.asKnown().isPresent) 1 else 0) + + (guaranteedReservation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (serviceType.asKnown().getOrNull()?.validity() ?: 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val cancellationPolicyProvided: + JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + cancellationPolicyProvided: JsonField = + JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, cancellationPolicyProvided, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Cancellation policy provided. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun cancellationPolicyProvided(): CancellationPolicyProvided = + cancellationPolicyProvided.getRequired("cancellation_policy_provided") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * Returns the raw JSON value of [cancellationPolicyProvided]. + * + * Unlike [cancellationPolicyProvided], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + fun _cancellationPolicyProvided(): JsonField = + cancellationPolicyProvided + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .cancellationPolicyProvided() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var cancellationPolicyProvided: + JsonField? = + null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = + apply { + canceledAt = cardholderCancellation.canceledAt + cancellationPolicyProvided = + cardholderCancellation.cancellationPolicyProvided + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Cancellation policy provided. */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: CancellationPolicyProvided + ) = cancellationPolicyProvided(JsonField.of(cancellationPolicyProvided)) + + /** + * Sets [Builder.cancellationPolicyProvided] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationPolicyProvided] with a + * well-typed [CancellationPolicyProvided] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: JsonField + ) = apply { + this.cancellationPolicyProvided = cancellationPolicyProvided + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] + * 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .cancellationPolicyProvided() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("canceledAt", canceledAt), + checkRequired( + "cancellationPolicyProvided", + cancellationPolicyProvided, + ), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + cancellationPolicyProvided().validate() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (cancellationPolicyProvided.asKnown().getOrNull()?.validity() + ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Cancellation policy provided. */ + class CancellationPolicyProvided + @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 { + + /** Not provided. */ + @JvmField val NOT_PROVIDED = of("not_provided") + + /** Provided. */ + @JvmField val PROVIDED = of("provided") + + @JvmStatic + fun of(value: String) = + CancellationPolicyProvided(JsonField.of(value)) + } + + /** An enum containing [CancellationPolicyProvided]'s known values. */ + enum class Known { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + } + + /** + * An enum containing [CancellationPolicyProvided]'s known values, as + * well as an [_UNKNOWN] member. + * + * An instance of [CancellationPolicyProvided] can contain an unknown + * value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + /** + * An enum member indicating that [CancellationPolicyProvided] 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) { + NOT_PROVIDED -> Value.NOT_PROVIDED + PROVIDED -> Value.PROVIDED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + NOT_PROVIDED -> Known.NOT_PROVIDED + PROVIDED -> Known.PROVIDED + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationPolicyProvided: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationPolicyProvided = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationPolicyProvided && 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 CardholderCancellation && + canceledAt == other.canceledAt && + cancellationPolicyProvided == other.cancellationPolicyProvided && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + canceledAt, + cancellationPolicyProvided, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{canceledAt=$canceledAt, cancellationPolicyProvided=$cancellationPolicyProvided, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Guaranteed reservation explanation. Present if and only if `service_type` is + * `guaranteed_reservation`. + */ + class GuaranteedReservation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun explanation(): Explanation = explanation.getRequired("explanation") + + /** + * 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 + + @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 + * [GuaranteedReservation]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GuaranteedReservation]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(guaranteedReservation: GuaranteedReservation) = + apply { + explanation = guaranteedReservation.explanation + additionalProperties = + guaranteedReservation.additionalProperties.toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: Explanation) = + explanation(JsonField.of(explanation)) + + /** + * Sets [Builder.explanation] to an arbitrary JSON value. + * + * You should usually call [Builder.explanation] with a well-typed + * [Explanation] 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 + } + + 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 [GuaranteedReservation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GuaranteedReservation = + GuaranteedReservation( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GuaranteedReservation = apply { + if (validated) { + return@apply + } + + explanation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (explanation.asKnown().getOrNull()?.validity() ?: 0) + + /** Explanation. */ + class Explanation + @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 { + + /** Cardholder canceled prior to service. */ + @JvmField + val CARDHOLDER_CANCELED_PRIOR_TO_SERVICE = + of("cardholder_canceled_prior_to_service") + + /** + * Cardholder cancellation attempt within 24 hours of confirmation. + */ + @JvmField + val CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION = + of( + "cardholder_cancellation_attempt_within_24_hours_of_confirmation" + ) + + /** Merchant billed for no-show. */ + @JvmField + val MERCHANT_BILLED_NO_SHOW = of("merchant_billed_no_show") + + @JvmStatic fun of(value: String) = Explanation(JsonField.of(value)) + } + + /** An enum containing [Explanation]'s known values. */ + enum class Known { + /** Cardholder canceled prior to service. */ + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE, + /** + * Cardholder cancellation attempt within 24 hours of confirmation. + */ + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION, + /** Merchant billed for no-show. */ + MERCHANT_BILLED_NO_SHOW, + } + + /** + * An enum containing [Explanation]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [Explanation] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may 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 canceled prior to service. */ + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE, + /** + * Cardholder cancellation attempt within 24 hours of confirmation. + */ + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION, + /** Merchant billed for no-show. */ + MERCHANT_BILLED_NO_SHOW, + /** + * An enum member indicating that [Explanation] 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_CANCELED_PRIOR_TO_SERVICE -> + Value.CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION -> + Value + .CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION + MERCHANT_BILLED_NO_SHOW -> Value.MERCHANT_BILLED_NO_SHOW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE -> + Known.CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION -> + Known + .CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION + MERCHANT_BILLED_NO_SHOW -> Known.MERCHANT_BILLED_NO_SHOW + else -> + throw IncreaseInvalidDataException( + "Unknown Explanation: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Explanation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Explanation && 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 GuaranteedReservation && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GuaranteedReservation{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Service type. */ + class ServiceType + @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 { + + /** Guaranteed reservation. */ + @JvmField val GUARANTEED_RESERVATION = of("guaranteed_reservation") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Timeshare. */ + @JvmField val TIMESHARE = of("timeshare") + + @JvmStatic fun of(value: String) = ServiceType(JsonField.of(value)) + } + + /** An enum containing [ServiceType]'s known values. */ + enum class Known { + /** Guaranteed reservation. */ + GUARANTEED_RESERVATION, + /** Other. */ + OTHER, + /** Timeshare. */ + TIMESHARE, + } + + /** + * An enum containing [ServiceType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ServiceType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Guaranteed reservation. */ + GUARANTEED_RESERVATION, + /** Other. */ + OTHER, + /** Timeshare. */ + TIMESHARE, + /** + * An enum member indicating that [ServiceType] 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) { + GUARANTEED_RESERVATION -> Value.GUARANTEED_RESERVATION + OTHER -> Value.OTHER + TIMESHARE -> Value.TIMESHARE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_RESERVATION -> Known.GUARANTEED_RESERVATION + OTHER -> Known.OTHER + TIMESHARE -> Known.TIMESHARE + else -> + throw IncreaseInvalidDataException( + "Unknown ServiceType: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ServiceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceType && 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 ConsumerCanceledServices && + cardholderCancellation == other.cardholderCancellation && + contractedAt == other.contractedAt && + guaranteedReservation == other.guaranteedReservation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + this.other == other.other && + purchaseExplanation == other.purchaseExplanation && + serviceType == other.serviceType && + timeshare == other.timeshare && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + contractedAt, + guaranteedReservation, + merchantResolutionAttempted, + other, + purchaseExplanation, + serviceType, + timeshare, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledServices{cardholderCancellation=$cardholderCancellation, contractedAt=$contractedAt, guaranteedReservation=$guaranteedReservation, merchantResolutionAttempted=$merchantResolutionAttempted, other=$other, purchaseExplanation=$purchaseExplanation, serviceType=$serviceType, timeshare=$timeshare, additionalProperties=$additionalProperties}" + } + + /** + * Counterfeit merchandise. Present if and only if `category` is + * `consumer_counterfeit_merchandise`. + */ + class ConsumerCounterfeitMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val counterfeitExplanation: JsonField, + private val dispositionExplanation: JsonField, + private val orderExplanation: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("counterfeit_explanation") + @ExcludeMissing + counterfeitExplanation: JsonField = JsonMissing.of(), + @JsonProperty("disposition_explanation") + @ExcludeMissing + dispositionExplanation: JsonField = JsonMissing.of(), + @JsonProperty("order_explanation") + @ExcludeMissing + orderExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + counterfeitExplanation, + dispositionExplanation, + orderExplanation, + receivedAt, + mutableMapOf(), + ) + + /** + * Counterfeit explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun counterfeitExplanation(): String = + counterfeitExplanation.getRequired("counterfeit_explanation") + + /** + * Disposition explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dispositionExplanation(): String = + dispositionExplanation.getRequired("disposition_explanation") + + /** + * Order explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun orderExplanation(): String = + orderExplanation.getRequired("order_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [counterfeitExplanation]. + * + * Unlike [counterfeitExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("counterfeit_explanation") + @ExcludeMissing + fun _counterfeitExplanation(): JsonField = counterfeitExplanation + + /** + * Returns the raw JSON value of [dispositionExplanation]. + * + * Unlike [dispositionExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("disposition_explanation") + @ExcludeMissing + fun _dispositionExplanation(): JsonField = dispositionExplanation + + /** + * Returns the raw JSON value of [orderExplanation]. + * + * Unlike [orderExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("order_explanation") + @ExcludeMissing + fun _orderExplanation(): JsonField = orderExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerCounterfeitMerchandise]. + * + * The following fields are required: + * ```java + * .counterfeitExplanation() + * .dispositionExplanation() + * .orderExplanation() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCounterfeitMerchandise]. */ + class Builder internal constructor() { + + private var counterfeitExplanation: JsonField? = null + private var dispositionExplanation: JsonField? = null + private var orderExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerCounterfeitMerchandise: ConsumerCounterfeitMerchandise + ) = apply { + counterfeitExplanation = + consumerCounterfeitMerchandise.counterfeitExplanation + dispositionExplanation = + consumerCounterfeitMerchandise.dispositionExplanation + orderExplanation = consumerCounterfeitMerchandise.orderExplanation + receivedAt = consumerCounterfeitMerchandise.receivedAt + additionalProperties = + consumerCounterfeitMerchandise.additionalProperties.toMutableMap() + } + + /** Counterfeit explanation. */ + fun counterfeitExplanation(counterfeitExplanation: String) = + counterfeitExplanation(JsonField.of(counterfeitExplanation)) + + /** + * Sets [Builder.counterfeitExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.counterfeitExplanation] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun counterfeitExplanation(counterfeitExplanation: JsonField) = + apply { + this.counterfeitExplanation = counterfeitExplanation + } + + /** Disposition explanation. */ + fun dispositionExplanation(dispositionExplanation: String) = + dispositionExplanation(JsonField.of(dispositionExplanation)) + + /** + * Sets [Builder.dispositionExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.dispositionExplanation] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun dispositionExplanation(dispositionExplanation: JsonField) = + apply { + this.dispositionExplanation = dispositionExplanation + } + + /** Order explanation. */ + fun orderExplanation(orderExplanation: String) = + orderExplanation(JsonField.of(orderExplanation)) + + /** + * Sets [Builder.orderExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.orderExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun orderExplanation(orderExplanation: JsonField) = apply { + this.orderExplanation = orderExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerCounterfeitMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .counterfeitExplanation() + * .dispositionExplanation() + * .orderExplanation() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCounterfeitMerchandise = + ConsumerCounterfeitMerchandise( + checkRequired("counterfeitExplanation", counterfeitExplanation), + checkRequired("dispositionExplanation", dispositionExplanation), + checkRequired("orderExplanation", orderExplanation), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCounterfeitMerchandise = apply { + if (validated) { + return@apply + } + + counterfeitExplanation() + dispositionExplanation() + orderExplanation() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (counterfeitExplanation.asKnown().isPresent) 1 else 0) + + (if (dispositionExplanation.asKnown().isPresent) 1 else 0) + + (if (orderExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCounterfeitMerchandise && + counterfeitExplanation == other.counterfeitExplanation && + dispositionExplanation == other.dispositionExplanation && + orderExplanation == other.orderExplanation && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + counterfeitExplanation, + dispositionExplanation, + orderExplanation, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCounterfeitMerchandise{counterfeitExplanation=$counterfeitExplanation, dispositionExplanation=$dispositionExplanation, orderExplanation=$orderExplanation, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Credit not processed. Present if and only if `category` is + * `consumer_credit_not_processed`. + */ + class ConsumerCreditNotProcessed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledOrReturnedAt: JsonField, + private val creditExpectedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_or_returned_at") + @ExcludeMissing + canceledOrReturnedAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_expected_at") + @ExcludeMissing + creditExpectedAt: JsonField = JsonMissing.of(), + ) : this(canceledOrReturnedAt, creditExpectedAt, mutableMapOf()) + + /** + * Canceled or returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun canceledOrReturnedAt(): Optional = + canceledOrReturnedAt.getOptional("canceled_or_returned_at") + + /** + * Credit expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun creditExpectedAt(): Optional = + creditExpectedAt.getOptional("credit_expected_at") + + /** + * Returns the raw JSON value of [canceledOrReturnedAt]. + * + * Unlike [canceledOrReturnedAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("canceled_or_returned_at") + @ExcludeMissing + fun _canceledOrReturnedAt(): JsonField = canceledOrReturnedAt + + /** + * Returns the raw JSON value of [creditExpectedAt]. + * + * Unlike [creditExpectedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credit_expected_at") + @ExcludeMissing + fun _creditExpectedAt(): JsonField = creditExpectedAt + + @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 + * [ConsumerCreditNotProcessed]. + * + * The following fields are required: + * ```java + * .canceledOrReturnedAt() + * .creditExpectedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCreditNotProcessed]. */ + class Builder internal constructor() { + + private var canceledOrReturnedAt: JsonField? = null + private var creditExpectedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCreditNotProcessed: ConsumerCreditNotProcessed) = + apply { + canceledOrReturnedAt = + consumerCreditNotProcessed.canceledOrReturnedAt + creditExpectedAt = consumerCreditNotProcessed.creditExpectedAt + additionalProperties = + consumerCreditNotProcessed.additionalProperties.toMutableMap() + } + + /** Canceled or returned at. */ + fun canceledOrReturnedAt(canceledOrReturnedAt: LocalDate?) = + canceledOrReturnedAt(JsonField.ofNullable(canceledOrReturnedAt)) + + /** + * Alias for calling [Builder.canceledOrReturnedAt] with + * `canceledOrReturnedAt.orElse(null)`. + */ + fun canceledOrReturnedAt(canceledOrReturnedAt: Optional) = + canceledOrReturnedAt(canceledOrReturnedAt.getOrNull()) + + /** + * Sets [Builder.canceledOrReturnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledOrReturnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledOrReturnedAt(canceledOrReturnedAt: JsonField) = + apply { + this.canceledOrReturnedAt = canceledOrReturnedAt + } + + /** Credit expected at. */ + fun creditExpectedAt(creditExpectedAt: LocalDate?) = + creditExpectedAt(JsonField.ofNullable(creditExpectedAt)) + + /** + * Alias for calling [Builder.creditExpectedAt] with + * `creditExpectedAt.orElse(null)`. + */ + fun creditExpectedAt(creditExpectedAt: Optional) = + creditExpectedAt(creditExpectedAt.getOrNull()) + + /** + * Sets [Builder.creditExpectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.creditExpectedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun creditExpectedAt(creditExpectedAt: JsonField) = apply { + this.creditExpectedAt = creditExpectedAt + } + + 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 [ConsumerCreditNotProcessed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledOrReturnedAt() + * .creditExpectedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCreditNotProcessed = + ConsumerCreditNotProcessed( + checkRequired("canceledOrReturnedAt", canceledOrReturnedAt), + checkRequired("creditExpectedAt", creditExpectedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCreditNotProcessed = apply { + if (validated) { + return@apply + } + + canceledOrReturnedAt() + creditExpectedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledOrReturnedAt.asKnown().isPresent) 1 else 0) + + (if (creditExpectedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCreditNotProcessed && + canceledOrReturnedAt == other.canceledOrReturnedAt && + creditExpectedAt == other.creditExpectedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledOrReturnedAt, creditExpectedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCreditNotProcessed{canceledOrReturnedAt=$canceledOrReturnedAt, creditExpectedAt=$creditExpectedAt, additionalProperties=$additionalProperties}" + } + + /** + * Damaged or defective merchandise. Present if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + */ + class ConsumerDamagedOrDefectiveMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val notReturned: JsonValue, + private val orderAndIssueExplanation: JsonField, + private val receivedAt: JsonField, + private val returnAttempted: JsonField, + private val returnOutcome: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("order_and_issue_explanation") + @ExcludeMissing + orderAndIssueExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + notReturned, + orderAndIssueExplanation, + receivedAt, + returnAttempted, + returnOutcome, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** Not returned. Present if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Order and issue explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun orderAndIssueExplanation(): String = + orderAndIssueExplanation.getRequired("order_and_issue_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Returned. Present if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [orderAndIssueExplanation]. + * + * Unlike [orderAndIssueExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("order_and_issue_explanation") + @ExcludeMissing + fun _orderAndIssueExplanation(): JsonField = orderAndIssueExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerDamagedOrDefectiveMerchandise]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .notReturned() + * .orderAndIssueExplanation() + * .receivedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerDamagedOrDefectiveMerchandise]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: + JsonField? = + null + private var notReturned: JsonValue? = null + private var orderAndIssueExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var returnAttempted: JsonField? = null + private var returnOutcome: JsonField? = null + private var returned: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerDamagedOrDefectiveMerchandise: + ConsumerDamagedOrDefectiveMerchandise + ) = apply { + merchantResolutionAttempted = + consumerDamagedOrDefectiveMerchandise.merchantResolutionAttempted + notReturned = consumerDamagedOrDefectiveMerchandise.notReturned + orderAndIssueExplanation = + consumerDamagedOrDefectiveMerchandise.orderAndIssueExplanation + receivedAt = consumerDamagedOrDefectiveMerchandise.receivedAt + returnAttempted = consumerDamagedOrDefectiveMerchandise.returnAttempted + returnOutcome = consumerDamagedOrDefectiveMerchandise.returnOutcome + returned = consumerDamagedOrDefectiveMerchandise.returned + additionalProperties = + consumerDamagedOrDefectiveMerchandise.additionalProperties + .toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * Not returned. Present if and only if `return_outcome` is `not_returned`. + */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** Order and issue explanation. */ + fun orderAndIssueExplanation(orderAndIssueExplanation: String) = + orderAndIssueExplanation(JsonField.of(orderAndIssueExplanation)) + + /** + * Sets [Builder.orderAndIssueExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.orderAndIssueExplanation] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun orderAndIssueExplanation(orderAndIssueExplanation: JsonField) = + apply { + this.orderAndIssueExplanation = orderAndIssueExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted?) = + returnAttempted(JsonField.ofNullable(returnAttempted)) + + /** + * Alias for calling [Builder.returnAttempted] with + * `returnAttempted.orElse(null)`. + */ + fun returnAttempted(returnAttempted: Optional) = + returnAttempted(returnAttempted.getOrNull()) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned?) = returned(JsonField.ofNullable(returned)) + + /** Alias for calling [Builder.returned] with `returned.orElse(null)`. */ + fun returned(returned: Optional) = returned(returned.getOrNull()) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returned(returned: JsonField) = apply { + this.returned = returned + } + + 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 [ConsumerDamagedOrDefectiveMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .notReturned() + * .orderAndIssueExplanation() + * .receivedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerDamagedOrDefectiveMerchandise = + ConsumerDamagedOrDefectiveMerchandise( + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("notReturned", notReturned), + checkRequired("orderAndIssueExplanation", orderAndIssueExplanation), + checkRequired("receivedAt", receivedAt), + checkRequired("returnAttempted", returnAttempted), + checkRequired("returnOutcome", returnOutcome), + checkRequired("returned", returned), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerDamagedOrDefectiveMerchandise = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + orderAndIssueExplanation() + receivedAt() + returnAttempted().ifPresent { it.validate() } + returnOutcome().validate() + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (orderAndIssueExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptReason(): AttemptReason = + attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField + val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField + val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic + fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + mutableMapOf(), + ) + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = + merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * Returns the raw JSON value of [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var merchantReceivedReturnAt: JsonField? = null + private var otherExplanation: JsonField? = null + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var trackingNumber: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate?) = + merchantReceivedReturnAt( + JsonField.ofNullable(merchantReceivedReturnAt) + ) + + /** + * Alias for calling [Builder.merchantReceivedReturnAt] with + * `merchantReceivedReturnAt.orElse(null)`. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: Optional + ) = merchantReceivedReturnAt(merchantReceivedReturnAt.getOrNull()) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is + * `other`. + */ + fun otherExplanation(otherExplanation: String?) = + otherExplanation(JsonField.ofNullable(otherExplanation)) + + /** + * Alias for calling [Builder.otherExplanation] with + * `otherExplanation.orElse(null)`. + */ + fun otherExplanation(otherExplanation: Optional) = + otherExplanation(otherExplanation.getOrNull()) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = + returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Tracking number. */ + 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired( + "merchantReceivedReturnAt", + merchantReceivedReturnAt, + ), + checkRequired("otherExplanation", otherExplanation), + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + checkRequired("trackingNumber", trackingNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + merchantReceivedReturnAt() + otherExplanation() + returnMethod().validate() + returnedAt() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, returnMethod=$returnMethod, returnedAt=$returnedAt, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerDamagedOrDefectiveMerchandise && + merchantResolutionAttempted == other.merchantResolutionAttempted && + notReturned == other.notReturned && + orderAndIssueExplanation == other.orderAndIssueExplanation && + receivedAt == other.receivedAt && + returnAttempted == other.returnAttempted && + returnOutcome == other.returnOutcome && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + notReturned, + orderAndIssueExplanation, + receivedAt, + returnAttempted, + returnOutcome, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerDamagedOrDefectiveMerchandise{merchantResolutionAttempted=$merchantResolutionAttempted, notReturned=$notReturned, orderAndIssueExplanation=$orderAndIssueExplanation, receivedAt=$receivedAt, returnAttempted=$returnAttempted, returnOutcome=$returnOutcome, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise misrepresentation. Present if and only if `category` is + * `consumer_merchandise_misrepresentation`. + */ + class ConsumerMerchandiseMisrepresentation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val misrepresentationExplanation: JsonField, + private val notReturned: JsonValue, + private val purchaseExplanation: JsonField, + private val receivedAt: JsonField, + private val returnAttempted: JsonField, + private val returnOutcome: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + misrepresentationExplanation: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + misrepresentationExplanation, + notReturned, + purchaseExplanation, + receivedAt, + returnAttempted, + returnOutcome, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Misrepresentation explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun misrepresentationExplanation(): String = + misrepresentationExplanation.getRequired("misrepresentation_explanation") + + /** Not returned. Present if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Returned. Present if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [misrepresentationExplanation]. + * + * Unlike [misrepresentationExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + fun _misrepresentationExplanation(): JsonField = + misrepresentationExplanation + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerMerchandiseMisrepresentation]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .notReturned() + * .purchaseExplanation() + * .receivedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseMisrepresentation]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: + JsonField? = + null + private var misrepresentationExplanation: JsonField? = null + private var notReturned: JsonValue? = null + private var purchaseExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var returnAttempted: JsonField? = null + private var returnOutcome: JsonField? = null + private var returned: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerMerchandiseMisrepresentation: + ConsumerMerchandiseMisrepresentation + ) = apply { + merchantResolutionAttempted = + consumerMerchandiseMisrepresentation.merchantResolutionAttempted + misrepresentationExplanation = + consumerMerchandiseMisrepresentation.misrepresentationExplanation + notReturned = consumerMerchandiseMisrepresentation.notReturned + purchaseExplanation = + consumerMerchandiseMisrepresentation.purchaseExplanation + receivedAt = consumerMerchandiseMisrepresentation.receivedAt + returnAttempted = consumerMerchandiseMisrepresentation.returnAttempted + returnOutcome = consumerMerchandiseMisrepresentation.returnOutcome + returned = consumerMerchandiseMisrepresentation.returned + additionalProperties = + consumerMerchandiseMisrepresentation.additionalProperties + .toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Misrepresentation explanation. */ + fun misrepresentationExplanation(misrepresentationExplanation: String) = + misrepresentationExplanation(JsonField.of(misrepresentationExplanation)) + + /** + * Sets [Builder.misrepresentationExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.misrepresentationExplanation] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun misrepresentationExplanation( + misrepresentationExplanation: JsonField + ) = apply { + this.misrepresentationExplanation = misrepresentationExplanation + } + + /** + * Not returned. Present if and only if `return_outcome` is `not_returned`. + */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted?) = + returnAttempted(JsonField.ofNullable(returnAttempted)) + + /** + * Alias for calling [Builder.returnAttempted] with + * `returnAttempted.orElse(null)`. + */ + fun returnAttempted(returnAttempted: Optional) = + returnAttempted(returnAttempted.getOrNull()) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned?) = returned(JsonField.ofNullable(returned)) + + /** Alias for calling [Builder.returned] with `returned.orElse(null)`. */ + fun returned(returned: Optional) = returned(returned.getOrNull()) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returned(returned: JsonField) = apply { + this.returned = returned + } + + 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 [ConsumerMerchandiseMisrepresentation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .notReturned() + * .purchaseExplanation() + * .receivedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseMisrepresentation = + ConsumerMerchandiseMisrepresentation( + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired( + "misrepresentationExplanation", + misrepresentationExplanation, + ), + checkRequired("notReturned", notReturned), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedAt", receivedAt), + checkRequired("returnAttempted", returnAttempted), + checkRequired("returnOutcome", returnOutcome), + checkRequired("returned", returned), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseMisrepresentation = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + misrepresentationExplanation() + purchaseExplanation() + receivedAt() + returnAttempted().ifPresent { it.validate() } + returnOutcome().validate() + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (misrepresentationExplanation.asKnown().isPresent) 1 else 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptReason(): AttemptReason = + attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField + val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField + val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic + fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + mutableMapOf(), + ) + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = + merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * Returns the raw JSON value of [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var merchantReceivedReturnAt: JsonField? = null + private var otherExplanation: JsonField? = null + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var trackingNumber: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate?) = + merchantReceivedReturnAt( + JsonField.ofNullable(merchantReceivedReturnAt) + ) + + /** + * Alias for calling [Builder.merchantReceivedReturnAt] with + * `merchantReceivedReturnAt.orElse(null)`. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: Optional + ) = merchantReceivedReturnAt(merchantReceivedReturnAt.getOrNull()) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is + * `other`. + */ + fun otherExplanation(otherExplanation: String?) = + otherExplanation(JsonField.ofNullable(otherExplanation)) + + /** + * Alias for calling [Builder.otherExplanation] with + * `otherExplanation.orElse(null)`. + */ + fun otherExplanation(otherExplanation: Optional) = + otherExplanation(otherExplanation.getOrNull()) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = + returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Tracking number. */ + 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired( + "merchantReceivedReturnAt", + merchantReceivedReturnAt, + ), + checkRequired("otherExplanation", otherExplanation), + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + checkRequired("trackingNumber", trackingNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + merchantReceivedReturnAt() + otherExplanation() + returnMethod().validate() + returnedAt() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, returnMethod=$returnMethod, returnedAt=$returnedAt, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerMerchandiseMisrepresentation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + misrepresentationExplanation == other.misrepresentationExplanation && + notReturned == other.notReturned && + purchaseExplanation == other.purchaseExplanation && + receivedAt == other.receivedAt && + returnAttempted == other.returnAttempted && + returnOutcome == other.returnOutcome && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + misrepresentationExplanation, + notReturned, + purchaseExplanation, + receivedAt, + returnAttempted, + returnOutcome, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseMisrepresentation{merchantResolutionAttempted=$merchantResolutionAttempted, misrepresentationExplanation=$misrepresentationExplanation, notReturned=$notReturned, purchaseExplanation=$purchaseExplanation, receivedAt=$receivedAt, returnAttempted=$returnAttempted, returnOutcome=$returnOutcome, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise not as described. Present if and only if `category` is + * `consumer_merchandise_not_as_described`. + */ + class ConsumerMerchandiseNotAsDescribed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val receivedAt: JsonField, + private val returnAttempted: JsonField, + private val returnOutcome: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + receivedAt, + returnAttempted, + returnOutcome, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Returned. Present if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerMerchandiseNotAsDescribed]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .receivedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseNotAsDescribed]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: + JsonField? = + null + private var receivedAt: JsonField? = null + private var returnAttempted: JsonField? = null + private var returnOutcome: JsonField? = null + private var returned: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerMerchandiseNotAsDescribed: ConsumerMerchandiseNotAsDescribed + ) = apply { + merchantResolutionAttempted = + consumerMerchandiseNotAsDescribed.merchantResolutionAttempted + receivedAt = consumerMerchandiseNotAsDescribed.receivedAt + returnAttempted = consumerMerchandiseNotAsDescribed.returnAttempted + returnOutcome = consumerMerchandiseNotAsDescribed.returnOutcome + returned = consumerMerchandiseNotAsDescribed.returned + additionalProperties = + consumerMerchandiseNotAsDescribed.additionalProperties + .toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted?) = + returnAttempted(JsonField.ofNullable(returnAttempted)) + + /** + * Alias for calling [Builder.returnAttempted] with + * `returnAttempted.orElse(null)`. + */ + fun returnAttempted(returnAttempted: Optional) = + returnAttempted(returnAttempted.getOrNull()) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned?) = returned(JsonField.ofNullable(returned)) + + /** Alias for calling [Builder.returned] with `returned.orElse(null)`. */ + fun returned(returned: Optional) = returned(returned.getOrNull()) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returned(returned: JsonField) = apply { + this.returned = returned + } + + 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 [ConsumerMerchandiseNotAsDescribed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .receivedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseNotAsDescribed = + ConsumerMerchandiseNotAsDescribed( + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("receivedAt", receivedAt), + checkRequired("returnAttempted", returnAttempted), + checkRequired("returnOutcome", returnOutcome), + checkRequired("returned", returned), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseNotAsDescribed = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + receivedAt() + returnAttempted().ifPresent { it.validate() } + returnOutcome().validate() + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptReason(): AttemptReason = + attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField + val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField + val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic + fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + mutableMapOf(), + ) + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = + merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * Returns the raw JSON value of [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var merchantReceivedReturnAt: JsonField? = null + private var otherExplanation: JsonField? = null + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var trackingNumber: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate?) = + merchantReceivedReturnAt( + JsonField.ofNullable(merchantReceivedReturnAt) + ) + + /** + * Alias for calling [Builder.merchantReceivedReturnAt] with + * `merchantReceivedReturnAt.orElse(null)`. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: Optional + ) = merchantReceivedReturnAt(merchantReceivedReturnAt.getOrNull()) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is + * `other`. + */ + fun otherExplanation(otherExplanation: String?) = + otherExplanation(JsonField.ofNullable(otherExplanation)) + + /** + * Alias for calling [Builder.otherExplanation] with + * `otherExplanation.orElse(null)`. + */ + fun otherExplanation(otherExplanation: Optional) = + otherExplanation(otherExplanation.getOrNull()) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = + returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Tracking number. */ + 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired( + "merchantReceivedReturnAt", + merchantReceivedReturnAt, + ), + checkRequired("otherExplanation", otherExplanation), + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + checkRequired("trackingNumber", trackingNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + merchantReceivedReturnAt() + otherExplanation() + returnMethod().validate() + returnedAt() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, returnMethod=$returnMethod, returnedAt=$returnedAt, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerMerchandiseNotAsDescribed && + merchantResolutionAttempted == other.merchantResolutionAttempted && + receivedAt == other.receivedAt && + returnAttempted == other.returnAttempted && + returnOutcome == other.returnOutcome && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + receivedAt, + returnAttempted, + returnOutcome, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseNotAsDescribed{merchantResolutionAttempted=$merchantResolutionAttempted, receivedAt=$receivedAt, returnAttempted=$returnAttempted, returnOutcome=$returnOutcome, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise not received. Present if and only if `category` is + * `consumer_merchandise_not_received`. + */ + class ConsumerMerchandiseNotReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationOutcome: JsonField, + private val cardholderCancellationPriorToExpectedReceipt: + JsonField, + private val delayed: JsonField, + private val deliveredToWrongLocation: JsonField, + private val deliveryIssue: JsonField, + private val lastExpectedReceiptAt: JsonField, + private val merchantCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val noCancellation: JsonValue, + private val purchaseInfoAndExplanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_outcome") + @ExcludeMissing + cancellationOutcome: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of(), + @JsonProperty("delayed") + @ExcludeMissing + delayed: JsonField = JsonMissing.of(), + @JsonProperty("delivered_to_wrong_location") + @ExcludeMissing + deliveredToWrongLocation: JsonField = + JsonMissing.of(), + @JsonProperty("delivery_issue") + @ExcludeMissing + deliveryIssue: JsonField = JsonMissing.of(), + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + lastExpectedReceiptAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_cancellation") + @ExcludeMissing + merchantCancellation: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("no_cancellation") + @ExcludeMissing + noCancellation: JsonValue = JsonMissing.of(), + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + purchaseInfoAndExplanation: JsonField = JsonMissing.of(), + ) : this( + cancellationOutcome, + cardholderCancellationPriorToExpectedReceipt, + delayed, + deliveredToWrongLocation, + deliveryIssue, + lastExpectedReceiptAt, + merchantCancellation, + merchantResolutionAttempted, + noCancellation, + purchaseInfoAndExplanation, + mutableMapOf(), + ) + + /** + * Cancellation outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationOutcome(): CancellationOutcome = + cancellationOutcome.getRequired("cancellation_outcome") + + /** + * Cardholder cancellation prior to expected receipt. Present if and only if + * `cancellation_outcome` is + * `cardholder_cancellation_prior_to_expected_receipt`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderCancellationPriorToExpectedReceipt(): + Optional = + cardholderCancellationPriorToExpectedReceipt.getOptional( + "cardholder_cancellation_prior_to_expected_receipt" + ) + + /** + * Delayed. Present if and only if `delivery_issue` is `delayed`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun delayed(): Optional = delayed.getOptional("delayed") + + /** + * Delivered to wrong location. Present if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun deliveredToWrongLocation(): Optional = + deliveredToWrongLocation.getOptional("delivered_to_wrong_location") + + /** + * Delivery issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun deliveryIssue(): DeliveryIssue = deliveryIssue.getRequired("delivery_issue") + + /** + * Last expected receipt at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastExpectedReceiptAt(): LocalDate = + lastExpectedReceiptAt.getRequired("last_expected_receipt_at") + + /** + * Merchant cancellation. Present if and only if `cancellation_outcome` is + * `merchant_cancellation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantCancellation(): Optional = + merchantCancellation.getOptional("merchant_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * No cancellation. Present if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + @JsonProperty("no_cancellation") + @ExcludeMissing + fun _noCancellation(): JsonValue = noCancellation + + /** + * Purchase information and explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseInfoAndExplanation(): String = + purchaseInfoAndExplanation.getRequired("purchase_info_and_explanation") + + /** + * Returns the raw JSON value of [cancellationOutcome]. + * + * Unlike [cancellationOutcome], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cancellation_outcome") + @ExcludeMissing + fun _cancellationOutcome(): JsonField = cancellationOutcome + + /** + * Returns the raw JSON value of [cardholderCancellationPriorToExpectedReceipt]. + * + * Unlike [cardholderCancellationPriorToExpectedReceipt], this method doesn't + * throw if the JSON field has an unexpected type. + */ + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + fun _cardholderCancellationPriorToExpectedReceipt(): + JsonField = + cardholderCancellationPriorToExpectedReceipt + + /** + * Returns the raw JSON value of [delayed]. + * + * Unlike [delayed], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("delayed") + @ExcludeMissing + fun _delayed(): JsonField = delayed + + /** + * Returns the raw JSON value of [deliveredToWrongLocation]. + * + * Unlike [deliveredToWrongLocation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("delivered_to_wrong_location") + @ExcludeMissing + fun _deliveredToWrongLocation(): JsonField = + deliveredToWrongLocation + + /** + * Returns the raw JSON value of [deliveryIssue]. + * + * Unlike [deliveryIssue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("delivery_issue") + @ExcludeMissing + fun _deliveryIssue(): JsonField = deliveryIssue + + /** + * Returns the raw JSON value of [lastExpectedReceiptAt]. + * + * Unlike [lastExpectedReceiptAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + fun _lastExpectedReceiptAt(): JsonField = lastExpectedReceiptAt + + /** + * Returns the raw JSON value of [merchantCancellation]. + * + * Unlike [merchantCancellation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_cancellation") + @ExcludeMissing + fun _merchantCancellation(): JsonField = + merchantCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseInfoAndExplanation]. + * + * Unlike [purchaseInfoAndExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + fun _purchaseInfoAndExplanation(): JsonField = + purchaseInfoAndExplanation + + @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 + * [ConsumerMerchandiseNotReceived]. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .cardholderCancellationPriorToExpectedReceipt() + * .delayed() + * .deliveredToWrongLocation() + * .deliveryIssue() + * .lastExpectedReceiptAt() + * .merchantCancellation() + * .merchantResolutionAttempted() + * .noCancellation() + * .purchaseInfoAndExplanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseNotReceived]. */ + class Builder internal constructor() { + + private var cancellationOutcome: JsonField? = null + private var cardholderCancellationPriorToExpectedReceipt: + JsonField? = + null + private var delayed: JsonField? = null + private var deliveredToWrongLocation: JsonField? = + null + private var deliveryIssue: JsonField? = null + private var lastExpectedReceiptAt: JsonField? = null + private var merchantCancellation: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var noCancellation: JsonValue? = null + private var purchaseInfoAndExplanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerMerchandiseNotReceived: ConsumerMerchandiseNotReceived + ) = apply { + cancellationOutcome = consumerMerchandiseNotReceived.cancellationOutcome + cardholderCancellationPriorToExpectedReceipt = + consumerMerchandiseNotReceived + .cardholderCancellationPriorToExpectedReceipt + delayed = consumerMerchandiseNotReceived.delayed + deliveredToWrongLocation = + consumerMerchandiseNotReceived.deliveredToWrongLocation + deliveryIssue = consumerMerchandiseNotReceived.deliveryIssue + lastExpectedReceiptAt = + consumerMerchandiseNotReceived.lastExpectedReceiptAt + merchantCancellation = + consumerMerchandiseNotReceived.merchantCancellation + merchantResolutionAttempted = + consumerMerchandiseNotReceived.merchantResolutionAttempted + noCancellation = consumerMerchandiseNotReceived.noCancellation + purchaseInfoAndExplanation = + consumerMerchandiseNotReceived.purchaseInfoAndExplanation + additionalProperties = + consumerMerchandiseNotReceived.additionalProperties.toMutableMap() + } + + /** Cancellation outcome. */ + fun cancellationOutcome(cancellationOutcome: CancellationOutcome) = + cancellationOutcome(JsonField.of(cancellationOutcome)) + + /** + * Sets [Builder.cancellationOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationOutcome] with a well-typed + * [CancellationOutcome] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cancellationOutcome( + cancellationOutcome: JsonField + ) = apply { this.cancellationOutcome = cancellationOutcome } + + /** + * Cardholder cancellation prior to expected receipt. Present if and only if + * `cancellation_outcome` is + * `cardholder_cancellation_prior_to_expected_receipt`. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt? + ) = + cardholderCancellationPriorToExpectedReceipt( + JsonField.ofNullable(cardholderCancellationPriorToExpectedReceipt) + ) + + /** + * Alias for calling [Builder.cardholderCancellationPriorToExpectedReceipt] + * with `cardholderCancellationPriorToExpectedReceipt.orElse(null)`. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + Optional + ) = + cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt.getOrNull() + ) + + /** + * Sets [Builder.cardholderCancellationPriorToExpectedReceipt] to an + * arbitrary JSON value. + * + * You should usually call + * [Builder.cardholderCancellationPriorToExpectedReceipt] with a well-typed + * [CardholderCancellationPriorToExpectedReceipt] value instead. This method + * is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + JsonField + ) = apply { + this.cardholderCancellationPriorToExpectedReceipt = + cardholderCancellationPriorToExpectedReceipt + } + + /** Delayed. Present if and only if `delivery_issue` is `delayed`. */ + fun delayed(delayed: Delayed?) = delayed(JsonField.ofNullable(delayed)) + + /** Alias for calling [Builder.delayed] with `delayed.orElse(null)`. */ + fun delayed(delayed: Optional) = delayed(delayed.getOrNull()) + + /** + * Sets [Builder.delayed] to an arbitrary JSON value. + * + * You should usually call [Builder.delayed] with a well-typed [Delayed] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun delayed(delayed: JsonField) = apply { this.delayed = delayed } + + /** + * Delivered to wrong location. Present if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + */ + fun deliveredToWrongLocation( + deliveredToWrongLocation: DeliveredToWrongLocation? + ) = deliveredToWrongLocation(JsonField.ofNullable(deliveredToWrongLocation)) + + /** + * Alias for calling [Builder.deliveredToWrongLocation] with + * `deliveredToWrongLocation.orElse(null)`. + */ + fun deliveredToWrongLocation( + deliveredToWrongLocation: Optional + ) = deliveredToWrongLocation(deliveredToWrongLocation.getOrNull()) + + /** + * Sets [Builder.deliveredToWrongLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveredToWrongLocation] with a + * well-typed [DeliveredToWrongLocation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun deliveredToWrongLocation( + deliveredToWrongLocation: JsonField + ) = apply { this.deliveredToWrongLocation = deliveredToWrongLocation } + + /** Delivery issue. */ + fun deliveryIssue(deliveryIssue: DeliveryIssue) = + deliveryIssue(JsonField.of(deliveryIssue)) + + /** + * Sets [Builder.deliveryIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveryIssue] with a well-typed + * [DeliveryIssue] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun deliveryIssue(deliveryIssue: JsonField) = apply { + this.deliveryIssue = deliveryIssue + } + + /** Last expected receipt at. */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: LocalDate) = + lastExpectedReceiptAt(JsonField.of(lastExpectedReceiptAt)) + + /** + * Sets [Builder.lastExpectedReceiptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastExpectedReceiptAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: JsonField) = + apply { + this.lastExpectedReceiptAt = lastExpectedReceiptAt + } + + /** + * Merchant cancellation. Present if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + fun merchantCancellation(merchantCancellation: MerchantCancellation?) = + merchantCancellation(JsonField.ofNullable(merchantCancellation)) + + /** + * Alias for calling [Builder.merchantCancellation] with + * `merchantCancellation.orElse(null)`. + */ + fun merchantCancellation( + merchantCancellation: Optional + ) = merchantCancellation(merchantCancellation.getOrNull()) + + /** + * Sets [Builder.merchantCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCancellation] with a well-typed + * [MerchantCancellation] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantCancellation( + merchantCancellation: JsonField + ) = apply { this.merchantCancellation = merchantCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * No cancellation. Present if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + fun noCancellation(noCancellation: JsonValue) = apply { + this.noCancellation = noCancellation + } + + /** Purchase information and explanation. */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: String) = + purchaseInfoAndExplanation(JsonField.of(purchaseInfoAndExplanation)) + + /** + * Sets [Builder.purchaseInfoAndExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndExplanation] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun purchaseInfoAndExplanation( + purchaseInfoAndExplanation: JsonField + ) = apply { this.purchaseInfoAndExplanation = purchaseInfoAndExplanation } + + 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 [ConsumerMerchandiseNotReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .cardholderCancellationPriorToExpectedReceipt() + * .delayed() + * .deliveredToWrongLocation() + * .deliveryIssue() + * .lastExpectedReceiptAt() + * .merchantCancellation() + * .merchantResolutionAttempted() + * .noCancellation() + * .purchaseInfoAndExplanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseNotReceived = + ConsumerMerchandiseNotReceived( + checkRequired("cancellationOutcome", cancellationOutcome), + checkRequired( + "cardholderCancellationPriorToExpectedReceipt", + cardholderCancellationPriorToExpectedReceipt, + ), + checkRequired("delayed", delayed), + checkRequired("deliveredToWrongLocation", deliveredToWrongLocation), + checkRequired("deliveryIssue", deliveryIssue), + checkRequired("lastExpectedReceiptAt", lastExpectedReceiptAt), + checkRequired("merchantCancellation", merchantCancellation), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("noCancellation", noCancellation), + checkRequired( + "purchaseInfoAndExplanation", + purchaseInfoAndExplanation, + ), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseNotReceived = apply { + if (validated) { + return@apply + } + + cancellationOutcome().validate() + cardholderCancellationPriorToExpectedReceipt().ifPresent { it.validate() } + delayed().ifPresent { it.validate() } + deliveredToWrongLocation().ifPresent { it.validate() } + deliveryIssue().validate() + lastExpectedReceiptAt() + merchantCancellation().ifPresent { it.validate() } + merchantResolutionAttempted().validate() + purchaseInfoAndExplanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderCancellationPriorToExpectedReceipt + .asKnown() + .getOrNull() + ?.validity() ?: 0) + + (delayed.asKnown().getOrNull()?.validity() ?: 0) + + (deliveredToWrongLocation.asKnown().getOrNull()?.validity() ?: 0) + + (deliveryIssue.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastExpectedReceiptAt.asKnown().isPresent) 1 else 0) + + (merchantCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndExplanation.asKnown().isPresent) 1 else 0) + + /** Cancellation outcome. */ + class CancellationOutcome + @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 { + + /** Cardholder cancellation prior to expected receipt. */ + @JvmField + val CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT = + of("cardholder_cancellation_prior_to_expected_receipt") + + /** Merchant cancellation. */ + @JvmField val MERCHANT_CANCELLATION = of("merchant_cancellation") + + /** No cancellation. */ + @JvmField val NO_CANCELLATION = of("no_cancellation") + + @JvmStatic + fun of(value: String) = CancellationOutcome(JsonField.of(value)) + } + + /** An enum containing [CancellationOutcome]'s known values. */ + enum class Known { + /** Cardholder cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + } + + /** + * An enum containing [CancellationOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CancellationOutcome] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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 cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + /** + * An enum member indicating that [CancellationOutcome] 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_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Value.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Value.MERCHANT_CANCELLATION + NO_CANCELLATION -> Value.NO_CANCELLATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Known.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Known.MERCHANT_CANCELLATION + NO_CANCELLATION -> Known.NO_CANCELLATION + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Cardholder cancellation prior to expected receipt. Present if and only if + * `cancellation_outcome` is + * `cardholder_cancellation_prior_to_expected_receipt`. + */ + class CardholderCancellationPriorToExpectedReceipt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellationPriorToExpectedReceipt]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = apply { + canceledAt = cardholderCancellationPriorToExpectedReceipt.canceledAt + reason = cardholderCancellationPriorToExpectedReceipt.reason + additionalProperties = + cardholderCancellationPriorToExpectedReceipt + .additionalProperties + .toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] + * 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 } + + 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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellationPriorToExpectedReceipt = + CardholderCancellationPriorToExpectedReceipt( + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellationPriorToExpectedReceipt = apply { + if (validated) { + return@apply + } + + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderCancellationPriorToExpectedReceipt && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellationPriorToExpectedReceipt{canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Delayed. Present if and only if `delivery_issue` is `delayed`. */ + class Delayed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returnOutcome: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + explanation, + notReturned, + returnAttempted, + returnOutcome, + returned, + mutableMapOf(), + ) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Not returned. Present if and only if `return_outcome` is `not_returned`. + */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnOutcome(): ReturnOutcome = + returnOutcome.getRequired("return_outcome") + + /** + * Returned. Present if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * 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 [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 [Delayed]. + * + * The following fields are required: + * ```java + * .explanation() + * .notReturned() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Delayed]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var notReturned: JsonValue? = null + private var returnAttempted: JsonField? = null + private var returnOutcome: JsonField? = null + private var returned: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(delayed: Delayed) = apply { + explanation = delayed.explanation + notReturned = delayed.notReturned + returnAttempted = delayed.returnAttempted + returnOutcome = delayed.returnOutcome + returned = delayed.returned + additionalProperties = delayed.additionalProperties.toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: String) = + explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** + * Not returned. Present if and only if `return_outcome` is + * `not_returned`. + */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted?) = + returnAttempted(JsonField.ofNullable(returnAttempted)) + + /** + * Alias for calling [Builder.returnAttempted] with + * `returnAttempted.orElse(null)`. + */ + fun returnAttempted(returnAttempted: Optional) = + returnAttempted(returnAttempted.getOrNull()) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = + apply { + this.returnAttempted = returnAttempted + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned?) = + returned(JsonField.ofNullable(returned)) + + /** + * Alias for calling [Builder.returned] with `returned.orElse(null)`. + */ + fun returned(returned: Optional) = + returned(returned.getOrNull()) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed + * [Returned] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returned(returned: JsonField) = apply { + this.returned = returned + } + + 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 [Delayed]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .explanation() + * .notReturned() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Delayed = + Delayed( + checkRequired("explanation", explanation), + checkRequired("notReturned", notReturned), + checkRequired("returnAttempted", returnAttempted), + checkRequired("returnOutcome", returnOutcome), + checkRequired("returned", returned), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Delayed = apply { + if (validated) { + return@apply + } + + explanation() + returnAttempted().ifPresent { it.validate() } + returnOutcome().validate() + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of() + ) : this(attemptedAt, mutableMapOf()) + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptedAt = returnAttempted.attemptedAt + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .attemptedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptedAt", attemptedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnAttempted && + attemptedAt == other.attemptedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attemptedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptedAt=$attemptedAt, additionalProperties=$additionalProperties}" + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic + fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantReceivedReturnAt: JsonField, + private val returnedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + ) : this(merchantReceivedReturnAt, returnedAt, mutableMapOf()) + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): LocalDate = + merchantReceivedReturnAt.getRequired("merchant_received_return_at") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an + * unexpected type or is unexpectedly missing or null (e.g. if the + * server responded with an unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = + merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + @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 + * [Returned]. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var merchantReceivedReturnAt: JsonField? = null + private var returnedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + returnedAt = returned.returnedAt + additionalProperties = + returned.additionalProperties.toMutableMap() + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON + * value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { + this.merchantReceivedReturnAt = merchantReceivedReturnAt + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = + returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired( + "merchantReceivedReturnAt", + merchantReceivedReturnAt, + ), + checkRequired("returnedAt", returnedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + merchantReceivedReturnAt() + returnedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Returned && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + returnedAt == other.returnedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantReceivedReturnAt, + returnedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{merchantReceivedReturnAt=$merchantReceivedReturnAt, returnedAt=$returnedAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Delayed && + explanation == other.explanation && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returnOutcome == other.returnOutcome && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + notReturned, + returnAttempted, + returnOutcome, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Delayed{explanation=$explanation, notReturned=$notReturned, returnAttempted=$returnAttempted, returnOutcome=$returnOutcome, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Delivered to wrong location. Present if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + */ + class DeliveredToWrongLocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agreedLocation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agreed_location") + @ExcludeMissing + agreedLocation: JsonField = JsonMissing.of() + ) : this(agreedLocation, mutableMapOf()) + + /** + * Agreed location. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun agreedLocation(): String = agreedLocation.getRequired("agreed_location") + + /** + * Returns the raw JSON value of [agreedLocation]. + * + * Unlike [agreedLocation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("agreed_location") + @ExcludeMissing + fun _agreedLocation(): JsonField = agreedLocation + + @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 + * [DeliveredToWrongLocation]. + * + * The following fields are required: + * ```java + * .agreedLocation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeliveredToWrongLocation]. */ + class Builder internal constructor() { + + private var agreedLocation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(deliveredToWrongLocation: DeliveredToWrongLocation) = + apply { + agreedLocation = deliveredToWrongLocation.agreedLocation + additionalProperties = + deliveredToWrongLocation.additionalProperties.toMutableMap() + } + + /** Agreed location. */ + fun agreedLocation(agreedLocation: String) = + agreedLocation(JsonField.of(agreedLocation)) + + /** + * Sets [Builder.agreedLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.agreedLocation] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun agreedLocation(agreedLocation: JsonField) = apply { + this.agreedLocation = agreedLocation + } + + 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 [DeliveredToWrongLocation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .agreedLocation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeliveredToWrongLocation = + DeliveredToWrongLocation( + checkRequired("agreedLocation", agreedLocation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DeliveredToWrongLocation = apply { + if (validated) { + return@apply + } + + agreedLocation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (agreedLocation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeliveredToWrongLocation && + agreedLocation == other.agreedLocation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(agreedLocation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DeliveredToWrongLocation{agreedLocation=$agreedLocation, additionalProperties=$additionalProperties}" + } + + /** Delivery issue. */ + class DeliveryIssue + @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 { + + /** Delayed. */ + @JvmField val DELAYED = of("delayed") + + /** Delivered to wrong location. */ + @JvmField + val DELIVERED_TO_WRONG_LOCATION = of("delivered_to_wrong_location") + + @JvmStatic fun of(value: String) = DeliveryIssue(JsonField.of(value)) + } + + /** An enum containing [DeliveryIssue]'s known values. */ + enum class Known { + /** Delayed. */ + DELAYED, + /** Delivered to wrong location. */ + DELIVERED_TO_WRONG_LOCATION, + } + + /** + * An enum containing [DeliveryIssue]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [DeliveryIssue] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Delayed. */ + DELAYED, + /** Delivered to wrong location. */ + DELIVERED_TO_WRONG_LOCATION, + /** + * An enum member indicating that [DeliveryIssue] 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) { + DELAYED -> Value.DELAYED + DELIVERED_TO_WRONG_LOCATION -> Value.DELIVERED_TO_WRONG_LOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DELAYED -> Known.DELAYED + DELIVERED_TO_WRONG_LOCATION -> Known.DELIVERED_TO_WRONG_LOCATION + else -> + throw IncreaseInvalidDataException( + "Unknown DeliveryIssue: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DeliveryIssue = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeliveryIssue && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Merchant cancellation. Present if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + class MerchantCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of() + ) : this(canceledAt, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + @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 + * [MerchantCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCancellation: MerchantCancellation) = apply { + canceledAt = merchantCancellation.canceledAt + additionalProperties = + merchantCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + 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 [MerchantCancellation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCancellation = + MerchantCancellation( + checkRequired("canceledAt", canceledAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCancellation && + canceledAt == other.canceledAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCancellation{canceledAt=$canceledAt, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && 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 ConsumerMerchandiseNotReceived && + cancellationOutcome == other.cancellationOutcome && + cardholderCancellationPriorToExpectedReceipt == + other.cardholderCancellationPriorToExpectedReceipt && + delayed == other.delayed && + deliveredToWrongLocation == other.deliveredToWrongLocation && + deliveryIssue == other.deliveryIssue && + lastExpectedReceiptAt == other.lastExpectedReceiptAt && + merchantCancellation == other.merchantCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + noCancellation == other.noCancellation && + purchaseInfoAndExplanation == other.purchaseInfoAndExplanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationOutcome, + cardholderCancellationPriorToExpectedReceipt, + delayed, + deliveredToWrongLocation, + deliveryIssue, + lastExpectedReceiptAt, + merchantCancellation, + merchantResolutionAttempted, + noCancellation, + purchaseInfoAndExplanation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseNotReceived{cancellationOutcome=$cancellationOutcome, cardholderCancellationPriorToExpectedReceipt=$cardholderCancellationPriorToExpectedReceipt, delayed=$delayed, deliveredToWrongLocation=$deliveredToWrongLocation, deliveryIssue=$deliveryIssue, lastExpectedReceiptAt=$lastExpectedReceiptAt, merchantCancellation=$merchantCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, noCancellation=$noCancellation, purchaseInfoAndExplanation=$purchaseInfoAndExplanation, additionalProperties=$additionalProperties}" + } + + /** + * Original Credit Transaction (OCT) not accepted. Present if and only if `category` + * is `consumer_original_credit_transaction_not_accepted`. + */ + class ConsumerOriginalCreditTransactionNotAccepted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(explanation, reason, mutableMapOf()) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): Reason = reason.getRequired("reason") + + /** + * 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 [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @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 + * [ConsumerOriginalCreditTransactionNotAccepted]. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerOriginalCreditTransactionNotAccepted]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerOriginalCreditTransactionNotAccepted: + ConsumerOriginalCreditTransactionNotAccepted + ) = apply { + explanation = consumerOriginalCreditTransactionNotAccepted.explanation + reason = consumerOriginalCreditTransactionNotAccepted.reason + additionalProperties = + consumerOriginalCreditTransactionNotAccepted.additionalProperties + .toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: String) = + explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Reason. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [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 } + + 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 + * [ConsumerOriginalCreditTransactionNotAccepted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerOriginalCreditTransactionNotAccepted = + ConsumerOriginalCreditTransactionNotAccepted( + checkRequired("explanation", explanation), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerOriginalCreditTransactionNotAccepted = apply { + if (validated) { + return@apply + } + + explanation() + reason().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** Reason. */ + class Reason + @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 { + + /** Prohibited by local laws or regulation. */ + @JvmField + val PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION = + of("prohibited_by_local_laws_or_regulation") + + /** Recipient refused. */ + @JvmField val RECIPIENT_REFUSED = of("recipient_refused") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** Prohibited by local laws or regulation. */ + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION, + /** Recipient refused. */ + RECIPIENT_REFUSED, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Reason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Prohibited by local laws or regulation. */ + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION, + /** Recipient refused. */ + RECIPIENT_REFUSED, + /** + * An enum member indicating that [Reason] 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) { + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION -> + Value.PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + RECIPIENT_REFUSED -> Value.RECIPIENT_REFUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION -> + Known.PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + RECIPIENT_REFUSED -> Known.RECIPIENT_REFUSED + else -> throw IncreaseInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && 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 ConsumerOriginalCreditTransactionNotAccepted && + explanation == other.explanation && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerOriginalCreditTransactionNotAccepted{explanation=$explanation, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise quality issue. Present if and only if `category` is + * `consumer_quality_merchandise`. + */ + class ConsumerQualityMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expectedAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val notReturned: JsonValue, + private val ongoingNegotiations: JsonField, + private val purchaseInfoAndQualityIssue: JsonField, + private val receivedAt: JsonField, + private val returnAttempted: JsonField, + private val returnOutcome: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expected_at") + @ExcludeMissing + expectedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + ongoingNegotiations: JsonField = JsonMissing.of(), + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + purchaseInfoAndQualityIssue: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + expectedAt, + merchantResolutionAttempted, + notReturned, + ongoingNegotiations, + purchaseInfoAndQualityIssue, + receivedAt, + returnAttempted, + returnOutcome, + returned, + mutableMapOf(), + ) + + /** + * Expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun expectedAt(): LocalDate = expectedAt.getRequired("expected_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** Not returned. Present if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing + * negotiations. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ongoingNegotiations(): Optional = + ongoingNegotiations.getOptional("ongoing_negotiations") + + /** + * Purchase information and quality issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseInfoAndQualityIssue(): String = + purchaseInfoAndQualityIssue.getRequired("purchase_info_and_quality_issue") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Returned. Present if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [expectedAt]. + * + * Unlike [expectedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("expected_at") + @ExcludeMissing + fun _expectedAt(): JsonField = expectedAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [ongoingNegotiations]. + * + * Unlike [ongoingNegotiations], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + fun _ongoingNegotiations(): JsonField = ongoingNegotiations + + /** + * Returns the raw JSON value of [purchaseInfoAndQualityIssue]. + * + * Unlike [purchaseInfoAndQualityIssue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + fun _purchaseInfoAndQualityIssue(): JsonField = + purchaseInfoAndQualityIssue + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerQualityMerchandise]. + * + * The following fields are required: + * ```java + * .expectedAt() + * .merchantResolutionAttempted() + * .notReturned() + * .ongoingNegotiations() + * .purchaseInfoAndQualityIssue() + * .receivedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerQualityMerchandise]. */ + class Builder internal constructor() { + + private var expectedAt: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var notReturned: JsonValue? = null + private var ongoingNegotiations: JsonField? = null + private var purchaseInfoAndQualityIssue: JsonField? = null + private var receivedAt: JsonField? = null + private var returnAttempted: JsonField? = null + private var returnOutcome: JsonField? = null + private var returned: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumerQualityMerchandise: ConsumerQualityMerchandise) = + apply { + expectedAt = consumerQualityMerchandise.expectedAt + merchantResolutionAttempted = + consumerQualityMerchandise.merchantResolutionAttempted + notReturned = consumerQualityMerchandise.notReturned + ongoingNegotiations = consumerQualityMerchandise.ongoingNegotiations + purchaseInfoAndQualityIssue = + consumerQualityMerchandise.purchaseInfoAndQualityIssue + receivedAt = consumerQualityMerchandise.receivedAt + returnAttempted = consumerQualityMerchandise.returnAttempted + returnOutcome = consumerQualityMerchandise.returnOutcome + returned = consumerQualityMerchandise.returned + additionalProperties = + consumerQualityMerchandise.additionalProperties.toMutableMap() + } + + /** Expected at. */ + fun expectedAt(expectedAt: LocalDate) = expectedAt(JsonField.of(expectedAt)) + + /** + * Sets [Builder.expectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun expectedAt(expectedAt: JsonField) = apply { + this.expectedAt = expectedAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * Not returned. Present if and only if `return_outcome` is `not_returned`. + */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing + * negotiations. + */ + fun ongoingNegotiations(ongoingNegotiations: OngoingNegotiations?) = + ongoingNegotiations(JsonField.ofNullable(ongoingNegotiations)) + + /** + * Alias for calling [Builder.ongoingNegotiations] with + * `ongoingNegotiations.orElse(null)`. + */ + fun ongoingNegotiations( + ongoingNegotiations: Optional + ) = ongoingNegotiations(ongoingNegotiations.getOrNull()) + + /** + * Sets [Builder.ongoingNegotiations] to an arbitrary JSON value. + * + * You should usually call [Builder.ongoingNegotiations] with a well-typed + * [OngoingNegotiations] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun ongoingNegotiations( + ongoingNegotiations: JsonField + ) = apply { this.ongoingNegotiations = ongoingNegotiations } + + /** Purchase information and quality issue. */ + fun purchaseInfoAndQualityIssue(purchaseInfoAndQualityIssue: String) = + purchaseInfoAndQualityIssue(JsonField.of(purchaseInfoAndQualityIssue)) + + /** + * Sets [Builder.purchaseInfoAndQualityIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndQualityIssue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun purchaseInfoAndQualityIssue( + purchaseInfoAndQualityIssue: JsonField + ) = apply { this.purchaseInfoAndQualityIssue = purchaseInfoAndQualityIssue } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted?) = + returnAttempted(JsonField.ofNullable(returnAttempted)) + + /** + * Alias for calling [Builder.returnAttempted] with + * `returnAttempted.orElse(null)`. + */ + fun returnAttempted(returnAttempted: Optional) = + returnAttempted(returnAttempted.getOrNull()) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned?) = returned(JsonField.ofNullable(returned)) + + /** Alias for calling [Builder.returned] with `returned.orElse(null)`. */ + fun returned(returned: Optional) = returned(returned.getOrNull()) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returned(returned: JsonField) = apply { + this.returned = returned + } + + 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 [ConsumerQualityMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expectedAt() + * .merchantResolutionAttempted() + * .notReturned() + * .ongoingNegotiations() + * .purchaseInfoAndQualityIssue() + * .receivedAt() + * .returnAttempted() + * .returnOutcome() + * .returned() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerQualityMerchandise = + ConsumerQualityMerchandise( + checkRequired("expectedAt", expectedAt), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("notReturned", notReturned), + checkRequired("ongoingNegotiations", ongoingNegotiations), + checkRequired( + "purchaseInfoAndQualityIssue", + purchaseInfoAndQualityIssue, + ), + checkRequired("receivedAt", receivedAt), + checkRequired("returnAttempted", returnAttempted), + checkRequired("returnOutcome", returnOutcome), + checkRequired("returned", returned), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerQualityMerchandise = apply { + if (validated) { + return@apply + } + + expectedAt() + merchantResolutionAttempted().validate() + ongoingNegotiations().ifPresent { it.validate() } + purchaseInfoAndQualityIssue() + receivedAt() + returnAttempted().ifPresent { it.validate() } + returnOutcome().validate() + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expectedAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (ongoingNegotiations.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndQualityIssue.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing + * negotiations. + */ + class OngoingNegotiations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val issuerFirstNotifiedAt: JsonField, + private val startedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + issuerFirstNotifiedAt: JsonField = JsonMissing.of(), + @JsonProperty("started_at") + @ExcludeMissing + startedAt: JsonField = JsonMissing.of(), + ) : this(explanation, issuerFirstNotifiedAt, startedAt, mutableMapOf()) + + /** + * Explanation of the previous ongoing negotiations between the cardholder + * and merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Date the cardholder first notified the issuer of the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun issuerFirstNotifiedAt(): LocalDate = + issuerFirstNotifiedAt.getRequired("issuer_first_notified_at") + + /** + * Started at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun startedAt(): LocalDate = startedAt.getRequired("started_at") + + /** + * 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 [issuerFirstNotifiedAt]. + * + * Unlike [issuerFirstNotifiedAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + fun _issuerFirstNotifiedAt(): JsonField = issuerFirstNotifiedAt + + /** + * Returns the raw JSON value of [startedAt]. + * + * Unlike [startedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("started_at") + @ExcludeMissing + fun _startedAt(): JsonField = startedAt + + @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 + * [OngoingNegotiations]. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OngoingNegotiations]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var issuerFirstNotifiedAt: JsonField? = null + private var startedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(ongoingNegotiations: OngoingNegotiations) = apply { + explanation = ongoingNegotiations.explanation + issuerFirstNotifiedAt = ongoingNegotiations.issuerFirstNotifiedAt + startedAt = ongoingNegotiations.startedAt + additionalProperties = + ongoingNegotiations.additionalProperties.toMutableMap() + } + + /** + * Explanation of the previous ongoing negotiations between the + * cardholder and merchant. + */ + fun explanation(explanation: String) = + explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Date the cardholder first notified the issuer of the dispute. */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: LocalDate) = + issuerFirstNotifiedAt(JsonField.of(issuerFirstNotifiedAt)) + + /** + * Sets [Builder.issuerFirstNotifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerFirstNotifiedAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: JsonField) = + apply { + this.issuerFirstNotifiedAt = issuerFirstNotifiedAt + } + + /** Started at. */ + fun startedAt(startedAt: LocalDate) = startedAt(JsonField.of(startedAt)) + + /** + * Sets [Builder.startedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startedAt(startedAt: JsonField) = apply { + this.startedAt = startedAt + } + + 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 [OngoingNegotiations]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OngoingNegotiations = + OngoingNegotiations( + checkRequired("explanation", explanation), + checkRequired("issuerFirstNotifiedAt", issuerFirstNotifiedAt), + checkRequired("startedAt", startedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OngoingNegotiations = apply { + if (validated) { + return@apply + } + + explanation() + issuerFirstNotifiedAt() + startedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (issuerFirstNotifiedAt.asKnown().isPresent) 1 else 0) + + (if (startedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OngoingNegotiations && + explanation == other.explanation && + issuerFirstNotifiedAt == other.issuerFirstNotifiedAt && + startedAt == other.startedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + issuerFirstNotifiedAt, + startedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OngoingNegotiations{explanation=$explanation, issuerFirstNotifiedAt=$issuerFirstNotifiedAt, startedAt=$startedAt, additionalProperties=$additionalProperties}" + } + + /** + * Return attempted. Present if and only if `return_outcome` is + * `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptReason(): AttemptReason = + attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField + val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField + val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic + fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Returned. Present if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + mutableMapOf(), + ) + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = + merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * Returns the raw JSON value of [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var merchantReceivedReturnAt: JsonField? = null + private var otherExplanation: JsonField? = null + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var trackingNumber: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate?) = + merchantReceivedReturnAt( + JsonField.ofNullable(merchantReceivedReturnAt) + ) + + /** + * Alias for calling [Builder.merchantReceivedReturnAt] with + * `merchantReceivedReturnAt.orElse(null)`. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: Optional + ) = merchantReceivedReturnAt(merchantReceivedReturnAt.getOrNull()) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is + * `other`. + */ + fun otherExplanation(otherExplanation: String?) = + otherExplanation(JsonField.ofNullable(otherExplanation)) + + /** + * Alias for calling [Builder.otherExplanation] with + * `otherExplanation.orElse(null)`. + */ + fun otherExplanation(otherExplanation: Optional) = + otherExplanation(otherExplanation.getOrNull()) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = + returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Tracking number. */ + 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .otherExplanation() + * .returnMethod() + * .returnedAt() + * .trackingNumber() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired( + "merchantReceivedReturnAt", + merchantReceivedReturnAt, + ), + checkRequired("otherExplanation", otherExplanation), + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + checkRequired("trackingNumber", trackingNumber), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + merchantReceivedReturnAt() + otherExplanation() + returnMethod().validate() + returnedAt() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantReceivedReturnAt, + otherExplanation, + returnMethod, + returnedAt, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, returnMethod=$returnMethod, returnedAt=$returnedAt, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerQualityMerchandise && + expectedAt == other.expectedAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + notReturned == other.notReturned && + ongoingNegotiations == other.ongoingNegotiations && + purchaseInfoAndQualityIssue == other.purchaseInfoAndQualityIssue && + receivedAt == other.receivedAt && + returnAttempted == other.returnAttempted && + returnOutcome == other.returnOutcome && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + expectedAt, + merchantResolutionAttempted, + notReturned, + ongoingNegotiations, + purchaseInfoAndQualityIssue, + receivedAt, + returnAttempted, + returnOutcome, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerQualityMerchandise{expectedAt=$expectedAt, merchantResolutionAttempted=$merchantResolutionAttempted, notReturned=$notReturned, ongoingNegotiations=$ongoingNegotiations, purchaseInfoAndQualityIssue=$purchaseInfoAndQualityIssue, receivedAt=$receivedAt, returnAttempted=$returnAttempted, returnOutcome=$returnOutcome, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Services quality issue. Present if and only if `category` is + * `consumer_quality_services`. + */ + class ConsumerQualityServices + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val cardholderPaidToHaveWorkRedone: + JsonField, + private val nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField< + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + >, + private val ongoingNegotiations: JsonField, + private val purchaseInfoAndQualityIssue: JsonField, + private val restaurantFoodRelated: JsonField, + private val servicesReceivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = + JsonMissing.of(), + @JsonProperty("cardholder_paid_to_have_work_redone") + @ExcludeMissing + cardholderPaidToHaveWorkRedone: JsonField = + JsonMissing.of(), + @JsonProperty( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + @ExcludeMissing + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField< + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + > = + JsonMissing.of(), + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + ongoingNegotiations: JsonField = JsonMissing.of(), + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + purchaseInfoAndQualityIssue: JsonField = JsonMissing.of(), + @JsonProperty("restaurant_food_related") + @ExcludeMissing + restaurantFoodRelated: JsonField = JsonMissing.of(), + @JsonProperty("services_received_at") + @ExcludeMissing + servicesReceivedAt: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + cardholderPaidToHaveWorkRedone, + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + ongoingNegotiations, + purchaseInfoAndQualityIssue, + restaurantFoodRelated, + servicesReceivedAt, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Cardholder paid to have work redone. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderPaidToHaveWorkRedone(): Optional = + cardholderPaidToHaveWorkRedone.getOptional( + "cardholder_paid_to_have_work_redone" + ) + + /** + * Non-fiat currency or non-fungible token related and not matching description. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription(): + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .getRequired( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing + * negotiations. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ongoingNegotiations(): Optional = + ongoingNegotiations.getOptional("ongoing_negotiations") + + /** + * Purchase information and quality issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseInfoAndQualityIssue(): String = + purchaseInfoAndQualityIssue.getRequired("purchase_info_and_quality_issue") + + /** + * Whether the dispute is related to the quality of food from an eating place or + * restaurant. Must be provided when Merchant Category Code (MCC) is 5812, 5813 + * or 5814. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun restaurantFoodRelated(): Optional = + restaurantFoodRelated.getOptional("restaurant_food_related") + + /** + * Services received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun servicesReceivedAt(): LocalDate = + servicesReceivedAt.getRequired("services_received_at") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [cardholderPaidToHaveWorkRedone]. + * + * Unlike [cardholderPaidToHaveWorkRedone], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("cardholder_paid_to_have_work_redone") + @ExcludeMissing + fun _cardholderPaidToHaveWorkRedone(): + JsonField = cardholderPaidToHaveWorkRedone + + /** + * Returns the raw JSON value of + * [nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]. + * + * Unlike [nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription], + * this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + @ExcludeMissing + fun _nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription(): + JsonField< + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + > = nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + + /** + * Returns the raw JSON value of [ongoingNegotiations]. + * + * Unlike [ongoingNegotiations], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + fun _ongoingNegotiations(): JsonField = ongoingNegotiations + + /** + * Returns the raw JSON value of [purchaseInfoAndQualityIssue]. + * + * Unlike [purchaseInfoAndQualityIssue], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + fun _purchaseInfoAndQualityIssue(): JsonField = + purchaseInfoAndQualityIssue + + /** + * Returns the raw JSON value of [restaurantFoodRelated]. + * + * Unlike [restaurantFoodRelated], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("restaurant_food_related") + @ExcludeMissing + fun _restaurantFoodRelated(): JsonField = + restaurantFoodRelated + + /** + * Returns the raw JSON value of [servicesReceivedAt]. + * + * Unlike [servicesReceivedAt], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("services_received_at") + @ExcludeMissing + fun _servicesReceivedAt(): JsonField = servicesReceivedAt + + @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 + * [ConsumerQualityServices]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .cardholderPaidToHaveWorkRedone() + * .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription() + * .ongoingNegotiations() + * .purchaseInfoAndQualityIssue() + * .restaurantFoodRelated() + * .servicesReceivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerQualityServices]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = + null + private var cardholderPaidToHaveWorkRedone: + JsonField? = + null + private var nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField< + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + >? = + null + private var ongoingNegotiations: JsonField? = null + private var purchaseInfoAndQualityIssue: JsonField? = null + private var restaurantFoodRelated: JsonField? = null + private var servicesReceivedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumerQualityServices: ConsumerQualityServices) = + apply { + cardholderCancellation = + consumerQualityServices.cardholderCancellation + cardholderPaidToHaveWorkRedone = + consumerQualityServices.cardholderPaidToHaveWorkRedone + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + consumerQualityServices + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + ongoingNegotiations = consumerQualityServices.ongoingNegotiations + purchaseInfoAndQualityIssue = + consumerQualityServices.purchaseInfoAndQualityIssue + restaurantFoodRelated = + consumerQualityServices.restaurantFoodRelated + servicesReceivedAt = consumerQualityServices.servicesReceivedAt + additionalProperties = + consumerQualityServices.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a + * well-typed [CardholderCancellation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Cardholder paid to have work redone. */ + fun cardholderPaidToHaveWorkRedone( + cardholderPaidToHaveWorkRedone: CardholderPaidToHaveWorkRedone? + ) = + cardholderPaidToHaveWorkRedone( + JsonField.ofNullable(cardholderPaidToHaveWorkRedone) + ) + + /** + * Alias for calling [Builder.cardholderPaidToHaveWorkRedone] with + * `cardholderPaidToHaveWorkRedone.orElse(null)`. + */ + fun cardholderPaidToHaveWorkRedone( + cardholderPaidToHaveWorkRedone: Optional + ) = + cardholderPaidToHaveWorkRedone( + cardholderPaidToHaveWorkRedone.getOrNull() + ) + + /** + * Sets [Builder.cardholderPaidToHaveWorkRedone] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderPaidToHaveWorkRedone] with a + * well-typed [CardholderPaidToHaveWorkRedone] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderPaidToHaveWorkRedone( + cardholderPaidToHaveWorkRedone: + JsonField + ) = apply { + this.cardholderPaidToHaveWorkRedone = cardholderPaidToHaveWorkRedone + } + + /** + * Non-fiat currency or non-fungible token related and not matching + * description. + */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + ) = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + JsonField.of( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + ) + ) + + /** + * Sets + * [Builder.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] + * to an arbitrary JSON value. + * + * You should usually call + * [Builder.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] + * with a well-typed + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField< + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + > + ) = apply { + this.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing + * negotiations. + */ + fun ongoingNegotiations(ongoingNegotiations: OngoingNegotiations?) = + ongoingNegotiations(JsonField.ofNullable(ongoingNegotiations)) + + /** + * Alias for calling [Builder.ongoingNegotiations] with + * `ongoingNegotiations.orElse(null)`. + */ + fun ongoingNegotiations( + ongoingNegotiations: Optional + ) = ongoingNegotiations(ongoingNegotiations.getOrNull()) + + /** + * Sets [Builder.ongoingNegotiations] to an arbitrary JSON value. + * + * You should usually call [Builder.ongoingNegotiations] with a well-typed + * [OngoingNegotiations] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun ongoingNegotiations( + ongoingNegotiations: JsonField + ) = apply { this.ongoingNegotiations = ongoingNegotiations } + + /** Purchase information and quality issue. */ + fun purchaseInfoAndQualityIssue(purchaseInfoAndQualityIssue: String) = + purchaseInfoAndQualityIssue(JsonField.of(purchaseInfoAndQualityIssue)) + + /** + * Sets [Builder.purchaseInfoAndQualityIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndQualityIssue] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun purchaseInfoAndQualityIssue( + purchaseInfoAndQualityIssue: JsonField + ) = apply { this.purchaseInfoAndQualityIssue = purchaseInfoAndQualityIssue } + + /** + * Whether the dispute is related to the quality of food from an eating + * place or restaurant. Must be provided when Merchant Category Code (MCC) + * is 5812, 5813 or 5814. + */ + fun restaurantFoodRelated(restaurantFoodRelated: RestaurantFoodRelated?) = + restaurantFoodRelated(JsonField.ofNullable(restaurantFoodRelated)) + + /** + * Alias for calling [Builder.restaurantFoodRelated] with + * `restaurantFoodRelated.orElse(null)`. + */ + fun restaurantFoodRelated( + restaurantFoodRelated: Optional + ) = restaurantFoodRelated(restaurantFoodRelated.getOrNull()) + + /** + * Sets [Builder.restaurantFoodRelated] to an arbitrary JSON value. + * + * You should usually call [Builder.restaurantFoodRelated] with a well-typed + * [RestaurantFoodRelated] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun restaurantFoodRelated( + restaurantFoodRelated: JsonField + ) = apply { this.restaurantFoodRelated = restaurantFoodRelated } + + /** Services received at. */ + fun servicesReceivedAt(servicesReceivedAt: LocalDate) = + servicesReceivedAt(JsonField.of(servicesReceivedAt)) + + /** + * Sets [Builder.servicesReceivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.servicesReceivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun servicesReceivedAt(servicesReceivedAt: JsonField) = apply { + this.servicesReceivedAt = servicesReceivedAt + } + + 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 [ConsumerQualityServices]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .cardholderPaidToHaveWorkRedone() + * .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription() + * .ongoingNegotiations() + * .purchaseInfoAndQualityIssue() + * .restaurantFoodRelated() + * .servicesReceivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerQualityServices = + ConsumerQualityServices( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired( + "cardholderPaidToHaveWorkRedone", + cardholderPaidToHaveWorkRedone, + ), + checkRequired( + "nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription", + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + ), + checkRequired("ongoingNegotiations", ongoingNegotiations), + checkRequired( + "purchaseInfoAndQualityIssue", + purchaseInfoAndQualityIssue, + ), + checkRequired("restaurantFoodRelated", restaurantFoodRelated), + checkRequired("servicesReceivedAt", servicesReceivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerQualityServices = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + cardholderPaidToHaveWorkRedone().ifPresent { it.validate() } + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription() + .validate() + ongoingNegotiations().ifPresent { it.validate() } + purchaseInfoAndQualityIssue() + restaurantFoodRelated().ifPresent { it.validate() } + servicesReceivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderPaidToHaveWorkRedone.asKnown().getOrNull()?.validity() + ?: 0) + + (nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .asKnown() + .getOrNull() + ?.validity() ?: 0) + + (ongoingNegotiations.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndQualityIssue.asKnown().isPresent) 1 else 0) + + (restaurantFoodRelated.asKnown().getOrNull()?.validity() ?: 0) + + (if (servicesReceivedAt.asKnown().isPresent) 1 else 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = + acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = + apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a + * well-typed [AcceptedByMerchant] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acceptedByMerchant( + acceptedByMerchant: JsonField + ) = apply { this.acceptedByMerchant = acceptedByMerchant } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] + * 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic + fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + acceptedByMerchant, + canceledAt, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Cardholder paid to have work redone. */ + class CardholderPaidToHaveWorkRedone + @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 { + + /** Cardholder did not pay to have work redone. */ + @JvmField + val DID_NOT_PAY_TO_HAVE_WORK_REDONE = + of("did_not_pay_to_have_work_redone") + + /** Cardholder paid to have work redone. */ + @JvmField val PAID_TO_HAVE_WORK_REDONE = of("paid_to_have_work_redone") + + @JvmStatic + fun of(value: String) = + CardholderPaidToHaveWorkRedone(JsonField.of(value)) + } + + /** An enum containing [CardholderPaidToHaveWorkRedone]'s known values. */ + enum class Known { + /** Cardholder did not pay to have work redone. */ + DID_NOT_PAY_TO_HAVE_WORK_REDONE, + /** Cardholder paid to have work redone. */ + PAID_TO_HAVE_WORK_REDONE, + } + + /** + * An enum containing [CardholderPaidToHaveWorkRedone]'s known values, as + * well as an [_UNKNOWN] member. + * + * An instance of [CardholderPaidToHaveWorkRedone] can contain an unknown + * value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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 did not pay to have work redone. */ + DID_NOT_PAY_TO_HAVE_WORK_REDONE, + /** Cardholder paid to have work redone. */ + PAID_TO_HAVE_WORK_REDONE, + /** + * An enum member indicating that [CardholderPaidToHaveWorkRedone] 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) { + DID_NOT_PAY_TO_HAVE_WORK_REDONE -> + Value.DID_NOT_PAY_TO_HAVE_WORK_REDONE + PAID_TO_HAVE_WORK_REDONE -> Value.PAID_TO_HAVE_WORK_REDONE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DID_NOT_PAY_TO_HAVE_WORK_REDONE -> + Known.DID_NOT_PAY_TO_HAVE_WORK_REDONE + PAID_TO_HAVE_WORK_REDONE -> Known.PAID_TO_HAVE_WORK_REDONE + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderPaidToHaveWorkRedone: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CardholderPaidToHaveWorkRedone = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderPaidToHaveWorkRedone && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Non-fiat currency or non-fungible token related and not matching description. + */ + class NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + @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 { + + /** Not related. */ + @JvmField val NOT_RELATED = of("not_related") + + /** Related. */ + @JvmField val RELATED = of("related") + + @JvmStatic + fun of(value: String) = + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + JsonField.of(value) + ) + } + + /** + * An enum containing + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]'s + * known values. + */ + enum class Known { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + } + + /** + * An enum containing + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]'s + * known values, as well as an [_UNKNOWN] member. + * + * An instance of + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] can + * contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + /** + * An enum member indicating that + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] + * 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) { + NOT_RELATED -> Value.NOT_RELATED + RELATED -> Value.RELATED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_RELATED -> Known.NOT_RELATED + RELATED -> Known.RELATED + else -> + throw IncreaseInvalidDataException( + "Unknown NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription && + value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing + * negotiations. + */ + class OngoingNegotiations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val issuerFirstNotifiedAt: JsonField, + private val startedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + issuerFirstNotifiedAt: JsonField = JsonMissing.of(), + @JsonProperty("started_at") + @ExcludeMissing + startedAt: JsonField = JsonMissing.of(), + ) : this(explanation, issuerFirstNotifiedAt, startedAt, mutableMapOf()) + + /** + * Explanation of the previous ongoing negotiations between the cardholder + * and merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Date the cardholder first notified the issuer of the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun issuerFirstNotifiedAt(): LocalDate = + issuerFirstNotifiedAt.getRequired("issuer_first_notified_at") + + /** + * Started at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun startedAt(): LocalDate = startedAt.getRequired("started_at") + + /** + * 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 [issuerFirstNotifiedAt]. + * + * Unlike [issuerFirstNotifiedAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + fun _issuerFirstNotifiedAt(): JsonField = issuerFirstNotifiedAt + + /** + * Returns the raw JSON value of [startedAt]. + * + * Unlike [startedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("started_at") + @ExcludeMissing + fun _startedAt(): JsonField = startedAt + + @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 + * [OngoingNegotiations]. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OngoingNegotiations]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var issuerFirstNotifiedAt: JsonField? = null + private var startedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(ongoingNegotiations: OngoingNegotiations) = apply { + explanation = ongoingNegotiations.explanation + issuerFirstNotifiedAt = ongoingNegotiations.issuerFirstNotifiedAt + startedAt = ongoingNegotiations.startedAt + additionalProperties = + ongoingNegotiations.additionalProperties.toMutableMap() + } + + /** + * Explanation of the previous ongoing negotiations between the + * cardholder and merchant. + */ + fun explanation(explanation: String) = + explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Date the cardholder first notified the issuer of the dispute. */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: LocalDate) = + issuerFirstNotifiedAt(JsonField.of(issuerFirstNotifiedAt)) + + /** + * Sets [Builder.issuerFirstNotifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerFirstNotifiedAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: JsonField) = + apply { + this.issuerFirstNotifiedAt = issuerFirstNotifiedAt + } + + /** Started at. */ + fun startedAt(startedAt: LocalDate) = startedAt(JsonField.of(startedAt)) + + /** + * Sets [Builder.startedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun startedAt(startedAt: JsonField) = apply { + this.startedAt = startedAt + } + + 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 [OngoingNegotiations]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OngoingNegotiations = + OngoingNegotiations( + checkRequired("explanation", explanation), + checkRequired("issuerFirstNotifiedAt", issuerFirstNotifiedAt), + checkRequired("startedAt", startedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OngoingNegotiations = apply { + if (validated) { + return@apply + } + + explanation() + issuerFirstNotifiedAt() + startedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (issuerFirstNotifiedAt.asKnown().isPresent) 1 else 0) + + (if (startedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OngoingNegotiations && + explanation == other.explanation && + issuerFirstNotifiedAt == other.issuerFirstNotifiedAt && + startedAt == other.startedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + issuerFirstNotifiedAt, + startedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OngoingNegotiations{explanation=$explanation, issuerFirstNotifiedAt=$issuerFirstNotifiedAt, startedAt=$startedAt, additionalProperties=$additionalProperties}" + } + + /** + * Whether the dispute is related to the quality of food from an eating place or + * restaurant. Must be provided when Merchant Category Code (MCC) is 5812, 5813 + * or 5814. + */ + class RestaurantFoodRelated + @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 { + + /** Not related. */ + @JvmField val NOT_RELATED = of("not_related") + + /** Related. */ + @JvmField val RELATED = of("related") + + @JvmStatic + fun of(value: String) = RestaurantFoodRelated(JsonField.of(value)) + } + + /** An enum containing [RestaurantFoodRelated]'s known values. */ + enum class Known { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + } + + /** + * An enum containing [RestaurantFoodRelated]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RestaurantFoodRelated] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + /** + * An enum member indicating that [RestaurantFoodRelated] 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) { + NOT_RELATED -> Value.NOT_RELATED + RELATED -> Value.RELATED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_RELATED -> Known.NOT_RELATED + RELATED -> Known.RELATED + else -> + throw IncreaseInvalidDataException( + "Unknown RestaurantFoodRelated: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RestaurantFoodRelated = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RestaurantFoodRelated && 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 ConsumerQualityServices && + cardholderCancellation == other.cardholderCancellation && + cardholderPaidToHaveWorkRedone == + other.cardholderPaidToHaveWorkRedone && + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription == + other + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription && + ongoingNegotiations == other.ongoingNegotiations && + purchaseInfoAndQualityIssue == other.purchaseInfoAndQualityIssue && + restaurantFoodRelated == other.restaurantFoodRelated && + servicesReceivedAt == other.servicesReceivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + cardholderPaidToHaveWorkRedone, + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + ongoingNegotiations, + purchaseInfoAndQualityIssue, + restaurantFoodRelated, + servicesReceivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerQualityServices{cardholderCancellation=$cardholderCancellation, cardholderPaidToHaveWorkRedone=$cardholderPaidToHaveWorkRedone, nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription=$nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, ongoingNegotiations=$ongoingNegotiations, purchaseInfoAndQualityIssue=$purchaseInfoAndQualityIssue, restaurantFoodRelated=$restaurantFoodRelated, servicesReceivedAt=$servicesReceivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Services misrepresentation. Present if and only if `category` is + * `consumer_services_misrepresentation`. + */ + class ConsumerServicesMisrepresentation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val misrepresentationExplanation: JsonField, + private val purchaseExplanation: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = + JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + misrepresentationExplanation: JsonField = JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Misrepresentation explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun misrepresentationExplanation(): String = + misrepresentationExplanation.getRequired("misrepresentation_explanation") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [misrepresentationExplanation]. + * + * Unlike [misrepresentationExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + fun _misrepresentationExplanation(): JsonField = + misrepresentationExplanation + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerServicesMisrepresentation]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesMisrepresentation]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = + null + private var merchantResolutionAttempted: + JsonField? = + null + private var misrepresentationExplanation: JsonField? = null + private var purchaseExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerServicesMisrepresentation: ConsumerServicesMisrepresentation + ) = apply { + cardholderCancellation = + consumerServicesMisrepresentation.cardholderCancellation + merchantResolutionAttempted = + consumerServicesMisrepresentation.merchantResolutionAttempted + misrepresentationExplanation = + consumerServicesMisrepresentation.misrepresentationExplanation + purchaseExplanation = + consumerServicesMisrepresentation.purchaseExplanation + receivedAt = consumerServicesMisrepresentation.receivedAt + additionalProperties = + consumerServicesMisrepresentation.additionalProperties + .toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a + * well-typed [CardholderCancellation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Misrepresentation explanation. */ + fun misrepresentationExplanation(misrepresentationExplanation: String) = + misrepresentationExplanation(JsonField.of(misrepresentationExplanation)) + + /** + * Sets [Builder.misrepresentationExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.misrepresentationExplanation] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun misrepresentationExplanation( + misrepresentationExplanation: JsonField + ) = apply { + this.misrepresentationExplanation = misrepresentationExplanation + } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerServicesMisrepresentation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesMisrepresentation = + ConsumerServicesMisrepresentation( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired( + "misrepresentationExplanation", + misrepresentationExplanation, + ), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesMisrepresentation = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + merchantResolutionAttempted().validate() + misrepresentationExplanation() + purchaseExplanation() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (misrepresentationExplanation.asKnown().isPresent) 1 else 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = + acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = + apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a + * well-typed [AcceptedByMerchant] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acceptedByMerchant( + acceptedByMerchant: JsonField + ) = apply { this.acceptedByMerchant = acceptedByMerchant } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] + * 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic + fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + acceptedByMerchant, + canceledAt, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && 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 ConsumerServicesMisrepresentation && + cardholderCancellation == other.cardholderCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + misrepresentationExplanation == other.misrepresentationExplanation && + purchaseExplanation == other.purchaseExplanation && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesMisrepresentation{cardholderCancellation=$cardholderCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, misrepresentationExplanation=$misrepresentationExplanation, purchaseExplanation=$purchaseExplanation, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Services not as described. Present if and only if `category` is + * `consumer_services_not_as_described`. + */ + class ConsumerServicesNotAsDescribed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = + JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + merchantResolutionAttempted, + receivedAt, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerServicesNotAsDescribed]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesNotAsDescribed]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = + null + private var merchantResolutionAttempted: + JsonField? = + null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerServicesNotAsDescribed: ConsumerServicesNotAsDescribed + ) = apply { + cardholderCancellation = + consumerServicesNotAsDescribed.cardholderCancellation + merchantResolutionAttempted = + consumerServicesNotAsDescribed.merchantResolutionAttempted + receivedAt = consumerServicesNotAsDescribed.receivedAt + additionalProperties = + consumerServicesNotAsDescribed.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a + * well-typed [CardholderCancellation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerServicesNotAsDescribed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesNotAsDescribed = + ConsumerServicesNotAsDescribed( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesNotAsDescribed = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + merchantResolutionAttempted().validate() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = + acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = + apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a + * well-typed [AcceptedByMerchant] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun acceptedByMerchant( + acceptedByMerchant: JsonField + ) = apply { this.acceptedByMerchant = acceptedByMerchant } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] + * 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic + fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + acceptedByMerchant, + canceledAt, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && 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 ConsumerServicesNotAsDescribed && + cardholderCancellation == other.cardholderCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + merchantResolutionAttempted, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesNotAsDescribed{cardholderCancellation=$cardholderCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Services not received. Present if and only if `category` is + * `consumer_services_not_received`. + */ + class ConsumerServicesNotReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationOutcome: JsonField, + private val cardholderCancellationPriorToExpectedReceipt: + JsonField, + private val lastExpectedReceiptAt: JsonField, + private val merchantCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val noCancellation: JsonValue, + private val purchaseInfoAndExplanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_outcome") + @ExcludeMissing + cancellationOutcome: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of(), + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + lastExpectedReceiptAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_cancellation") + @ExcludeMissing + merchantCancellation: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("no_cancellation") + @ExcludeMissing + noCancellation: JsonValue = JsonMissing.of(), + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + purchaseInfoAndExplanation: JsonField = JsonMissing.of(), + ) : this( + cancellationOutcome, + cardholderCancellationPriorToExpectedReceipt, + lastExpectedReceiptAt, + merchantCancellation, + merchantResolutionAttempted, + noCancellation, + purchaseInfoAndExplanation, + mutableMapOf(), + ) + + /** + * Cancellation outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationOutcome(): CancellationOutcome = + cancellationOutcome.getRequired("cancellation_outcome") + + /** + * Cardholder cancellation prior to expected receipt. Present if and only if + * `cancellation_outcome` is + * `cardholder_cancellation_prior_to_expected_receipt`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderCancellationPriorToExpectedReceipt(): + Optional = + cardholderCancellationPriorToExpectedReceipt.getOptional( + "cardholder_cancellation_prior_to_expected_receipt" + ) + + /** + * Last expected receipt at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastExpectedReceiptAt(): LocalDate = + lastExpectedReceiptAt.getRequired("last_expected_receipt_at") + + /** + * Merchant cancellation. Present if and only if `cancellation_outcome` is + * `merchant_cancellation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantCancellation(): Optional = + merchantCancellation.getOptional("merchant_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * No cancellation. Present if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + @JsonProperty("no_cancellation") + @ExcludeMissing + fun _noCancellation(): JsonValue = noCancellation + + /** + * Purchase information and explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseInfoAndExplanation(): String = + purchaseInfoAndExplanation.getRequired("purchase_info_and_explanation") + + /** + * Returns the raw JSON value of [cancellationOutcome]. + * + * Unlike [cancellationOutcome], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cancellation_outcome") + @ExcludeMissing + fun _cancellationOutcome(): JsonField = cancellationOutcome + + /** + * Returns the raw JSON value of [cardholderCancellationPriorToExpectedReceipt]. + * + * Unlike [cardholderCancellationPriorToExpectedReceipt], this method doesn't + * throw if the JSON field has an unexpected type. + */ + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + fun _cardholderCancellationPriorToExpectedReceipt(): + JsonField = + cardholderCancellationPriorToExpectedReceipt + + /** + * Returns the raw JSON value of [lastExpectedReceiptAt]. + * + * Unlike [lastExpectedReceiptAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + fun _lastExpectedReceiptAt(): JsonField = lastExpectedReceiptAt + + /** + * Returns the raw JSON value of [merchantCancellation]. + * + * Unlike [merchantCancellation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_cancellation") + @ExcludeMissing + fun _merchantCancellation(): JsonField = + merchantCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseInfoAndExplanation]. + * + * Unlike [purchaseInfoAndExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + fun _purchaseInfoAndExplanation(): JsonField = + purchaseInfoAndExplanation + + @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 + * [ConsumerServicesNotReceived]. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .cardholderCancellationPriorToExpectedReceipt() + * .lastExpectedReceiptAt() + * .merchantCancellation() + * .merchantResolutionAttempted() + * .noCancellation() + * .purchaseInfoAndExplanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesNotReceived]. */ + class Builder internal constructor() { + + private var cancellationOutcome: JsonField? = null + private var cardholderCancellationPriorToExpectedReceipt: + JsonField? = + null + private var lastExpectedReceiptAt: JsonField? = null + private var merchantCancellation: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var noCancellation: JsonValue? = null + private var purchaseInfoAndExplanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerServicesNotReceived: ConsumerServicesNotReceived + ) = apply { + cancellationOutcome = consumerServicesNotReceived.cancellationOutcome + cardholderCancellationPriorToExpectedReceipt = + consumerServicesNotReceived + .cardholderCancellationPriorToExpectedReceipt + lastExpectedReceiptAt = + consumerServicesNotReceived.lastExpectedReceiptAt + merchantCancellation = consumerServicesNotReceived.merchantCancellation + merchantResolutionAttempted = + consumerServicesNotReceived.merchantResolutionAttempted + noCancellation = consumerServicesNotReceived.noCancellation + purchaseInfoAndExplanation = + consumerServicesNotReceived.purchaseInfoAndExplanation + additionalProperties = + consumerServicesNotReceived.additionalProperties.toMutableMap() + } + + /** Cancellation outcome. */ + fun cancellationOutcome(cancellationOutcome: CancellationOutcome) = + cancellationOutcome(JsonField.of(cancellationOutcome)) + + /** + * Sets [Builder.cancellationOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationOutcome] with a well-typed + * [CancellationOutcome] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cancellationOutcome( + cancellationOutcome: JsonField + ) = apply { this.cancellationOutcome = cancellationOutcome } + + /** + * Cardholder cancellation prior to expected receipt. Present if and only if + * `cancellation_outcome` is + * `cardholder_cancellation_prior_to_expected_receipt`. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt? + ) = + cardholderCancellationPriorToExpectedReceipt( + JsonField.ofNullable(cardholderCancellationPriorToExpectedReceipt) + ) + + /** + * Alias for calling [Builder.cardholderCancellationPriorToExpectedReceipt] + * with `cardholderCancellationPriorToExpectedReceipt.orElse(null)`. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + Optional + ) = + cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt.getOrNull() + ) + + /** + * Sets [Builder.cardholderCancellationPriorToExpectedReceipt] to an + * arbitrary JSON value. + * + * You should usually call + * [Builder.cardholderCancellationPriorToExpectedReceipt] with a well-typed + * [CardholderCancellationPriorToExpectedReceipt] value instead. This method + * is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + JsonField + ) = apply { + this.cardholderCancellationPriorToExpectedReceipt = + cardholderCancellationPriorToExpectedReceipt + } + + /** Last expected receipt at. */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: LocalDate) = + lastExpectedReceiptAt(JsonField.of(lastExpectedReceiptAt)) + + /** + * Sets [Builder.lastExpectedReceiptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastExpectedReceiptAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: JsonField) = + apply { + this.lastExpectedReceiptAt = lastExpectedReceiptAt + } + + /** + * Merchant cancellation. Present if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + fun merchantCancellation(merchantCancellation: MerchantCancellation?) = + merchantCancellation(JsonField.ofNullable(merchantCancellation)) + + /** + * Alias for calling [Builder.merchantCancellation] with + * `merchantCancellation.orElse(null)`. + */ + fun merchantCancellation( + merchantCancellation: Optional + ) = merchantCancellation(merchantCancellation.getOrNull()) + + /** + * Sets [Builder.merchantCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCancellation] with a well-typed + * [MerchantCancellation] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantCancellation( + merchantCancellation: JsonField + ) = apply { this.merchantCancellation = merchantCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * No cancellation. Present if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + fun noCancellation(noCancellation: JsonValue) = apply { + this.noCancellation = noCancellation + } + + /** Purchase information and explanation. */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: String) = + purchaseInfoAndExplanation(JsonField.of(purchaseInfoAndExplanation)) + + /** + * Sets [Builder.purchaseInfoAndExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndExplanation] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun purchaseInfoAndExplanation( + purchaseInfoAndExplanation: JsonField + ) = apply { this.purchaseInfoAndExplanation = purchaseInfoAndExplanation } + + 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 [ConsumerServicesNotReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .cardholderCancellationPriorToExpectedReceipt() + * .lastExpectedReceiptAt() + * .merchantCancellation() + * .merchantResolutionAttempted() + * .noCancellation() + * .purchaseInfoAndExplanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesNotReceived = + ConsumerServicesNotReceived( + checkRequired("cancellationOutcome", cancellationOutcome), + checkRequired( + "cardholderCancellationPriorToExpectedReceipt", + cardholderCancellationPriorToExpectedReceipt, + ), + checkRequired("lastExpectedReceiptAt", lastExpectedReceiptAt), + checkRequired("merchantCancellation", merchantCancellation), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("noCancellation", noCancellation), + checkRequired( + "purchaseInfoAndExplanation", + purchaseInfoAndExplanation, + ), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesNotReceived = apply { + if (validated) { + return@apply + } + + cancellationOutcome().validate() + cardholderCancellationPriorToExpectedReceipt().ifPresent { it.validate() } + lastExpectedReceiptAt() + merchantCancellation().ifPresent { it.validate() } + merchantResolutionAttempted().validate() + purchaseInfoAndExplanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderCancellationPriorToExpectedReceipt + .asKnown() + .getOrNull() + ?.validity() ?: 0) + + (if (lastExpectedReceiptAt.asKnown().isPresent) 1 else 0) + + (merchantCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndExplanation.asKnown().isPresent) 1 else 0) + + /** Cancellation outcome. */ + class CancellationOutcome + @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 { + + /** Cardholder cancellation prior to expected receipt. */ + @JvmField + val CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT = + of("cardholder_cancellation_prior_to_expected_receipt") + + /** Merchant cancellation. */ + @JvmField val MERCHANT_CANCELLATION = of("merchant_cancellation") + + /** No cancellation. */ + @JvmField val NO_CANCELLATION = of("no_cancellation") + + @JvmStatic + fun of(value: String) = CancellationOutcome(JsonField.of(value)) + } + + /** An enum containing [CancellationOutcome]'s known values. */ + enum class Known { + /** Cardholder cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + } + + /** + * An enum containing [CancellationOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CancellationOutcome] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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 cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + /** + * An enum member indicating that [CancellationOutcome] 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_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Value.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Value.MERCHANT_CANCELLATION + NO_CANCELLATION -> Value.NO_CANCELLATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Known.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Known.MERCHANT_CANCELLATION + NO_CANCELLATION -> Known.NO_CANCELLATION + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Cardholder cancellation prior to expected receipt. Present if and only if + * `cancellation_outcome` is + * `cardholder_cancellation_prior_to_expected_receipt`. + */ + class CardholderCancellationPriorToExpectedReceipt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellationPriorToExpectedReceipt]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = apply { + canceledAt = cardholderCancellationPriorToExpectedReceipt.canceledAt + reason = cardholderCancellationPriorToExpectedReceipt.reason + additionalProperties = + cardholderCancellationPriorToExpectedReceipt + .additionalProperties + .toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] + * 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 } + + 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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellationPriorToExpectedReceipt = + CardholderCancellationPriorToExpectedReceipt( + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellationPriorToExpectedReceipt = apply { + if (validated) { + return@apply + } + + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderCancellationPriorToExpectedReceipt && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellationPriorToExpectedReceipt{canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Merchant cancellation. Present if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + class MerchantCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of() + ) : this(canceledAt, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + @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 + * [MerchantCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCancellation: MerchantCancellation) = apply { + canceledAt = merchantCancellation.canceledAt + additionalProperties = + merchantCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = + canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + 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 [MerchantCancellation]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCancellation = + MerchantCancellation( + checkRequired("canceledAt", canceledAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCancellation && + canceledAt == other.canceledAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCancellation{canceledAt=$canceledAt, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && 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 ConsumerServicesNotReceived && + cancellationOutcome == other.cancellationOutcome && + cardholderCancellationPriorToExpectedReceipt == + other.cardholderCancellationPriorToExpectedReceipt && + lastExpectedReceiptAt == other.lastExpectedReceiptAt && + merchantCancellation == other.merchantCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + noCancellation == other.noCancellation && + purchaseInfoAndExplanation == other.purchaseInfoAndExplanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationOutcome, + cardholderCancellationPriorToExpectedReceipt, + lastExpectedReceiptAt, + merchantCancellation, + merchantResolutionAttempted, + noCancellation, + purchaseInfoAndExplanation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesNotReceived{cancellationOutcome=$cancellationOutcome, cardholderCancellationPriorToExpectedReceipt=$cardholderCancellationPriorToExpectedReceipt, lastExpectedReceiptAt=$lastExpectedReceiptAt, merchantCancellation=$merchantCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, noCancellation=$noCancellation, purchaseInfoAndExplanation=$purchaseInfoAndExplanation, additionalProperties=$additionalProperties}" + } + + /** Fraud. Present if and only if `category` is `fraud`. */ + class Fraud + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fraudType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fraud_type") + @ExcludeMissing + fraudType: JsonField = JsonMissing.of() + ) : this(fraudType, mutableMapOf()) + + /** + * Fraud type. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun fraudType(): FraudType = fraudType.getRequired("fraud_type") + + /** + * Returns the raw JSON value of [fraudType]. + * + * Unlike [fraudType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("fraud_type") + @ExcludeMissing + fun _fraudType(): JsonField = fraudType + + @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 [Fraud]. + * + * The following fields are required: + * ```java + * .fraudType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Fraud]. */ + class Builder internal constructor() { + + private var fraudType: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(fraud: Fraud) = apply { + fraudType = fraud.fraudType + additionalProperties = fraud.additionalProperties.toMutableMap() + } + + /** Fraud type. */ + fun fraudType(fraudType: FraudType) = fraudType(JsonField.of(fraudType)) + + /** + * Sets [Builder.fraudType] to an arbitrary JSON value. + * + * You should usually call [Builder.fraudType] with a well-typed [FraudType] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fraudType(fraudType: JsonField) = apply { + this.fraudType = fraudType + } + + 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 [Fraud]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fraudType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Fraud = + Fraud( + checkRequired("fraudType", fraudType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Fraud = apply { + if (validated) { + return@apply + } + + fraudType().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (fraudType.asKnown().getOrNull()?.validity() ?: 0) + + /** Fraud type. */ + class FraudType + @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 { + + /** Account or credentials takeover. */ + @JvmField + val ACCOUNT_OR_CREDENTIALS_TAKEOVER = + of("account_or_credentials_takeover") + + /** Card not received as issued. */ + @JvmField + val CARD_NOT_RECEIVED_AS_ISSUED = of("card_not_received_as_issued") + + /** Fraudulent application. */ + @JvmField val FRAUDULENT_APPLICATION = of("fraudulent_application") + + /** Fraudulent use of account number. */ + @JvmField + val FRAUDULENT_USE_OF_ACCOUNT_NUMBER = + of("fraudulent_use_of_account_number") + + /** Incorrect processing. */ + @JvmField val INCORRECT_PROCESSING = of("incorrect_processing") + + /** Issuer reported counterfeit. */ + @JvmField + val ISSUER_REPORTED_COUNTERFEIT = of("issuer_reported_counterfeit") + + /** Lost. */ + @JvmField val LOST = of("lost") + + /** Manipulation of account holder. */ + @JvmField + val MANIPULATION_OF_ACCOUNT_HOLDER = + of("manipulation_of_account_holder") + + /** Merchant misrepresentation. */ + @JvmField + val MERCHANT_MISREPRESENTATION = of("merchant_misrepresentation") + + /** Miscellaneous. */ + @JvmField val MISCELLANEOUS = of("miscellaneous") + + /** Stolen. */ + @JvmField val STOLEN = of("stolen") + + @JvmStatic fun of(value: String) = FraudType(JsonField.of(value)) + } + + /** An enum containing [FraudType]'s known values. */ + enum class Known { + /** Account or credentials takeover. */ + ACCOUNT_OR_CREDENTIALS_TAKEOVER, + /** Card not received as issued. */ + CARD_NOT_RECEIVED_AS_ISSUED, + /** Fraudulent application. */ + FRAUDULENT_APPLICATION, + /** Fraudulent use of account number. */ + FRAUDULENT_USE_OF_ACCOUNT_NUMBER, + /** Incorrect processing. */ + INCORRECT_PROCESSING, + /** Issuer reported counterfeit. */ + ISSUER_REPORTED_COUNTERFEIT, + /** Lost. */ + LOST, + /** Manipulation of account holder. */ + MANIPULATION_OF_ACCOUNT_HOLDER, + /** Merchant misrepresentation. */ + MERCHANT_MISREPRESENTATION, + /** Miscellaneous. */ + MISCELLANEOUS, + /** Stolen. */ + STOLEN, + } + + /** + * An enum containing [FraudType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [FraudType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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 or credentials takeover. */ + ACCOUNT_OR_CREDENTIALS_TAKEOVER, + /** Card not received as issued. */ + CARD_NOT_RECEIVED_AS_ISSUED, + /** Fraudulent application. */ + FRAUDULENT_APPLICATION, + /** Fraudulent use of account number. */ + FRAUDULENT_USE_OF_ACCOUNT_NUMBER, + /** Incorrect processing. */ + INCORRECT_PROCESSING, + /** Issuer reported counterfeit. */ + ISSUER_REPORTED_COUNTERFEIT, + /** Lost. */ + LOST, + /** Manipulation of account holder. */ + MANIPULATION_OF_ACCOUNT_HOLDER, + /** Merchant misrepresentation. */ + MERCHANT_MISREPRESENTATION, + /** Miscellaneous. */ + MISCELLANEOUS, + /** Stolen. */ + STOLEN, + /** + * An enum member indicating that [FraudType] 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_OR_CREDENTIALS_TAKEOVER -> + Value.ACCOUNT_OR_CREDENTIALS_TAKEOVER + CARD_NOT_RECEIVED_AS_ISSUED -> Value.CARD_NOT_RECEIVED_AS_ISSUED + FRAUDULENT_APPLICATION -> Value.FRAUDULENT_APPLICATION + FRAUDULENT_USE_OF_ACCOUNT_NUMBER -> + Value.FRAUDULENT_USE_OF_ACCOUNT_NUMBER + INCORRECT_PROCESSING -> Value.INCORRECT_PROCESSING + ISSUER_REPORTED_COUNTERFEIT -> Value.ISSUER_REPORTED_COUNTERFEIT + LOST -> Value.LOST + MANIPULATION_OF_ACCOUNT_HOLDER -> + Value.MANIPULATION_OF_ACCOUNT_HOLDER + MERCHANT_MISREPRESENTATION -> Value.MERCHANT_MISREPRESENTATION + MISCELLANEOUS -> Value.MISCELLANEOUS + STOLEN -> Value.STOLEN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_OR_CREDENTIALS_TAKEOVER -> + Known.ACCOUNT_OR_CREDENTIALS_TAKEOVER + CARD_NOT_RECEIVED_AS_ISSUED -> Known.CARD_NOT_RECEIVED_AS_ISSUED + FRAUDULENT_APPLICATION -> Known.FRAUDULENT_APPLICATION + FRAUDULENT_USE_OF_ACCOUNT_NUMBER -> + Known.FRAUDULENT_USE_OF_ACCOUNT_NUMBER + INCORRECT_PROCESSING -> Known.INCORRECT_PROCESSING + ISSUER_REPORTED_COUNTERFEIT -> Known.ISSUER_REPORTED_COUNTERFEIT + LOST -> Known.LOST + MANIPULATION_OF_ACCOUNT_HOLDER -> + Known.MANIPULATION_OF_ACCOUNT_HOLDER + MERCHANT_MISREPRESENTATION -> Known.MERCHANT_MISREPRESENTATION + MISCELLANEOUS -> Known.MISCELLANEOUS + STOLEN -> Known.STOLEN + else -> + throw IncreaseInvalidDataException("Unknown FraudType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): FraudType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FraudType && 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 Fraud && + fraudType == other.fraudType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(fraudType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Fraud{fraudType=$fraudType, additionalProperties=$additionalProperties}" + } + + /** Processing error. Present if and only if `category` is `processing_error`. */ + class ProcessingError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val duplicateTransaction: JsonField, + private val errorReason: JsonField, + private val incorrectAmount: JsonField, + private val merchantResolutionAttempted: JsonField, + private val paidByOtherMeans: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("duplicate_transaction") + @ExcludeMissing + duplicateTransaction: JsonField = JsonMissing.of(), + @JsonProperty("error_reason") + @ExcludeMissing + errorReason: JsonField = JsonMissing.of(), + @JsonProperty("incorrect_amount") + @ExcludeMissing + incorrectAmount: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("paid_by_other_means") + @ExcludeMissing + paidByOtherMeans: JsonField = JsonMissing.of(), + ) : this( + duplicateTransaction, + errorReason, + incorrectAmount, + merchantResolutionAttempted, + paidByOtherMeans, + mutableMapOf(), + ) + + /** + * Duplicate transaction. Present if and only if `error_reason` is + * `duplicate_transaction`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun duplicateTransaction(): Optional = + duplicateTransaction.getOptional("duplicate_transaction") + + /** + * Error reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun errorReason(): ErrorReason = errorReason.getRequired("error_reason") + + /** + * Incorrect amount. Present if and only if `error_reason` is + * `incorrect_amount`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun incorrectAmount(): Optional = + incorrectAmount.getOptional("incorrect_amount") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Paid by other means. Present if and only if `error_reason` is + * `paid_by_other_means`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun paidByOtherMeans(): Optional = + paidByOtherMeans.getOptional("paid_by_other_means") + + /** + * Returns the raw JSON value of [duplicateTransaction]. + * + * Unlike [duplicateTransaction], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("duplicate_transaction") + @ExcludeMissing + fun _duplicateTransaction(): JsonField = + duplicateTransaction + + /** + * Returns the raw JSON value of [errorReason]. + * + * Unlike [errorReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("error_reason") + @ExcludeMissing + fun _errorReason(): JsonField = errorReason + + /** + * Returns the raw JSON value of [incorrectAmount]. + * + * Unlike [incorrectAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("incorrect_amount") + @ExcludeMissing + fun _incorrectAmount(): JsonField = incorrectAmount + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [paidByOtherMeans]. + * + * Unlike [paidByOtherMeans], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("paid_by_other_means") + @ExcludeMissing + fun _paidByOtherMeans(): JsonField = paidByOtherMeans + + @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 + * [ProcessingError]. + * + * The following fields are required: + * ```java + * .duplicateTransaction() + * .errorReason() + * .incorrectAmount() + * .merchantResolutionAttempted() + * .paidByOtherMeans() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProcessingError]. */ + class Builder internal constructor() { + + private var duplicateTransaction: JsonField? = null + private var errorReason: JsonField? = null + private var incorrectAmount: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var paidByOtherMeans: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(processingError: ProcessingError) = apply { + duplicateTransaction = processingError.duplicateTransaction + errorReason = processingError.errorReason + incorrectAmount = processingError.incorrectAmount + merchantResolutionAttempted = + processingError.merchantResolutionAttempted + paidByOtherMeans = processingError.paidByOtherMeans + additionalProperties = + processingError.additionalProperties.toMutableMap() + } + + /** + * Duplicate transaction. Present if and only if `error_reason` is + * `duplicate_transaction`. + */ + fun duplicateTransaction(duplicateTransaction: DuplicateTransaction?) = + duplicateTransaction(JsonField.ofNullable(duplicateTransaction)) + + /** + * Alias for calling [Builder.duplicateTransaction] with + * `duplicateTransaction.orElse(null)`. + */ + fun duplicateTransaction( + duplicateTransaction: Optional + ) = duplicateTransaction(duplicateTransaction.getOrNull()) + + /** + * Sets [Builder.duplicateTransaction] to an arbitrary JSON value. + * + * You should usually call [Builder.duplicateTransaction] with a well-typed + * [DuplicateTransaction] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun duplicateTransaction( + duplicateTransaction: JsonField + ) = apply { this.duplicateTransaction = duplicateTransaction } + + /** Error reason. */ + fun errorReason(errorReason: ErrorReason) = + errorReason(JsonField.of(errorReason)) + + /** + * Sets [Builder.errorReason] to an arbitrary JSON value. + * + * You should usually call [Builder.errorReason] with a well-typed + * [ErrorReason] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun errorReason(errorReason: JsonField) = apply { + this.errorReason = errorReason + } + + /** + * Incorrect amount. Present if and only if `error_reason` is + * `incorrect_amount`. + */ + fun incorrectAmount(incorrectAmount: IncorrectAmount?) = + incorrectAmount(JsonField.ofNullable(incorrectAmount)) + + /** + * Alias for calling [Builder.incorrectAmount] with + * `incorrectAmount.orElse(null)`. + */ + fun incorrectAmount(incorrectAmount: Optional) = + incorrectAmount(incorrectAmount.getOrNull()) + + /** + * Sets [Builder.incorrectAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.incorrectAmount] with a well-typed + * [IncorrectAmount] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun incorrectAmount(incorrectAmount: JsonField) = apply { + this.incorrectAmount = incorrectAmount + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * Paid by other means. Present if and only if `error_reason` is + * `paid_by_other_means`. + */ + fun paidByOtherMeans(paidByOtherMeans: PaidByOtherMeans?) = + paidByOtherMeans(JsonField.ofNullable(paidByOtherMeans)) + + /** + * Alias for calling [Builder.paidByOtherMeans] with + * `paidByOtherMeans.orElse(null)`. + */ + fun paidByOtherMeans(paidByOtherMeans: Optional) = + paidByOtherMeans(paidByOtherMeans.getOrNull()) + + /** + * Sets [Builder.paidByOtherMeans] to an arbitrary JSON value. + * + * You should usually call [Builder.paidByOtherMeans] with a well-typed + * [PaidByOtherMeans] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun paidByOtherMeans(paidByOtherMeans: JsonField) = + apply { + this.paidByOtherMeans = paidByOtherMeans + } + + 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 [ProcessingError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duplicateTransaction() + * .errorReason() + * .incorrectAmount() + * .merchantResolutionAttempted() + * .paidByOtherMeans() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProcessingError = + ProcessingError( + checkRequired("duplicateTransaction", duplicateTransaction), + checkRequired("errorReason", errorReason), + checkRequired("incorrectAmount", incorrectAmount), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("paidByOtherMeans", paidByOtherMeans), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProcessingError = apply { + if (validated) { + return@apply + } + + duplicateTransaction().ifPresent { it.validate() } + errorReason().validate() + incorrectAmount().ifPresent { it.validate() } + merchantResolutionAttempted().validate() + paidByOtherMeans().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (duplicateTransaction.asKnown().getOrNull()?.validity() ?: 0) + + (errorReason.asKnown().getOrNull()?.validity() ?: 0) + + (incorrectAmount.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (paidByOtherMeans.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Duplicate transaction. Present if and only if `error_reason` is + * `duplicate_transaction`. + */ + class DuplicateTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val otherTransactionId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("other_transaction_id") + @ExcludeMissing + otherTransactionId: JsonField = JsonMissing.of() + ) : this(otherTransactionId, mutableMapOf()) + + /** + * Other transaction ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun otherTransactionId(): String = + otherTransactionId.getRequired("other_transaction_id") + + /** + * Returns the raw JSON value of [otherTransactionId]. + * + * Unlike [otherTransactionId], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_transaction_id") + @ExcludeMissing + fun _otherTransactionId(): JsonField = otherTransactionId + + @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 + * [DuplicateTransaction]. + * + * The following fields are required: + * ```java + * .otherTransactionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DuplicateTransaction]. */ + class Builder internal constructor() { + + private var otherTransactionId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(duplicateTransaction: DuplicateTransaction) = apply { + otherTransactionId = duplicateTransaction.otherTransactionId + additionalProperties = + duplicateTransaction.additionalProperties.toMutableMap() + } + + /** Other transaction ID. */ + fun otherTransactionId(otherTransactionId: String) = + otherTransactionId(JsonField.of(otherTransactionId)) + + /** + * Sets [Builder.otherTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.otherTransactionId] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun otherTransactionId(otherTransactionId: JsonField) = apply { + this.otherTransactionId = otherTransactionId + } + + 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 [DuplicateTransaction]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .otherTransactionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DuplicateTransaction = + DuplicateTransaction( + checkRequired("otherTransactionId", otherTransactionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DuplicateTransaction = apply { + if (validated) { + return@apply + } + + otherTransactionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (otherTransactionId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DuplicateTransaction && + otherTransactionId == other.otherTransactionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(otherTransactionId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DuplicateTransaction{otherTransactionId=$otherTransactionId, additionalProperties=$additionalProperties}" + } + + /** Error reason. */ + class ErrorReason + @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 { + + /** Duplicate transaction. */ + @JvmField val DUPLICATE_TRANSACTION = of("duplicate_transaction") + + /** Incorrect amount. */ + @JvmField val INCORRECT_AMOUNT = of("incorrect_amount") + + /** Paid by other means. */ + @JvmField val PAID_BY_OTHER_MEANS = of("paid_by_other_means") + + @JvmStatic fun of(value: String) = ErrorReason(JsonField.of(value)) + } + + /** An enum containing [ErrorReason]'s known values. */ + enum class Known { + /** Duplicate transaction. */ + DUPLICATE_TRANSACTION, + /** Incorrect amount. */ + INCORRECT_AMOUNT, + /** Paid by other means. */ + PAID_BY_OTHER_MEANS, + } + + /** + * An enum containing [ErrorReason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ErrorReason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Duplicate transaction. */ + DUPLICATE_TRANSACTION, + /** Incorrect amount. */ + INCORRECT_AMOUNT, + /** Paid by other means. */ + PAID_BY_OTHER_MEANS, + /** + * An enum member indicating that [ErrorReason] 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) { + DUPLICATE_TRANSACTION -> Value.DUPLICATE_TRANSACTION + INCORRECT_AMOUNT -> Value.INCORRECT_AMOUNT + PAID_BY_OTHER_MEANS -> Value.PAID_BY_OTHER_MEANS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DUPLICATE_TRANSACTION -> Known.DUPLICATE_TRANSACTION + INCORRECT_AMOUNT -> Known.INCORRECT_AMOUNT + PAID_BY_OTHER_MEANS -> Known.PAID_BY_OTHER_MEANS + else -> + throw IncreaseInvalidDataException( + "Unknown ErrorReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ErrorReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ErrorReason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Incorrect amount. Present if and only if `error_reason` is + * `incorrect_amount`. + */ + class IncorrectAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expectedAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expected_amount") + @ExcludeMissing + expectedAmount: JsonField = JsonMissing.of() + ) : this(expectedAmount, mutableMapOf()) + + /** + * Expected amount. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun expectedAmount(): Long = expectedAmount.getRequired("expected_amount") + + /** + * Returns the raw JSON value of [expectedAmount]. + * + * Unlike [expectedAmount], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("expected_amount") + @ExcludeMissing + fun _expectedAmount(): JsonField = expectedAmount + + @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 + * [IncorrectAmount]. + * + * The following fields are required: + * ```java + * .expectedAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IncorrectAmount]. */ + class Builder internal constructor() { + + private var expectedAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(incorrectAmount: IncorrectAmount) = apply { + expectedAmount = incorrectAmount.expectedAmount + additionalProperties = + incorrectAmount.additionalProperties.toMutableMap() + } + + /** Expected amount. */ + fun expectedAmount(expectedAmount: Long) = + expectedAmount(JsonField.of(expectedAmount)) + + /** + * Sets [Builder.expectedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedAmount] with a well-typed + * [Long] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun expectedAmount(expectedAmount: JsonField) = apply { + this.expectedAmount = expectedAmount + } + + 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 [IncorrectAmount]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .expectedAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): IncorrectAmount = + IncorrectAmount( + checkRequired("expectedAmount", expectedAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): IncorrectAmount = apply { + if (validated) { + return@apply + } + + expectedAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expectedAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IncorrectAmount && + expectedAmount == other.expectedAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expectedAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "IncorrectAmount{expectedAmount=$expectedAmount, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Paid by other means. Present if and only if `error_reason` is + * `paid_by_other_means`. + */ + class PaidByOtherMeans + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val otherFormOfPaymentEvidence: + JsonField, + private val otherTransactionId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("other_form_of_payment_evidence") + @ExcludeMissing + otherFormOfPaymentEvidence: JsonField = + JsonMissing.of(), + @JsonProperty("other_transaction_id") + @ExcludeMissing + otherTransactionId: JsonField = JsonMissing.of(), + ) : this(otherFormOfPaymentEvidence, otherTransactionId, mutableMapOf()) + + /** + * Other form of payment evidence. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun otherFormOfPaymentEvidence(): OtherFormOfPaymentEvidence = + otherFormOfPaymentEvidence.getRequired("other_form_of_payment_evidence") + + /** + * Other transaction ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun otherTransactionId(): Optional = + otherTransactionId.getOptional("other_transaction_id") + + /** + * Returns the raw JSON value of [otherFormOfPaymentEvidence]. + * + * Unlike [otherFormOfPaymentEvidence], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("other_form_of_payment_evidence") + @ExcludeMissing + fun _otherFormOfPaymentEvidence(): JsonField = + otherFormOfPaymentEvidence + + /** + * Returns the raw JSON value of [otherTransactionId]. + * + * Unlike [otherTransactionId], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_transaction_id") + @ExcludeMissing + fun _otherTransactionId(): JsonField = otherTransactionId + + @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 + * [PaidByOtherMeans]. + * + * The following fields are required: + * ```java + * .otherFormOfPaymentEvidence() + * .otherTransactionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaidByOtherMeans]. */ + class Builder internal constructor() { + + private var otherFormOfPaymentEvidence: + JsonField? = + null + private var otherTransactionId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(paidByOtherMeans: PaidByOtherMeans) = apply { + otherFormOfPaymentEvidence = + paidByOtherMeans.otherFormOfPaymentEvidence + otherTransactionId = paidByOtherMeans.otherTransactionId + additionalProperties = + paidByOtherMeans.additionalProperties.toMutableMap() + } + + /** Other form of payment evidence. */ + fun otherFormOfPaymentEvidence( + otherFormOfPaymentEvidence: OtherFormOfPaymentEvidence + ) = otherFormOfPaymentEvidence(JsonField.of(otherFormOfPaymentEvidence)) + + /** + * Sets [Builder.otherFormOfPaymentEvidence] to an arbitrary JSON value. + * + * You should usually call [Builder.otherFormOfPaymentEvidence] with a + * well-typed [OtherFormOfPaymentEvidence] value instead. This method is + * primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun otherFormOfPaymentEvidence( + otherFormOfPaymentEvidence: JsonField + ) = apply { + this.otherFormOfPaymentEvidence = otherFormOfPaymentEvidence + } + + /** Other transaction ID. */ + fun otherTransactionId(otherTransactionId: String?) = + otherTransactionId(JsonField.ofNullable(otherTransactionId)) + + /** + * Alias for calling [Builder.otherTransactionId] with + * `otherTransactionId.orElse(null)`. + */ + fun otherTransactionId(otherTransactionId: Optional) = + otherTransactionId(otherTransactionId.getOrNull()) + + /** + * Sets [Builder.otherTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.otherTransactionId] with a + * well-typed [String] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun otherTransactionId(otherTransactionId: JsonField) = apply { + this.otherTransactionId = otherTransactionId + } + + 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 [PaidByOtherMeans]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .otherFormOfPaymentEvidence() + * .otherTransactionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaidByOtherMeans = + PaidByOtherMeans( + checkRequired( + "otherFormOfPaymentEvidence", + otherFormOfPaymentEvidence, + ), + checkRequired("otherTransactionId", otherTransactionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaidByOtherMeans = apply { + if (validated) { + return@apply + } + + otherFormOfPaymentEvidence().validate() + otherTransactionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (otherFormOfPaymentEvidence.asKnown().getOrNull()?.validity() ?: 0) + + (if (otherTransactionId.asKnown().isPresent) 1 else 0) + + /** Other form of payment evidence. */ + class OtherFormOfPaymentEvidence + @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 { + + /** Canceled check. */ + @JvmField val CANCELED_CHECK = of("canceled_check") + + /** Card transaction. */ + @JvmField val CARD_TRANSACTION = of("card_transaction") + + /** Cash receipt. */ + @JvmField val CASH_RECEIPT = of("cash_receipt") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Statement. */ + @JvmField val STATEMENT = of("statement") + + /** Voucher. */ + @JvmField val VOUCHER = of("voucher") + + @JvmStatic + fun of(value: String) = + OtherFormOfPaymentEvidence(JsonField.of(value)) + } + + /** An enum containing [OtherFormOfPaymentEvidence]'s known values. */ + enum class Known { + /** Canceled check. */ + CANCELED_CHECK, + /** Card transaction. */ + CARD_TRANSACTION, + /** Cash receipt. */ + CASH_RECEIPT, + /** Other. */ + OTHER, + /** Statement. */ + STATEMENT, + /** Voucher. */ + VOUCHER, + } + + /** + * An enum containing [OtherFormOfPaymentEvidence]'s known values, as + * well as an [_UNKNOWN] member. + * + * An instance of [OtherFormOfPaymentEvidence] can contain an unknown + * value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. + * For example, if the SDK is on an older version than the API, then + * the API may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Canceled check. */ + CANCELED_CHECK, + /** Card transaction. */ + CARD_TRANSACTION, + /** Cash receipt. */ + CASH_RECEIPT, + /** Other. */ + OTHER, + /** Statement. */ + STATEMENT, + /** Voucher. */ + VOUCHER, + /** + * An enum member indicating that [OtherFormOfPaymentEvidence] 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) { + CANCELED_CHECK -> Value.CANCELED_CHECK + CARD_TRANSACTION -> Value.CARD_TRANSACTION + CASH_RECEIPT -> Value.CASH_RECEIPT + OTHER -> Value.OTHER + STATEMENT -> Value.STATEMENT + VOUCHER -> Value.VOUCHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is + * always known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value + * is a not a known member. + */ + fun known(): Known = + when (this) { + CANCELED_CHECK -> Known.CANCELED_CHECK + CARD_TRANSACTION -> Known.CARD_TRANSACTION + CASH_RECEIPT -> Known.CASH_RECEIPT + OTHER -> Known.OTHER + STATEMENT -> Known.STATEMENT + VOUCHER -> Known.VOUCHER + else -> + throw IncreaseInvalidDataException( + "Unknown OtherFormOfPaymentEvidence: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is + * primarily for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value + * does not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): OtherFormOfPaymentEvidence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OtherFormOfPaymentEvidence && 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 PaidByOtherMeans && + otherFormOfPaymentEvidence == other.otherFormOfPaymentEvidence && + otherTransactionId == other.otherTransactionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + otherFormOfPaymentEvidence, + otherTransactionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaidByOtherMeans{otherFormOfPaymentEvidence=$otherFormOfPaymentEvidence, otherTransactionId=$otherTransactionId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProcessingError && + duplicateTransaction == other.duplicateTransaction && + errorReason == other.errorReason && + incorrectAmount == other.incorrectAmount && + merchantResolutionAttempted == other.merchantResolutionAttempted && + paidByOtherMeans == other.paidByOtherMeans && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + duplicateTransaction, + errorReason, + incorrectAmount, + merchantResolutionAttempted, + paidByOtherMeans, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProcessingError{duplicateTransaction=$duplicateTransaction, errorReason=$errorReason, incorrectAmount=$incorrectAmount, merchantResolutionAttempted=$merchantResolutionAttempted, paidByOtherMeans=$paidByOtherMeans, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Chargeback && + authorization == other.authorization && + category == other.category && + consumerCanceledMerchandise == other.consumerCanceledMerchandise && + consumerCanceledRecurringTransaction == + other.consumerCanceledRecurringTransaction && + consumerCanceledServices == other.consumerCanceledServices && + consumerCounterfeitMerchandise == other.consumerCounterfeitMerchandise && + consumerCreditNotProcessed == other.consumerCreditNotProcessed && + consumerDamagedOrDefectiveMerchandise == + other.consumerDamagedOrDefectiveMerchandise && + consumerMerchandiseMisrepresentation == + other.consumerMerchandiseMisrepresentation && + consumerMerchandiseNotAsDescribed == + other.consumerMerchandiseNotAsDescribed && + consumerMerchandiseNotReceived == other.consumerMerchandiseNotReceived && + consumerNonReceiptOfCash == other.consumerNonReceiptOfCash && + consumerOriginalCreditTransactionNotAccepted == + other.consumerOriginalCreditTransactionNotAccepted && + consumerQualityMerchandise == other.consumerQualityMerchandise && + consumerQualityServices == other.consumerQualityServices && + consumerServicesMisrepresentation == + other.consumerServicesMisrepresentation && + consumerServicesNotAsDescribed == other.consumerServicesNotAsDescribed && + consumerServicesNotReceived == other.consumerServicesNotReceived && + fraud == other.fraud && + processingError == other.processingError && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + authorization, + category, + consumerCanceledMerchandise, + consumerCanceledRecurringTransaction, + consumerCanceledServices, + consumerCounterfeitMerchandise, + consumerCreditNotProcessed, + consumerDamagedOrDefectiveMerchandise, + consumerMerchandiseMisrepresentation, + consumerMerchandiseNotAsDescribed, + consumerMerchandiseNotReceived, + consumerNonReceiptOfCash, + consumerOriginalCreditTransactionNotAccepted, + consumerQualityMerchandise, + consumerQualityServices, + consumerServicesMisrepresentation, + consumerServicesNotAsDescribed, + consumerServicesNotReceived, + fraud, + processingError, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Chargeback{authorization=$authorization, category=$category, consumerCanceledMerchandise=$consumerCanceledMerchandise, consumerCanceledRecurringTransaction=$consumerCanceledRecurringTransaction, consumerCanceledServices=$consumerCanceledServices, consumerCounterfeitMerchandise=$consumerCounterfeitMerchandise, consumerCreditNotProcessed=$consumerCreditNotProcessed, consumerDamagedOrDefectiveMerchandise=$consumerDamagedOrDefectiveMerchandise, consumerMerchandiseMisrepresentation=$consumerMerchandiseMisrepresentation, consumerMerchandiseNotAsDescribed=$consumerMerchandiseNotAsDescribed, consumerMerchandiseNotReceived=$consumerMerchandiseNotReceived, consumerNonReceiptOfCash=$consumerNonReceiptOfCash, consumerOriginalCreditTransactionNotAccepted=$consumerOriginalCreditTransactionNotAccepted, consumerQualityMerchandise=$consumerQualityMerchandise, consumerQualityServices=$consumerQualityServices, consumerServicesMisrepresentation=$consumerServicesMisrepresentation, consumerServicesNotAsDescribed=$consumerServicesNotAsDescribed, consumerServicesNotReceived=$consumerServicesNotReceived, fraud=$fraud, processingError=$processingError, additionalProperties=$additionalProperties}" + } + + /** + * A Visa Card Dispute Merchant Pre-Arbitration Decline User Submission object. This + * field will be present in the JSON response if and only if `category` is equal to + * `merchant_prearbitration_decline`. Contains the details specific to a merchant + * prearbitration decline Visa Card Dispute User Submission. + */ + class MerchantPrearbitrationDecline + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of() + ) : this(reason, mutableMapOf()) + + /** + * The reason the user declined the merchant's request for pre-arbitration in their + * favor. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * 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 + + @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 + * [MerchantPrearbitrationDecline]. + * + * The following fields are required: + * ```java + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantPrearbitrationDecline]. */ + class Builder internal constructor() { + + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + merchantPrearbitrationDecline: MerchantPrearbitrationDecline + ) = apply { + reason = merchantPrearbitrationDecline.reason + additionalProperties = + merchantPrearbitrationDecline.additionalProperties.toMutableMap() + } + + /** + * The reason the user declined the merchant's request for pre-arbitration in + * their favor. + */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [MerchantPrearbitrationDecline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantPrearbitrationDecline = + MerchantPrearbitrationDecline( + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantPrearbitrationDecline = apply { + if (validated) { + return@apply + } + + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantPrearbitrationDecline && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(reason, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantPrearbitrationDecline{reason=$reason, additionalProperties=$additionalProperties}" + } + + /** The status of the Visa Card Dispute User Submission. */ + class Status @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** The User Submission was abandoned. */ + @JvmField val ABANDONED = of("abandoned") + + /** The User Submission was accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** + * Further information is requested, please resubmit with the requested + * information. + */ + @JvmField + val FURTHER_INFORMATION_REQUESTED = of("further_information_requested") + + /** The User Submission is pending review. */ + @JvmField val PENDING_REVIEWING = of("pending_reviewing") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + /** The User Submission was abandoned. */ + ABANDONED, + /** The User Submission was accepted. */ + ACCEPTED, + /** + * Further information is requested, please resubmit with the requested + * information. + */ + FURTHER_INFORMATION_REQUESTED, + /** The User Submission is pending review. */ + PENDING_REVIEWING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** The User Submission was abandoned. */ + ABANDONED, + /** The User Submission was accepted. */ + ACCEPTED, + /** + * Further information is requested, please resubmit with the requested + * information. + */ + FURTHER_INFORMATION_REQUESTED, + /** The User Submission is pending review. */ + PENDING_REVIEWING, + /** + * 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) { + ABANDONED -> Value.ABANDONED + ACCEPTED -> Value.ACCEPTED + FURTHER_INFORMATION_REQUESTED -> Value.FURTHER_INFORMATION_REQUESTED + PENDING_REVIEWING -> Value.PENDING_REVIEWING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ABANDONED -> Known.ABANDONED + ACCEPTED -> Known.ACCEPTED + FURTHER_INFORMATION_REQUESTED -> Known.FURTHER_INFORMATION_REQUESTED + PENDING_REVIEWING -> Known.PENDING_REVIEWING + else -> throw IncreaseInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * A Visa Card Dispute User-Initiated Pre-Arbitration User Submission object. This field + * will be present in the JSON response if and only if `category` is equal to + * `user_prearbitration`. Contains the details specific to a user-initiated + * pre-arbitration Visa Card Dispute User Submission. + */ + class UserPrearbitration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val categoryChange: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("category_change") + @ExcludeMissing + categoryChange: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(categoryChange, reason, mutableMapOf()) + + /** + * Category change details for the pre-arbitration request, if requested. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun categoryChange(): Optional = + categoryChange.getOptional("category_change") + + /** + * The reason for the pre-arbitration request. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [categoryChange]. + * + * Unlike [categoryChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("category_change") + @ExcludeMissing + fun _categoryChange(): JsonField = categoryChange + + /** + * 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 + + @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 + * [UserPrearbitration]. + * + * The following fields are required: + * ```java + * .categoryChange() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserPrearbitration]. */ + class Builder internal constructor() { + + private var categoryChange: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userPrearbitration: UserPrearbitration) = apply { + categoryChange = userPrearbitration.categoryChange + reason = userPrearbitration.reason + additionalProperties = + userPrearbitration.additionalProperties.toMutableMap() + } + + /** Category change details for the pre-arbitration request, if requested. */ + fun categoryChange(categoryChange: CategoryChange?) = + categoryChange(JsonField.ofNullable(categoryChange)) + + /** + * Alias for calling [Builder.categoryChange] with + * `categoryChange.orElse(null)`. + */ + fun categoryChange(categoryChange: Optional) = + categoryChange(categoryChange.getOrNull()) + + /** + * Sets [Builder.categoryChange] to an arbitrary JSON value. + * + * You should usually call [Builder.categoryChange] with a well-typed + * [CategoryChange] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun categoryChange(categoryChange: JsonField) = apply { + this.categoryChange = categoryChange + } + + /** The reason for the pre-arbitration request. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [UserPrearbitration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .categoryChange() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserPrearbitration = + UserPrearbitration( + checkRequired("categoryChange", categoryChange), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserPrearbitration = apply { + if (validated) { + return@apply + } + + categoryChange().ifPresent { it.validate() } + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (categoryChange.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Category change details for the pre-arbitration request, if requested. */ + class CategoryChange + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val category: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(category, reason, mutableMapOf()) + + /** + * The category the dispute is being changed to. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun category(): Category = category.getRequired("category") + + /** + * The reason for the pre-arbitration request. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * 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 [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("reason") + @ExcludeMissing + fun _reason(): JsonField = reason + + @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 + * [CategoryChange]. + * + * The following fields are required: + * ```java + * .category() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CategoryChange]. */ + class Builder internal constructor() { + + private var category: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(categoryChange: CategoryChange) = apply { + category = categoryChange.category + reason = categoryChange.reason + additionalProperties = + categoryChange.additionalProperties.toMutableMap() + } + + /** The category the dispute is being changed to. */ + 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 + } + + /** The reason for the pre-arbitration request. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CategoryChange]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .category() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CategoryChange = + CategoryChange( + checkRequired("category", category), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CategoryChange = apply { + if (validated) { + return@apply + } + + category().validate() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** The category the dispute is being changed to. */ + 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 { + + /** Authorization. */ + @JvmField val AUTHORIZATION = of("authorization") + + /** Consumer: canceled merchandise. */ + @JvmField + val CONSUMER_CANCELED_MERCHANDISE = of("consumer_canceled_merchandise") + + /** Consumer: canceled recurring transaction. */ + @JvmField + val CONSUMER_CANCELED_RECURRING_TRANSACTION = + of("consumer_canceled_recurring_transaction") + + /** Consumer: canceled services. */ + @JvmField + val CONSUMER_CANCELED_SERVICES = of("consumer_canceled_services") + + /** Consumer: counterfeit merchandise. */ + @JvmField + val CONSUMER_COUNTERFEIT_MERCHANDISE = + of("consumer_counterfeit_merchandise") + + /** Consumer: credit not processed. */ + @JvmField + val CONSUMER_CREDIT_NOT_PROCESSED = of("consumer_credit_not_processed") + + /** Consumer: damaged or defective merchandise. */ + @JvmField + val CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE = + of("consumer_damaged_or_defective_merchandise") + + /** Consumer: merchandise misrepresentation. */ + @JvmField + val CONSUMER_MERCHANDISE_MISREPRESENTATION = + of("consumer_merchandise_misrepresentation") + + /** Consumer: merchandise not as described. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED = + of("consumer_merchandise_not_as_described") + + /** Consumer: merchandise not received. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_RECEIVED = + of("consumer_merchandise_not_received") + + /** Consumer: non-receipt of cash. */ + @JvmField + val CONSUMER_NON_RECEIPT_OF_CASH = of("consumer_non_receipt_of_cash") + + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + @JvmField + val CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED = + of("consumer_original_credit_transaction_not_accepted") + + /** Consumer: merchandise quality issue. */ + @JvmField + val CONSUMER_QUALITY_MERCHANDISE = of("consumer_quality_merchandise") + + /** Consumer: services quality issue. */ + @JvmField + val CONSUMER_QUALITY_SERVICES = of("consumer_quality_services") + + /** Consumer: services misrepresentation. */ + @JvmField + val CONSUMER_SERVICES_MISREPRESENTATION = + of("consumer_services_misrepresentation") + + /** Consumer: services not as described. */ + @JvmField + val CONSUMER_SERVICES_NOT_AS_DESCRIBED = + of("consumer_services_not_as_described") + + /** Consumer: services not received. */ + @JvmField + val CONSUMER_SERVICES_NOT_RECEIVED = + of("consumer_services_not_received") + + /** Fraud. */ + @JvmField val FRAUD = of("fraud") + + /** Processing error. */ + @JvmField val PROCESSING_ERROR = of("processing_error") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + } + + /** + * 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 { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + /** + * 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) { + AUTHORIZATION -> Value.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Value.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Value.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Value.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> + Value.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Value.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Value.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Value.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Value.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> + Value.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Value.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Value.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Value.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Value.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> + Value.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> + Value.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> + Value.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Value.FRAUD + PROCESSING_ERROR -> Value.PROCESSING_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 IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + AUTHORIZATION -> Known.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Known.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Known.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Known.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> + Known.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Known.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Known.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Known.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Known.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> + Known.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Known.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Known.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Known.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Known.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> + Known.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> + Known.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> + Known.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Known.FRAUD + PROCESSING_ERROR -> Known.PROCESSING_ERROR + else -> + throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CategoryChange && + category == other.category && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(category, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CategoryChange{category=$category, reason=$reason, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserPrearbitration && + categoryChange == other.categoryChange && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(categoryChange, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserPrearbitration{categoryChange=$categoryChange, reason=$reason, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserSubmission && + acceptedAt == other.acceptedAt && + amount == other.amount && + attachmentFiles == other.attachmentFiles && + category == other.category && + chargeback == other.chargeback && + createdAt == other.createdAt && + furtherInformationRequestedAt == other.furtherInformationRequestedAt && + furtherInformationRequestedReason == other.furtherInformationRequestedReason && + merchantPrearbitrationDecline == other.merchantPrearbitrationDecline && + status == other.status && + updatedAt == other.updatedAt && + userPrearbitration == other.userPrearbitration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + acceptedAt, + amount, + attachmentFiles, + category, + chargeback, + createdAt, + furtherInformationRequestedAt, + furtherInformationRequestedReason, + merchantPrearbitrationDecline, + status, + updatedAt, + userPrearbitration, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserSubmission{acceptedAt=$acceptedAt, amount=$amount, attachmentFiles=$attachmentFiles, category=$category, chargeback=$chargeback, createdAt=$createdAt, furtherInformationRequestedAt=$furtherInformationRequestedAt, furtherInformationRequestedReason=$furtherInformationRequestedReason, merchantPrearbitrationDecline=$merchantPrearbitrationDecline, status=$status, updatedAt=$updatedAt, userPrearbitration=$userPrearbitration, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Visa && + networkEvents == other.networkEvents && + requiredUserSubmissionCategory == other.requiredUserSubmissionCategory && + userSubmissions == other.userSubmissions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + networkEvents, + requiredUserSubmissionCategory, + userSubmissions, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Visa{networkEvents=$networkEvents, requiredUserSubmissionCategory=$requiredUserSubmissionCategory, userSubmissions=$userSubmissions, additionalProperties=$additionalProperties}" + } + + /** If the Card Dispute's status is `won`, this will contain details of the won dispute. */ + class Win + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val wonAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("won_at") + @ExcludeMissing + wonAt: JsonField = JsonMissing.of() + ) : this(wonAt, mutableMapOf()) + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the Card + * Dispute was won. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun wonAt(): OffsetDateTime = wonAt.getRequired("won_at") + + /** + * Returns the raw JSON value of [wonAt]. + * + * Unlike [wonAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("won_at") @ExcludeMissing fun _wonAt(): JsonField = wonAt + + @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 [Win]. + * + * The following fields are required: + * ```java + * .wonAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Win]. */ + class Builder internal constructor() { + + private var wonAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(win: Win) = apply { + wonAt = win.wonAt + additionalProperties = win.additionalProperties.toMutableMap() + } + + /** + * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the + * Card Dispute was won. + */ + fun wonAt(wonAt: OffsetDateTime) = wonAt(JsonField.of(wonAt)) + + /** + * Sets [Builder.wonAt] to an arbitrary JSON value. + * + * You should usually call [Builder.wonAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun wonAt(wonAt: JsonField) = apply { this.wonAt = wonAt } + + 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 [Win]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .wonAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Win = + Win(checkRequired("wonAt", wonAt), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Win = apply { + if (validated) { + return@apply + } + + wonAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (wonAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Win && + wonAt == other.wonAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(wonAt, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Win{wonAt=$wonAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardDispute && + id == other.id && + amount == other.amount && + cardId == other.cardId && + createdAt == other.createdAt && + disputedTransactionId == other.disputedTransactionId && + idempotencyKey == other.idempotencyKey && + loss == other.loss && + network == other.network && + status == other.status && + type == other.type && + userSubmissionRequiredBy == other.userSubmissionRequiredBy && + visa == other.visa && + win == other.win && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + amount, + cardId, + createdAt, + disputedTransactionId, + idempotencyKey, + loss, + network, + status, + type, + userSubmissionRequiredBy, + visa, + win, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardDispute{id=$id, amount=$amount, cardId=$cardId, createdAt=$createdAt, disputedTransactionId=$disputedTransactionId, idempotencyKey=$idempotencyKey, loss=$loss, network=$network, status=$status, type=$type, userSubmissionRequiredBy=$userSubmissionRequiredBy, visa=$visa, win=$win, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeCreateParams.kt new file mode 100644 index 000000000..f595e7bd8 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeCreateParams.kt @@ -0,0 +1,25246 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.increase.api.core.Enum +import com.increase.api.core.ExcludeMissing +import com.increase.api.core.JsonField +import com.increase.api.core.JsonMissing +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.checkKnown +import com.increase.api.core.checkRequired +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable +import com.increase.api.errors.IncreaseInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a Card Dispute */ +class CardDisputeCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The Transaction you wish to dispute. This Transaction must have a `source_type` of + * `card_settlement`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun disputedTransactionId(): String = body.disputedTransactionId() + + /** + * The network of the disputed transaction. Details specific to the network are required under + * the sub-object with the same identifier as the network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): Network = body.network() + + /** + * The monetary amount of the part of the transaction that is being disputed. This is optional + * and will default to the full amount of the transaction if not provided. If provided, the + * amount must be less than or equal to the amount of the transaction. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = body.amount() + + /** + * The files to be attached to the initial dispute submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attachmentFiles(): Optional> = body.attachmentFiles() + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is `visa`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun visa(): Optional = body.visa() + + /** + * Returns the raw JSON value of [disputedTransactionId]. + * + * Unlike [disputedTransactionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _disputedTransactionId(): JsonField = body._disputedTransactionId() + + /** + * Returns the raw JSON value of [network]. + * + * Unlike [network], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _network(): JsonField = body._network() + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _amount(): JsonField = body._amount() + + /** + * Returns the raw JSON value of [attachmentFiles]. + * + * Unlike [attachmentFiles], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _attachmentFiles(): JsonField> = body._attachmentFiles() + + /** + * Returns the raw JSON value of [visa]. + * + * Unlike [visa], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _visa(): JsonField = body._visa() + + 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 [CardDisputeCreateParams]. + * + * The following fields are required: + * ```java + * .disputedTransactionId() + * .network() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardDisputeCreateParams: CardDisputeCreateParams) = apply { + body = cardDisputeCreateParams.body.toBuilder() + additionalHeaders = cardDisputeCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = cardDisputeCreateParams.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: + * - [disputedTransactionId] + * - [network] + * - [amount] + * - [attachmentFiles] + * - [visa] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The Transaction you wish to dispute. This Transaction must have a `source_type` of + * `card_settlement`. + */ + fun disputedTransactionId(disputedTransactionId: String) = apply { + body.disputedTransactionId(disputedTransactionId) + } + + /** + * Sets [Builder.disputedTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.disputedTransactionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun disputedTransactionId(disputedTransactionId: JsonField) = apply { + body.disputedTransactionId(disputedTransactionId) + } + + /** + * The network of the disputed transaction. Details specific to the network are required + * under the sub-object with the same identifier as the network. + */ + fun network(network: Network) = apply { body.network(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 { body.network(network) } + + /** + * The monetary amount of the part of the transaction that is being disputed. This is + * optional and will default to the full amount of the transaction if not provided. If + * provided, the amount must be less than or equal to the amount of the transaction. + */ + fun amount(amount: Long) = apply { body.amount(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 { body.amount(amount) } + + /** The files to be attached to the initial dispute submission. */ + fun attachmentFiles(attachmentFiles: List) = apply { + body.attachmentFiles(attachmentFiles) + } + + /** + * Sets [Builder.attachmentFiles] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentFiles] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun attachmentFiles(attachmentFiles: JsonField>) = apply { + body.attachmentFiles(attachmentFiles) + } + + /** + * Adds a single [AttachmentFile] to [attachmentFiles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAttachmentFile(attachmentFile: AttachmentFile) = apply { + body.addAttachmentFile(attachmentFile) + } + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is + * `visa`. + */ + fun visa(visa: Visa) = apply { body.visa(visa) } + + /** + * Sets [Builder.visa] to an arbitrary JSON value. + * + * You should usually call [Builder.visa] with a well-typed [Visa] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun visa(visa: JsonField) = apply { body.visa(visa) } + + 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 [CardDisputeCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .disputedTransactionId() + * .network() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardDisputeCreateParams = + CardDisputeCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val disputedTransactionId: JsonField, + private val network: JsonField, + private val amount: JsonField, + private val attachmentFiles: JsonField>, + private val visa: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("disputed_transaction_id") + @ExcludeMissing + disputedTransactionId: JsonField = JsonMissing.of(), + @JsonProperty("network") @ExcludeMissing network: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attachment_files") + @ExcludeMissing + attachmentFiles: JsonField> = JsonMissing.of(), + @JsonProperty("visa") @ExcludeMissing visa: JsonField = JsonMissing.of(), + ) : this(disputedTransactionId, network, amount, attachmentFiles, visa, mutableMapOf()) + + /** + * The Transaction you wish to dispute. This Transaction must have a `source_type` of + * `card_settlement`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun disputedTransactionId(): String = + disputedTransactionId.getRequired("disputed_transaction_id") + + /** + * The network of the disputed transaction. Details specific to the network are required + * under the sub-object with the same identifier as the network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): Network = network.getRequired("network") + + /** + * The monetary amount of the part of the transaction that is being disputed. This is + * optional and will default to the full amount of the transaction if not provided. If + * provided, the amount must be less than or equal to the amount of the transaction. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The files to be attached to the initial dispute submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun attachmentFiles(): Optional> = + attachmentFiles.getOptional("attachment_files") + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is + * `visa`. + * + * @throws IncreaseInvalidDataException 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 [disputedTransactionId]. + * + * Unlike [disputedTransactionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("disputed_transaction_id") + @ExcludeMissing + fun _disputedTransactionId(): JsonField = disputedTransactionId + + /** + * 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 [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 [attachmentFiles]. + * + * Unlike [attachmentFiles], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attachment_files") + @ExcludeMissing + fun _attachmentFiles(): JsonField> = attachmentFiles + + /** + * 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 [Body]. + * + * The following fields are required: + * ```java + * .disputedTransactionId() + * .network() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var disputedTransactionId: JsonField? = null + private var network: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var attachmentFiles: JsonField>? = null + private var visa: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + disputedTransactionId = body.disputedTransactionId + network = body.network + amount = body.amount + attachmentFiles = body.attachmentFiles.map { it.toMutableList() } + visa = body.visa + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The Transaction you wish to dispute. This Transaction must have a `source_type` of + * `card_settlement`. + */ + fun disputedTransactionId(disputedTransactionId: String) = + disputedTransactionId(JsonField.of(disputedTransactionId)) + + /** + * Sets [Builder.disputedTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.disputedTransactionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun disputedTransactionId(disputedTransactionId: JsonField) = apply { + this.disputedTransactionId = disputedTransactionId + } + + /** + * The network of the disputed transaction. Details specific to the network are required + * under the sub-object with the same identifier as the network. + */ + 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 } + + /** + * The monetary amount of the part of the transaction that is being disputed. This is + * optional and will default to the full amount of the transaction if not provided. If + * provided, the amount must be less than or equal to the amount of the transaction. + */ + 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 files to be attached to the initial dispute submission. */ + fun attachmentFiles(attachmentFiles: List) = + attachmentFiles(JsonField.of(attachmentFiles)) + + /** + * Sets [Builder.attachmentFiles] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentFiles] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attachmentFiles(attachmentFiles: JsonField>) = apply { + this.attachmentFiles = attachmentFiles.map { it.toMutableList() } + } + + /** + * Adds a single [AttachmentFile] to [attachmentFiles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAttachmentFile(attachmentFile: AttachmentFile) = apply { + attachmentFiles = + (attachmentFiles ?: JsonField.of(mutableListOf())).also { + checkKnown("attachmentFiles", it).add(attachmentFile) + } + } + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is + * `visa`. + */ + fun visa(visa: Visa) = visa(JsonField.of(visa)) + + /** + * Sets [Builder.visa] to an arbitrary JSON value. + * + * You should usually call [Builder.visa] with a well-typed [Visa] 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .disputedTransactionId() + * .network() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("disputedTransactionId", disputedTransactionId), + checkRequired("network", network), + amount, + (attachmentFiles ?: JsonMissing.of()).map { it.toImmutable() }, + visa, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + disputedTransactionId() + network().validate() + amount() + attachmentFiles().ifPresent { it.forEach { it.validate() } } + visa().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (disputedTransactionId.asKnown().isPresent) 1 else 0) + + (network.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attachmentFiles.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (visa.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + disputedTransactionId == other.disputedTransactionId && + network == other.network && + amount == other.amount && + attachmentFiles == other.attachmentFiles && + visa == other.visa && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + disputedTransactionId, + network, + amount, + attachmentFiles, + visa, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{disputedTransactionId=$disputedTransactionId, network=$network, amount=$amount, attachmentFiles=$attachmentFiles, visa=$visa, additionalProperties=$additionalProperties}" + } + + /** + * The network of the disputed transaction. Details specific to the network are required under + * the sub-object with the same identifier as the network. + */ + 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 { + + /** Visa */ + @JvmField val VISA = of("visa") + + @JvmStatic fun of(value: String) = Network(JsonField.of(value)) + } + + /** An enum containing [Network]'s known values. */ + enum class Known { + /** Visa */ + 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 { + /** Visa */ + 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) { + 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 IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VISA -> Known.VISA + else -> throw IncreaseInvalidDataException("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 IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Network = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Network && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class AttachmentFile + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of() + ) : this(fileId, mutableMapOf()) + + /** + * The ID of the file to be attached. The file must have a `purpose` of + * `card_dispute_attachment`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + @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 [AttachmentFile]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentFile]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentFile: AttachmentFile) = apply { + fileId = attachmentFile.fileId + additionalProperties = attachmentFile.additionalProperties.toMutableMap() + } + + /** + * The ID of the file to be attached. The file must have a `purpose` of + * `card_dispute_attachment`. + */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + 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 [AttachmentFile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AttachmentFile = + AttachmentFile(checkRequired("fileId", fileId), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AttachmentFile = apply { + if (validated) { + return@apply + } + + fileId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (fileId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentFile && + fileId == other.fileId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AttachmentFile{fileId=$fileId, additionalProperties=$additionalProperties}" + } + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is `visa`. + */ + class Visa + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val category: JsonField, + private val authorization: JsonField, + private val consumerCanceledMerchandise: JsonField, + private val consumerCanceledRecurringTransaction: + JsonField, + private val consumerCanceledServices: JsonField, + private val consumerCounterfeitMerchandise: JsonField, + private val consumerCreditNotProcessed: JsonField, + private val consumerDamagedOrDefectiveMerchandise: + JsonField, + private val consumerMerchandiseMisrepresentation: + JsonField, + private val consumerMerchandiseNotAsDescribed: JsonField, + private val consumerMerchandiseNotReceived: JsonField, + private val consumerNonReceiptOfCash: JsonValue, + private val consumerOriginalCreditTransactionNotAccepted: + JsonField, + private val consumerQualityMerchandise: JsonField, + private val consumerQualityServices: JsonField, + private val consumerServicesMisrepresentation: JsonField, + private val consumerServicesNotAsDescribed: JsonField, + private val consumerServicesNotReceived: JsonField, + private val fraud: JsonField, + private val processingError: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("authorization") + @ExcludeMissing + authorization: JsonField = JsonMissing.of(), + @JsonProperty("consumer_canceled_merchandise") + @ExcludeMissing + consumerCanceledMerchandise: JsonField = JsonMissing.of(), + @JsonProperty("consumer_canceled_recurring_transaction") + @ExcludeMissing + consumerCanceledRecurringTransaction: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_canceled_services") + @ExcludeMissing + consumerCanceledServices: JsonField = JsonMissing.of(), + @JsonProperty("consumer_counterfeit_merchandise") + @ExcludeMissing + consumerCounterfeitMerchandise: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_credit_not_processed") + @ExcludeMissing + consumerCreditNotProcessed: JsonField = JsonMissing.of(), + @JsonProperty("consumer_damaged_or_defective_merchandise") + @ExcludeMissing + consumerDamagedOrDefectiveMerchandise: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_misrepresentation") + @ExcludeMissing + consumerMerchandiseMisrepresentation: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_not_as_described") + @ExcludeMissing + consumerMerchandiseNotAsDescribed: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_not_received") + @ExcludeMissing + consumerMerchandiseNotReceived: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_non_receipt_of_cash") + @ExcludeMissing + consumerNonReceiptOfCash: JsonValue = JsonMissing.of(), + @JsonProperty("consumer_original_credit_transaction_not_accepted") + @ExcludeMissing + consumerOriginalCreditTransactionNotAccepted: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_quality_merchandise") + @ExcludeMissing + consumerQualityMerchandise: JsonField = JsonMissing.of(), + @JsonProperty("consumer_quality_services") + @ExcludeMissing + consumerQualityServices: JsonField = JsonMissing.of(), + @JsonProperty("consumer_services_misrepresentation") + @ExcludeMissing + consumerServicesMisrepresentation: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_services_not_as_described") + @ExcludeMissing + consumerServicesNotAsDescribed: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_services_not_received") + @ExcludeMissing + consumerServicesNotReceived: JsonField = JsonMissing.of(), + @JsonProperty("fraud") @ExcludeMissing fraud: JsonField = JsonMissing.of(), + @JsonProperty("processing_error") + @ExcludeMissing + processingError: JsonField = JsonMissing.of(), + ) : this( + category, + authorization, + consumerCanceledMerchandise, + consumerCanceledRecurringTransaction, + consumerCanceledServices, + consumerCounterfeitMerchandise, + consumerCreditNotProcessed, + consumerDamagedOrDefectiveMerchandise, + consumerMerchandiseMisrepresentation, + consumerMerchandiseNotAsDescribed, + consumerMerchandiseNotReceived, + consumerNonReceiptOfCash, + consumerOriginalCreditTransactionNotAccepted, + consumerQualityMerchandise, + consumerQualityServices, + consumerServicesMisrepresentation, + consumerServicesNotAsDescribed, + consumerServicesNotReceived, + fraud, + processingError, + mutableMapOf(), + ) + + /** + * Category. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): Category = category.getRequired("category") + + /** + * Authorization. Required if and only if `category` is `authorization`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun authorization(): Optional = authorization.getOptional("authorization") + + /** + * Canceled merchandise. Required if and only if `category` is + * `consumer_canceled_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerCanceledMerchandise(): Optional = + consumerCanceledMerchandise.getOptional("consumer_canceled_merchandise") + + /** + * Canceled recurring transaction. Required if and only if `category` is + * `consumer_canceled_recurring_transaction`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerCanceledRecurringTransaction(): Optional = + consumerCanceledRecurringTransaction.getOptional( + "consumer_canceled_recurring_transaction" + ) + + /** + * Canceled services. Required if and only if `category` is `consumer_canceled_services`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerCanceledServices(): Optional = + consumerCanceledServices.getOptional("consumer_canceled_services") + + /** + * Counterfeit merchandise. Required if and only if `category` is + * `consumer_counterfeit_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerCounterfeitMerchandise(): Optional = + consumerCounterfeitMerchandise.getOptional("consumer_counterfeit_merchandise") + + /** + * Credit not processed. Required if and only if `category` is + * `consumer_credit_not_processed`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerCreditNotProcessed(): Optional = + consumerCreditNotProcessed.getOptional("consumer_credit_not_processed") + + /** + * Damaged or defective merchandise. Required if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerDamagedOrDefectiveMerchandise(): + Optional = + consumerDamagedOrDefectiveMerchandise.getOptional( + "consumer_damaged_or_defective_merchandise" + ) + + /** + * Merchandise misrepresentation. Required if and only if `category` is + * `consumer_merchandise_misrepresentation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerMerchandiseMisrepresentation(): Optional = + consumerMerchandiseMisrepresentation.getOptional( + "consumer_merchandise_misrepresentation" + ) + + /** + * Merchandise not as described. Required if and only if `category` is + * `consumer_merchandise_not_as_described`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerMerchandiseNotAsDescribed(): Optional = + consumerMerchandiseNotAsDescribed.getOptional("consumer_merchandise_not_as_described") + + /** + * Merchandise not received. Required if and only if `category` is + * `consumer_merchandise_not_received`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerMerchandiseNotReceived(): Optional = + consumerMerchandiseNotReceived.getOptional("consumer_merchandise_not_received") + + /** + * Non-receipt of cash. Required if and only if `category` is + * `consumer_non_receipt_of_cash`. + */ + @JsonProperty("consumer_non_receipt_of_cash") + @ExcludeMissing + fun _consumerNonReceiptOfCash(): JsonValue = consumerNonReceiptOfCash + + /** + * Original Credit Transaction (OCT) not accepted. Required if and only if `category` is + * `consumer_original_credit_transaction_not_accepted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerOriginalCreditTransactionNotAccepted(): + Optional = + consumerOriginalCreditTransactionNotAccepted.getOptional( + "consumer_original_credit_transaction_not_accepted" + ) + + /** + * Merchandise quality issue. Required if and only if `category` is + * `consumer_quality_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerQualityMerchandise(): Optional = + consumerQualityMerchandise.getOptional("consumer_quality_merchandise") + + /** + * Services quality issue. Required if and only if `category` is + * `consumer_quality_services`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerQualityServices(): Optional = + consumerQualityServices.getOptional("consumer_quality_services") + + /** + * Services misrepresentation. Required if and only if `category` is + * `consumer_services_misrepresentation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerServicesMisrepresentation(): Optional = + consumerServicesMisrepresentation.getOptional("consumer_services_misrepresentation") + + /** + * Services not as described. Required if and only if `category` is + * `consumer_services_not_as_described`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerServicesNotAsDescribed(): Optional = + consumerServicesNotAsDescribed.getOptional("consumer_services_not_as_described") + + /** + * Services not received. Required if and only if `category` is + * `consumer_services_not_received`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun consumerServicesNotReceived(): Optional = + consumerServicesNotReceived.getOptional("consumer_services_not_received") + + /** + * Fraud. Required if and only if `category` is `fraud`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun fraud(): Optional = fraud.getOptional("fraud") + + /** + * Processing error. Required if and only if `category` is `processing_error`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun processingError(): Optional = + processingError.getOptional("processing_error") + + /** + * 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 [authorization]. + * + * Unlike [authorization], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authorization") + @ExcludeMissing + fun _authorization(): JsonField = authorization + + /** + * Returns the raw JSON value of [consumerCanceledMerchandise]. + * + * Unlike [consumerCanceledMerchandise], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumer_canceled_merchandise") + @ExcludeMissing + fun _consumerCanceledMerchandise(): JsonField = + consumerCanceledMerchandise + + /** + * Returns the raw JSON value of [consumerCanceledRecurringTransaction]. + * + * Unlike [consumerCanceledRecurringTransaction], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_canceled_recurring_transaction") + @ExcludeMissing + fun _consumerCanceledRecurringTransaction(): + JsonField = consumerCanceledRecurringTransaction + + /** + * Returns the raw JSON value of [consumerCanceledServices]. + * + * Unlike [consumerCanceledServices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumer_canceled_services") + @ExcludeMissing + fun _consumerCanceledServices(): JsonField = + consumerCanceledServices + + /** + * Returns the raw JSON value of [consumerCounterfeitMerchandise]. + * + * Unlike [consumerCounterfeitMerchandise], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumer_counterfeit_merchandise") + @ExcludeMissing + fun _consumerCounterfeitMerchandise(): JsonField = + consumerCounterfeitMerchandise + + /** + * Returns the raw JSON value of [consumerCreditNotProcessed]. + * + * Unlike [consumerCreditNotProcessed], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumer_credit_not_processed") + @ExcludeMissing + fun _consumerCreditNotProcessed(): JsonField = + consumerCreditNotProcessed + + /** + * Returns the raw JSON value of [consumerDamagedOrDefectiveMerchandise]. + * + * Unlike [consumerDamagedOrDefectiveMerchandise], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_damaged_or_defective_merchandise") + @ExcludeMissing + fun _consumerDamagedOrDefectiveMerchandise(): + JsonField = consumerDamagedOrDefectiveMerchandise + + /** + * Returns the raw JSON value of [consumerMerchandiseMisrepresentation]. + * + * Unlike [consumerMerchandiseMisrepresentation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_merchandise_misrepresentation") + @ExcludeMissing + fun _consumerMerchandiseMisrepresentation(): + JsonField = consumerMerchandiseMisrepresentation + + /** + * Returns the raw JSON value of [consumerMerchandiseNotAsDescribed]. + * + * Unlike [consumerMerchandiseNotAsDescribed], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_merchandise_not_as_described") + @ExcludeMissing + fun _consumerMerchandiseNotAsDescribed(): JsonField = + consumerMerchandiseNotAsDescribed + + /** + * Returns the raw JSON value of [consumerMerchandiseNotReceived]. + * + * Unlike [consumerMerchandiseNotReceived], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumer_merchandise_not_received") + @ExcludeMissing + fun _consumerMerchandiseNotReceived(): JsonField = + consumerMerchandiseNotReceived + + /** + * Returns the raw JSON value of [consumerOriginalCreditTransactionNotAccepted]. + * + * Unlike [consumerOriginalCreditTransactionNotAccepted], this method doesn't throw if the + * JSON field has an unexpected type. + */ + @JsonProperty("consumer_original_credit_transaction_not_accepted") + @ExcludeMissing + fun _consumerOriginalCreditTransactionNotAccepted(): + JsonField = + consumerOriginalCreditTransactionNotAccepted + + /** + * Returns the raw JSON value of [consumerQualityMerchandise]. + * + * Unlike [consumerQualityMerchandise], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumer_quality_merchandise") + @ExcludeMissing + fun _consumerQualityMerchandise(): JsonField = + consumerQualityMerchandise + + /** + * Returns the raw JSON value of [consumerQualityServices]. + * + * Unlike [consumerQualityServices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumer_quality_services") + @ExcludeMissing + fun _consumerQualityServices(): JsonField = consumerQualityServices + + /** + * Returns the raw JSON value of [consumerServicesMisrepresentation]. + * + * Unlike [consumerServicesMisrepresentation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_services_misrepresentation") + @ExcludeMissing + fun _consumerServicesMisrepresentation(): JsonField = + consumerServicesMisrepresentation + + /** + * Returns the raw JSON value of [consumerServicesNotAsDescribed]. + * + * Unlike [consumerServicesNotAsDescribed], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumer_services_not_as_described") + @ExcludeMissing + fun _consumerServicesNotAsDescribed(): JsonField = + consumerServicesNotAsDescribed + + /** + * Returns the raw JSON value of [consumerServicesNotReceived]. + * + * Unlike [consumerServicesNotReceived], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumer_services_not_received") + @ExcludeMissing + fun _consumerServicesNotReceived(): JsonField = + consumerServicesNotReceived + + /** + * Returns the raw JSON value of [fraud]. + * + * Unlike [fraud], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fraud") @ExcludeMissing fun _fraud(): JsonField = fraud + + /** + * Returns the raw JSON value of [processingError]. + * + * Unlike [processingError], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("processing_error") + @ExcludeMissing + fun _processingError(): JsonField = processingError + + @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 [Visa]. + * + * The following fields are required: + * ```java + * .category() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Visa]. */ + class Builder internal constructor() { + + private var category: JsonField? = null + private var authorization: JsonField = JsonMissing.of() + private var consumerCanceledMerchandise: JsonField = + JsonMissing.of() + private var consumerCanceledRecurringTransaction: + JsonField = + JsonMissing.of() + private var consumerCanceledServices: JsonField = + JsonMissing.of() + private var consumerCounterfeitMerchandise: JsonField = + JsonMissing.of() + private var consumerCreditNotProcessed: JsonField = + JsonMissing.of() + private var consumerDamagedOrDefectiveMerchandise: + JsonField = + JsonMissing.of() + private var consumerMerchandiseMisrepresentation: + JsonField = + JsonMissing.of() + private var consumerMerchandiseNotAsDescribed: + JsonField = + JsonMissing.of() + private var consumerMerchandiseNotReceived: JsonField = + JsonMissing.of() + private var consumerNonReceiptOfCash: JsonValue = JsonMissing.of() + private var consumerOriginalCreditTransactionNotAccepted: + JsonField = + JsonMissing.of() + private var consumerQualityMerchandise: JsonField = + JsonMissing.of() + private var consumerQualityServices: JsonField = + JsonMissing.of() + private var consumerServicesMisrepresentation: + JsonField = + JsonMissing.of() + private var consumerServicesNotAsDescribed: JsonField = + JsonMissing.of() + private var consumerServicesNotReceived: JsonField = + JsonMissing.of() + private var fraud: JsonField = JsonMissing.of() + private var processingError: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(visa: Visa) = apply { + category = visa.category + authorization = visa.authorization + consumerCanceledMerchandise = visa.consumerCanceledMerchandise + consumerCanceledRecurringTransaction = visa.consumerCanceledRecurringTransaction + consumerCanceledServices = visa.consumerCanceledServices + consumerCounterfeitMerchandise = visa.consumerCounterfeitMerchandise + consumerCreditNotProcessed = visa.consumerCreditNotProcessed + consumerDamagedOrDefectiveMerchandise = visa.consumerDamagedOrDefectiveMerchandise + consumerMerchandiseMisrepresentation = visa.consumerMerchandiseMisrepresentation + consumerMerchandiseNotAsDescribed = visa.consumerMerchandiseNotAsDescribed + consumerMerchandiseNotReceived = visa.consumerMerchandiseNotReceived + consumerNonReceiptOfCash = visa.consumerNonReceiptOfCash + consumerOriginalCreditTransactionNotAccepted = + visa.consumerOriginalCreditTransactionNotAccepted + consumerQualityMerchandise = visa.consumerQualityMerchandise + consumerQualityServices = visa.consumerQualityServices + consumerServicesMisrepresentation = visa.consumerServicesMisrepresentation + consumerServicesNotAsDescribed = visa.consumerServicesNotAsDescribed + consumerServicesNotReceived = visa.consumerServicesNotReceived + fraud = visa.fraud + processingError = visa.processingError + additionalProperties = visa.additionalProperties.toMutableMap() + } + + /** Category. */ + 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 } + + /** Authorization. Required if and only if `category` is `authorization`. */ + fun authorization(authorization: Authorization) = + authorization(JsonField.of(authorization)) + + /** + * Sets [Builder.authorization] to an arbitrary JSON value. + * + * You should usually call [Builder.authorization] with a well-typed [Authorization] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun authorization(authorization: JsonField) = apply { + this.authorization = authorization + } + + /** + * Canceled merchandise. Required if and only if `category` is + * `consumer_canceled_merchandise`. + */ + fun consumerCanceledMerchandise( + consumerCanceledMerchandise: ConsumerCanceledMerchandise + ) = consumerCanceledMerchandise(JsonField.of(consumerCanceledMerchandise)) + + /** + * Sets [Builder.consumerCanceledMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCanceledMerchandise] with a well-typed + * [ConsumerCanceledMerchandise] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumerCanceledMerchandise( + consumerCanceledMerchandise: JsonField + ) = apply { this.consumerCanceledMerchandise = consumerCanceledMerchandise } + + /** + * Canceled recurring transaction. Required if and only if `category` is + * `consumer_canceled_recurring_transaction`. + */ + fun consumerCanceledRecurringTransaction( + consumerCanceledRecurringTransaction: ConsumerCanceledRecurringTransaction + ) = + consumerCanceledRecurringTransaction( + JsonField.of(consumerCanceledRecurringTransaction) + ) + + /** + * Sets [Builder.consumerCanceledRecurringTransaction] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCanceledRecurringTransaction] with a + * well-typed [ConsumerCanceledRecurringTransaction] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerCanceledRecurringTransaction( + consumerCanceledRecurringTransaction: + JsonField + ) = apply { + this.consumerCanceledRecurringTransaction = consumerCanceledRecurringTransaction + } + + /** + * Canceled services. Required if and only if `category` is + * `consumer_canceled_services`. + */ + fun consumerCanceledServices(consumerCanceledServices: ConsumerCanceledServices) = + consumerCanceledServices(JsonField.of(consumerCanceledServices)) + + /** + * Sets [Builder.consumerCanceledServices] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCanceledServices] with a well-typed + * [ConsumerCanceledServices] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumerCanceledServices( + consumerCanceledServices: JsonField + ) = apply { this.consumerCanceledServices = consumerCanceledServices } + + /** + * Counterfeit merchandise. Required if and only if `category` is + * `consumer_counterfeit_merchandise`. + */ + fun consumerCounterfeitMerchandise( + consumerCounterfeitMerchandise: ConsumerCounterfeitMerchandise + ) = consumerCounterfeitMerchandise(JsonField.of(consumerCounterfeitMerchandise)) + + /** + * Sets [Builder.consumerCounterfeitMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCounterfeitMerchandise] with a well-typed + * [ConsumerCounterfeitMerchandise] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerCounterfeitMerchandise( + consumerCounterfeitMerchandise: JsonField + ) = apply { this.consumerCounterfeitMerchandise = consumerCounterfeitMerchandise } + + /** + * Credit not processed. Required if and only if `category` is + * `consumer_credit_not_processed`. + */ + fun consumerCreditNotProcessed(consumerCreditNotProcessed: ConsumerCreditNotProcessed) = + consumerCreditNotProcessed(JsonField.of(consumerCreditNotProcessed)) + + /** + * Sets [Builder.consumerCreditNotProcessed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCreditNotProcessed] with a well-typed + * [ConsumerCreditNotProcessed] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumerCreditNotProcessed( + consumerCreditNotProcessed: JsonField + ) = apply { this.consumerCreditNotProcessed = consumerCreditNotProcessed } + + /** + * Damaged or defective merchandise. Required if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + */ + fun consumerDamagedOrDefectiveMerchandise( + consumerDamagedOrDefectiveMerchandise: ConsumerDamagedOrDefectiveMerchandise + ) = + consumerDamagedOrDefectiveMerchandise( + JsonField.of(consumerDamagedOrDefectiveMerchandise) + ) + + /** + * Sets [Builder.consumerDamagedOrDefectiveMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerDamagedOrDefectiveMerchandise] with a + * well-typed [ConsumerDamagedOrDefectiveMerchandise] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerDamagedOrDefectiveMerchandise( + consumerDamagedOrDefectiveMerchandise: + JsonField + ) = apply { + this.consumerDamagedOrDefectiveMerchandise = consumerDamagedOrDefectiveMerchandise + } + + /** + * Merchandise misrepresentation. Required if and only if `category` is + * `consumer_merchandise_misrepresentation`. + */ + fun consumerMerchandiseMisrepresentation( + consumerMerchandiseMisrepresentation: ConsumerMerchandiseMisrepresentation + ) = + consumerMerchandiseMisrepresentation( + JsonField.of(consumerMerchandiseMisrepresentation) + ) + + /** + * Sets [Builder.consumerMerchandiseMisrepresentation] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerMerchandiseMisrepresentation] with a + * well-typed [ConsumerMerchandiseMisrepresentation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerMerchandiseMisrepresentation( + consumerMerchandiseMisrepresentation: + JsonField + ) = apply { + this.consumerMerchandiseMisrepresentation = consumerMerchandiseMisrepresentation + } + + /** + * Merchandise not as described. Required if and only if `category` is + * `consumer_merchandise_not_as_described`. + */ + fun consumerMerchandiseNotAsDescribed( + consumerMerchandiseNotAsDescribed: ConsumerMerchandiseNotAsDescribed + ) = consumerMerchandiseNotAsDescribed(JsonField.of(consumerMerchandiseNotAsDescribed)) + + /** + * Sets [Builder.consumerMerchandiseNotAsDescribed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerMerchandiseNotAsDescribed] with a well-typed + * [ConsumerMerchandiseNotAsDescribed] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumerMerchandiseNotAsDescribed( + consumerMerchandiseNotAsDescribed: JsonField + ) = apply { this.consumerMerchandiseNotAsDescribed = consumerMerchandiseNotAsDescribed } + + /** + * Merchandise not received. Required if and only if `category` is + * `consumer_merchandise_not_received`. + */ + fun consumerMerchandiseNotReceived( + consumerMerchandiseNotReceived: ConsumerMerchandiseNotReceived + ) = consumerMerchandiseNotReceived(JsonField.of(consumerMerchandiseNotReceived)) + + /** + * Sets [Builder.consumerMerchandiseNotReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerMerchandiseNotReceived] with a well-typed + * [ConsumerMerchandiseNotReceived] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerMerchandiseNotReceived( + consumerMerchandiseNotReceived: JsonField + ) = apply { this.consumerMerchandiseNotReceived = consumerMerchandiseNotReceived } + + /** + * Non-receipt of cash. Required if and only if `category` is + * `consumer_non_receipt_of_cash`. + */ + fun consumerNonReceiptOfCash(consumerNonReceiptOfCash: JsonValue) = apply { + this.consumerNonReceiptOfCash = consumerNonReceiptOfCash + } + + /** + * Original Credit Transaction (OCT) not accepted. Required if and only if `category` is + * `consumer_original_credit_transaction_not_accepted`. + */ + fun consumerOriginalCreditTransactionNotAccepted( + consumerOriginalCreditTransactionNotAccepted: + ConsumerOriginalCreditTransactionNotAccepted + ) = + consumerOriginalCreditTransactionNotAccepted( + JsonField.of(consumerOriginalCreditTransactionNotAccepted) + ) + + /** + * Sets [Builder.consumerOriginalCreditTransactionNotAccepted] to an arbitrary JSON + * value. + * + * You should usually call [Builder.consumerOriginalCreditTransactionNotAccepted] with a + * well-typed [ConsumerOriginalCreditTransactionNotAccepted] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerOriginalCreditTransactionNotAccepted( + consumerOriginalCreditTransactionNotAccepted: + JsonField + ) = apply { + this.consumerOriginalCreditTransactionNotAccepted = + consumerOriginalCreditTransactionNotAccepted + } + + /** + * Merchandise quality issue. Required if and only if `category` is + * `consumer_quality_merchandise`. + */ + fun consumerQualityMerchandise(consumerQualityMerchandise: ConsumerQualityMerchandise) = + consumerQualityMerchandise(JsonField.of(consumerQualityMerchandise)) + + /** + * Sets [Builder.consumerQualityMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerQualityMerchandise] with a well-typed + * [ConsumerQualityMerchandise] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumerQualityMerchandise( + consumerQualityMerchandise: JsonField + ) = apply { this.consumerQualityMerchandise = consumerQualityMerchandise } + + /** + * Services quality issue. Required if and only if `category` is + * `consumer_quality_services`. + */ + fun consumerQualityServices(consumerQualityServices: ConsumerQualityServices) = + consumerQualityServices(JsonField.of(consumerQualityServices)) + + /** + * Sets [Builder.consumerQualityServices] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerQualityServices] with a well-typed + * [ConsumerQualityServices] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumerQualityServices( + consumerQualityServices: JsonField + ) = apply { this.consumerQualityServices = consumerQualityServices } + + /** + * Services misrepresentation. Required if and only if `category` is + * `consumer_services_misrepresentation`. + */ + fun consumerServicesMisrepresentation( + consumerServicesMisrepresentation: ConsumerServicesMisrepresentation + ) = consumerServicesMisrepresentation(JsonField.of(consumerServicesMisrepresentation)) + + /** + * Sets [Builder.consumerServicesMisrepresentation] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesMisrepresentation] with a well-typed + * [ConsumerServicesMisrepresentation] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumerServicesMisrepresentation( + consumerServicesMisrepresentation: JsonField + ) = apply { this.consumerServicesMisrepresentation = consumerServicesMisrepresentation } + + /** + * Services not as described. Required if and only if `category` is + * `consumer_services_not_as_described`. + */ + fun consumerServicesNotAsDescribed( + consumerServicesNotAsDescribed: ConsumerServicesNotAsDescribed + ) = consumerServicesNotAsDescribed(JsonField.of(consumerServicesNotAsDescribed)) + + /** + * Sets [Builder.consumerServicesNotAsDescribed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesNotAsDescribed] with a well-typed + * [ConsumerServicesNotAsDescribed] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerServicesNotAsDescribed( + consumerServicesNotAsDescribed: JsonField + ) = apply { this.consumerServicesNotAsDescribed = consumerServicesNotAsDescribed } + + /** + * Services not received. Required if and only if `category` is + * `consumer_services_not_received`. + */ + fun consumerServicesNotReceived( + consumerServicesNotReceived: ConsumerServicesNotReceived + ) = consumerServicesNotReceived(JsonField.of(consumerServicesNotReceived)) + + /** + * Sets [Builder.consumerServicesNotReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesNotReceived] with a well-typed + * [ConsumerServicesNotReceived] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumerServicesNotReceived( + consumerServicesNotReceived: JsonField + ) = apply { this.consumerServicesNotReceived = consumerServicesNotReceived } + + /** Fraud. Required if and only if `category` is `fraud`. */ + fun fraud(fraud: Fraud) = fraud(JsonField.of(fraud)) + + /** + * Sets [Builder.fraud] to an arbitrary JSON value. + * + * You should usually call [Builder.fraud] with a well-typed [Fraud] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fraud(fraud: JsonField) = apply { this.fraud = fraud } + + /** Processing error. Required if and only if `category` is `processing_error`. */ + fun processingError(processingError: ProcessingError) = + processingError(JsonField.of(processingError)) + + /** + * Sets [Builder.processingError] to an arbitrary JSON value. + * + * You should usually call [Builder.processingError] with a well-typed [ProcessingError] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun processingError(processingError: JsonField) = apply { + this.processingError = processingError + } + + 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 [Visa]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .category() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Visa = + Visa( + checkRequired("category", category), + authorization, + consumerCanceledMerchandise, + consumerCanceledRecurringTransaction, + consumerCanceledServices, + consumerCounterfeitMerchandise, + consumerCreditNotProcessed, + consumerDamagedOrDefectiveMerchandise, + consumerMerchandiseMisrepresentation, + consumerMerchandiseNotAsDescribed, + consumerMerchandiseNotReceived, + consumerNonReceiptOfCash, + consumerOriginalCreditTransactionNotAccepted, + consumerQualityMerchandise, + consumerQualityServices, + consumerServicesMisrepresentation, + consumerServicesNotAsDescribed, + consumerServicesNotReceived, + fraud, + processingError, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Visa = apply { + if (validated) { + return@apply + } + + category().validate() + authorization().ifPresent { it.validate() } + consumerCanceledMerchandise().ifPresent { it.validate() } + consumerCanceledRecurringTransaction().ifPresent { it.validate() } + consumerCanceledServices().ifPresent { it.validate() } + consumerCounterfeitMerchandise().ifPresent { it.validate() } + consumerCreditNotProcessed().ifPresent { it.validate() } + consumerDamagedOrDefectiveMerchandise().ifPresent { it.validate() } + consumerMerchandiseMisrepresentation().ifPresent { it.validate() } + consumerMerchandiseNotAsDescribed().ifPresent { it.validate() } + consumerMerchandiseNotReceived().ifPresent { it.validate() } + consumerOriginalCreditTransactionNotAccepted().ifPresent { it.validate() } + consumerQualityMerchandise().ifPresent { it.validate() } + consumerQualityServices().ifPresent { it.validate() } + consumerServicesMisrepresentation().ifPresent { it.validate() } + consumerServicesNotAsDescribed().ifPresent { it.validate() } + consumerServicesNotReceived().ifPresent { it.validate() } + fraud().ifPresent { it.validate() } + processingError().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (category.asKnown().getOrNull()?.validity() ?: 0) + + (authorization.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCanceledMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCanceledRecurringTransaction.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCanceledServices.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCounterfeitMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCreditNotProcessed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerDamagedOrDefectiveMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerMerchandiseMisrepresentation.asKnown().getOrNull()?.validity() ?: 0) + + (consumerMerchandiseNotAsDescribed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerMerchandiseNotReceived.asKnown().getOrNull()?.validity() ?: 0) + + (consumerOriginalCreditTransactionNotAccepted.asKnown().getOrNull()?.validity() + ?: 0) + + (consumerQualityMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerQualityServices.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesMisrepresentation.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesNotAsDescribed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesNotReceived.asKnown().getOrNull()?.validity() ?: 0) + + (fraud.asKnown().getOrNull()?.validity() ?: 0) + + (processingError.asKnown().getOrNull()?.validity() ?: 0) + + /** Category. */ + 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 { + + /** Authorization. */ + @JvmField val AUTHORIZATION = of("authorization") + + /** Consumer: canceled merchandise. */ + @JvmField val CONSUMER_CANCELED_MERCHANDISE = of("consumer_canceled_merchandise") + + /** Consumer: canceled recurring transaction. */ + @JvmField + val CONSUMER_CANCELED_RECURRING_TRANSACTION = + of("consumer_canceled_recurring_transaction") + + /** Consumer: canceled services. */ + @JvmField val CONSUMER_CANCELED_SERVICES = of("consumer_canceled_services") + + /** Consumer: counterfeit merchandise. */ + @JvmField + val CONSUMER_COUNTERFEIT_MERCHANDISE = of("consumer_counterfeit_merchandise") + + /** Consumer: credit not processed. */ + @JvmField val CONSUMER_CREDIT_NOT_PROCESSED = of("consumer_credit_not_processed") + + /** Consumer: damaged or defective merchandise. */ + @JvmField + val CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE = + of("consumer_damaged_or_defective_merchandise") + + /** Consumer: merchandise misrepresentation. */ + @JvmField + val CONSUMER_MERCHANDISE_MISREPRESENTATION = + of("consumer_merchandise_misrepresentation") + + /** Consumer: merchandise not as described. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED = + of("consumer_merchandise_not_as_described") + + /** Consumer: merchandise not received. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_RECEIVED = of("consumer_merchandise_not_received") + + /** Consumer: non-receipt of cash. */ + @JvmField val CONSUMER_NON_RECEIPT_OF_CASH = of("consumer_non_receipt_of_cash") + + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + @JvmField + val CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED = + of("consumer_original_credit_transaction_not_accepted") + + /** Consumer: merchandise quality issue. */ + @JvmField val CONSUMER_QUALITY_MERCHANDISE = of("consumer_quality_merchandise") + + /** Consumer: services quality issue. */ + @JvmField val CONSUMER_QUALITY_SERVICES = of("consumer_quality_services") + + /** Consumer: services misrepresentation. */ + @JvmField + val CONSUMER_SERVICES_MISREPRESENTATION = of("consumer_services_misrepresentation") + + /** Consumer: services not as described. */ + @JvmField + val CONSUMER_SERVICES_NOT_AS_DESCRIBED = of("consumer_services_not_as_described") + + /** Consumer: services not received. */ + @JvmField val CONSUMER_SERVICES_NOT_RECEIVED = of("consumer_services_not_received") + + /** Fraud. */ + @JvmField val FRAUD = of("fraud") + + /** Processing error. */ + @JvmField val PROCESSING_ERROR = of("processing_error") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + } + + /** + * 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 { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + /** + * 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) { + AUTHORIZATION -> Value.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Value.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Value.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Value.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> Value.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Value.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Value.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Value.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Value.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> Value.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Value.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Value.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Value.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Value.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> Value.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> Value.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> Value.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Value.FRAUD + PROCESSING_ERROR -> Value.PROCESSING_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 IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AUTHORIZATION -> Known.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Known.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Known.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Known.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> Known.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Known.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Known.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Known.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Known.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> Known.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Known.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Known.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Known.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Known.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> Known.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> Known.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> Known.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Known.FRAUD + PROCESSING_ERROR -> Known.PROCESSING_ERROR + else -> throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Authorization. Required if and only if `category` is `authorization`. */ + class Authorization + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accountStatus: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_status") + @ExcludeMissing + accountStatus: JsonField = JsonMissing.of() + ) : this(accountStatus, mutableMapOf()) + + /** + * Account status. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun accountStatus(): AccountStatus = accountStatus.getRequired("account_status") + + /** + * Returns the raw JSON value of [accountStatus]. + * + * Unlike [accountStatus], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_status") + @ExcludeMissing + fun _accountStatus(): JsonField = accountStatus + + @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 [Authorization]. + * + * The following fields are required: + * ```java + * .accountStatus() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Authorization]. */ + class Builder internal constructor() { + + private var accountStatus: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authorization: Authorization) = apply { + accountStatus = authorization.accountStatus + additionalProperties = authorization.additionalProperties.toMutableMap() + } + + /** Account status. */ + fun accountStatus(accountStatus: AccountStatus) = + accountStatus(JsonField.of(accountStatus)) + + /** + * Sets [Builder.accountStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.accountStatus] with a well-typed [AccountStatus] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun accountStatus(accountStatus: JsonField) = apply { + this.accountStatus = accountStatus + } + + 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 [Authorization]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountStatus() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Authorization = + Authorization( + checkRequired("accountStatus", accountStatus), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Authorization = apply { + if (validated) { + return@apply + } + + accountStatus().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (accountStatus.asKnown().getOrNull()?.validity() ?: 0) + + /** Account status. */ + class AccountStatus + @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 { + + /** Account closed. */ + @JvmField val ACCOUNT_CLOSED = of("account_closed") + + /** Credit problem. */ + @JvmField val CREDIT_PROBLEM = of("credit_problem") + + /** Fraud. */ + @JvmField val FRAUD = of("fraud") + + @JvmStatic fun of(value: String) = AccountStatus(JsonField.of(value)) + } + + /** An enum containing [AccountStatus]'s known values. */ + enum class Known { + /** Account closed. */ + ACCOUNT_CLOSED, + /** Credit problem. */ + CREDIT_PROBLEM, + /** Fraud. */ + FRAUD, + } + + /** + * An enum containing [AccountStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AccountStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may 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 closed. */ + ACCOUNT_CLOSED, + /** Credit problem. */ + CREDIT_PROBLEM, + /** Fraud. */ + FRAUD, + /** + * An enum member indicating that [AccountStatus] 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_CLOSED -> Value.ACCOUNT_CLOSED + CREDIT_PROBLEM -> Value.CREDIT_PROBLEM + FRAUD -> Value.FRAUD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_CLOSED -> Known.ACCOUNT_CLOSED + CREDIT_PROBLEM -> Known.CREDIT_PROBLEM + FRAUD -> Known.FRAUD + else -> throw IncreaseInvalidDataException("Unknown AccountStatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AccountStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountStatus && 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 Authorization && + accountStatus == other.accountStatus && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(accountStatus, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Authorization{accountStatus=$accountStatus, additionalProperties=$additionalProperties}" + } + + /** + * Canceled merchandise. Required if and only if `category` is + * `consumer_canceled_merchandise`. + */ + class ConsumerCanceledMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val purchaseExplanation: JsonField, + private val receivedOrExpectedAt: JsonField, + private val returnOutcome: JsonField, + private val cardholderCancellation: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_or_expected_at") + @ExcludeMissing + receivedOrExpectedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + purchaseExplanation, + receivedOrExpectedAt, + returnOutcome, + cardholderCancellation, + notReturned, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received or expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun receivedOrExpectedAt(): LocalDate = + receivedOrExpectedAt.getRequired("received_or_expected_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun cardholderCancellation(): Optional = + cardholderCancellation.getOptional("cardholder_cancellation") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedOrExpectedAt]. + * + * Unlike [receivedOrExpectedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_or_expected_at") + @ExcludeMissing + fun _receivedOrExpectedAt(): JsonField = receivedOrExpectedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerCanceledMerchandise]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .purchaseExplanation() + * .receivedOrExpectedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledMerchandise]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: JsonField? = + null + private var purchaseExplanation: JsonField? = null + private var receivedOrExpectedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var cardholderCancellation: JsonField = + JsonMissing.of() + private var notReturned: JsonValue = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCanceledMerchandise: ConsumerCanceledMerchandise) = + apply { + merchantResolutionAttempted = + consumerCanceledMerchandise.merchantResolutionAttempted + purchaseExplanation = consumerCanceledMerchandise.purchaseExplanation + receivedOrExpectedAt = consumerCanceledMerchandise.receivedOrExpectedAt + returnOutcome = consumerCanceledMerchandise.returnOutcome + cardholderCancellation = consumerCanceledMerchandise.cardholderCancellation + notReturned = consumerCanceledMerchandise.notReturned + returnAttempted = consumerCanceledMerchandise.returnAttempted + returned = consumerCanceledMerchandise.returned + additionalProperties = + consumerCanceledMerchandise.additionalProperties.toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received or expected at. */ + fun receivedOrExpectedAt(receivedOrExpectedAt: LocalDate) = + receivedOrExpectedAt(JsonField.of(receivedOrExpectedAt)) + + /** + * Sets [Builder.receivedOrExpectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedOrExpectedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receivedOrExpectedAt(receivedOrExpectedAt: JsonField) = apply { + this.receivedOrExpectedAt = receivedOrExpectedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed [ReturnOutcome] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { this.notReturned = notReturned } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerCanceledMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .purchaseExplanation() + * .receivedOrExpectedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledMerchandise = + ConsumerCanceledMerchandise( + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedOrExpectedAt", receivedOrExpectedAt), + checkRequired("returnOutcome", returnOutcome), + cardholderCancellation, + notReturned, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledMerchandise = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + purchaseExplanation() + receivedOrExpectedAt() + returnOutcome().validate() + cardholderCancellation().ifPresent { it.validate() } + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedOrExpectedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val canceledPriorToShipDate: JsonField, + private val cancellationPolicyProvided: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("canceled_prior_to_ship_date") + @ExcludeMissing + canceledPriorToShipDate: JsonField = JsonMissing.of(), + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + cancellationPolicyProvided: JsonField = + JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + canceledAt, + canceledPriorToShipDate, + cancellationPolicyProvided, + reason, + mutableMapOf(), + ) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Canceled prior to ship date. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledPriorToShipDate(): CanceledPriorToShipDate = + canceledPriorToShipDate.getRequired("canceled_prior_to_ship_date") + + /** + * Cancellation policy provided. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationPolicyProvided(): CancellationPolicyProvided = + cancellationPolicyProvided.getRequired("cancellation_policy_provided") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * Returns the raw JSON value of [canceledPriorToShipDate]. + * + * Unlike [canceledPriorToShipDate], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("canceled_prior_to_ship_date") + @ExcludeMissing + fun _canceledPriorToShipDate(): JsonField = + canceledPriorToShipDate + + /** + * Returns the raw JSON value of [cancellationPolicyProvided]. + * + * Unlike [cancellationPolicyProvided], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + fun _cancellationPolicyProvided(): JsonField = + cancellationPolicyProvided + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .canceledPriorToShipDate() + * .cancellationPolicyProvided() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var canceledPriorToShipDate: JsonField? = null + private var cancellationPolicyProvided: JsonField? = + null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + canceledAt = cardholderCancellation.canceledAt + canceledPriorToShipDate = cardholderCancellation.canceledPriorToShipDate + cancellationPolicyProvided = + cardholderCancellation.cancellationPolicyProvided + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Canceled prior to ship date. */ + fun canceledPriorToShipDate(canceledPriorToShipDate: CanceledPriorToShipDate) = + canceledPriorToShipDate(JsonField.of(canceledPriorToShipDate)) + + /** + * Sets [Builder.canceledPriorToShipDate] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledPriorToShipDate] with a well-typed + * [CanceledPriorToShipDate] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun canceledPriorToShipDate( + canceledPriorToShipDate: JsonField + ) = apply { this.canceledPriorToShipDate = canceledPriorToShipDate } + + /** Cancellation policy provided. */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: CancellationPolicyProvided + ) = cancellationPolicyProvided(JsonField.of(cancellationPolicyProvided)) + + /** + * Sets [Builder.cancellationPolicyProvided] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationPolicyProvided] with a + * well-typed [CancellationPolicyProvided] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: JsonField + ) = apply { this.cancellationPolicyProvided = cancellationPolicyProvided } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .canceledPriorToShipDate() + * .cancellationPolicyProvided() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("canceledAt", canceledAt), + checkRequired("canceledPriorToShipDate", canceledPriorToShipDate), + checkRequired("cancellationPolicyProvided", cancellationPolicyProvided), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + canceledPriorToShipDate().validate() + cancellationPolicyProvided().validate() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (canceledPriorToShipDate.asKnown().getOrNull()?.validity() ?: 0) + + (cancellationPolicyProvided.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Canceled prior to ship date. */ + class CanceledPriorToShipDate + @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 { + + /** Canceled prior to ship date. */ + @JvmField + val CANCELED_PRIOR_TO_SHIP_DATE = of("canceled_prior_to_ship_date") + + /** Not canceled prior to ship date. */ + @JvmField + val NOT_CANCELED_PRIOR_TO_SHIP_DATE = of("not_canceled_prior_to_ship_date") + + @JvmStatic + fun of(value: String) = CanceledPriorToShipDate(JsonField.of(value)) + } + + /** An enum containing [CanceledPriorToShipDate]'s known values. */ + enum class Known { + /** Canceled prior to ship date. */ + CANCELED_PRIOR_TO_SHIP_DATE, + /** Not canceled prior to ship date. */ + NOT_CANCELED_PRIOR_TO_SHIP_DATE, + } + + /** + * An enum containing [CanceledPriorToShipDate]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CanceledPriorToShipDate] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Canceled prior to ship date. */ + CANCELED_PRIOR_TO_SHIP_DATE, + /** Not canceled prior to ship date. */ + NOT_CANCELED_PRIOR_TO_SHIP_DATE, + /** + * An enum member indicating that [CanceledPriorToShipDate] 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) { + CANCELED_PRIOR_TO_SHIP_DATE -> Value.CANCELED_PRIOR_TO_SHIP_DATE + NOT_CANCELED_PRIOR_TO_SHIP_DATE -> Value.NOT_CANCELED_PRIOR_TO_SHIP_DATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CANCELED_PRIOR_TO_SHIP_DATE -> Known.CANCELED_PRIOR_TO_SHIP_DATE + NOT_CANCELED_PRIOR_TO_SHIP_DATE -> Known.NOT_CANCELED_PRIOR_TO_SHIP_DATE + else -> + throw IncreaseInvalidDataException( + "Unknown CanceledPriorToShipDate: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CanceledPriorToShipDate = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CanceledPriorToShipDate && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Cancellation policy provided. */ + class CancellationPolicyProvided + @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 { + + /** Not provided. */ + @JvmField val NOT_PROVIDED = of("not_provided") + + /** Provided. */ + @JvmField val PROVIDED = of("provided") + + @JvmStatic + fun of(value: String) = CancellationPolicyProvided(JsonField.of(value)) + } + + /** An enum containing [CancellationPolicyProvided]'s known values. */ + enum class Known { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + } + + /** + * An enum containing [CancellationPolicyProvided]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CancellationPolicyProvided] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + /** + * An enum member indicating that [CancellationPolicyProvided] 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) { + NOT_PROVIDED -> Value.NOT_PROVIDED + PROVIDED -> Value.PROVIDED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_PROVIDED -> Known.NOT_PROVIDED + PROVIDED -> Known.PROVIDED + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationPolicyProvided: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationPolicyProvided = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationPolicyProvided && 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 CardholderCancellation && + canceledAt == other.canceledAt && + canceledPriorToShipDate == other.canceledPriorToShipDate && + cancellationPolicyProvided == other.cancellationPolicyProvided && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + canceledAt, + canceledPriorToShipDate, + cancellationPolicyProvided, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{canceledAt=$canceledAt, canceledPriorToShipDate=$canceledPriorToShipDate, cancellationPolicyProvided=$cancellationPolicyProvided, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Return attempted. Required if and only if `return_outcome` is `return_attempted`. */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException("Unknown AttemptReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: JsonField) = + apply { + this.merchantReceivedReturnAt = merchantReceivedReturnAt + } + + /** Other explanation. Required if and only if the return method is `other`. */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException("Unknown ReturnMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCanceledMerchandise && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseExplanation == other.purchaseExplanation && + receivedOrExpectedAt == other.receivedOrExpectedAt && + returnOutcome == other.returnOutcome && + cardholderCancellation == other.cardholderCancellation && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + purchaseExplanation, + receivedOrExpectedAt, + returnOutcome, + cardholderCancellation, + notReturned, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledMerchandise{merchantResolutionAttempted=$merchantResolutionAttempted, purchaseExplanation=$purchaseExplanation, receivedOrExpectedAt=$receivedOrExpectedAt, returnOutcome=$returnOutcome, cardholderCancellation=$cardholderCancellation, notReturned=$notReturned, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Canceled recurring transaction. Required if and only if `category` is + * `consumer_canceled_recurring_transaction`. + */ + class ConsumerCanceledRecurringTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationTarget: JsonField, + private val merchantContactMethods: JsonField, + private val transactionOrAccountCanceledAt: JsonField, + private val otherFormOfPaymentExplanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_target") + @ExcludeMissing + cancellationTarget: JsonField = JsonMissing.of(), + @JsonProperty("merchant_contact_methods") + @ExcludeMissing + merchantContactMethods: JsonField = JsonMissing.of(), + @JsonProperty("transaction_or_account_canceled_at") + @ExcludeMissing + transactionOrAccountCanceledAt: JsonField = JsonMissing.of(), + @JsonProperty("other_form_of_payment_explanation") + @ExcludeMissing + otherFormOfPaymentExplanation: JsonField = JsonMissing.of(), + ) : this( + cancellationTarget, + merchantContactMethods, + transactionOrAccountCanceledAt, + otherFormOfPaymentExplanation, + mutableMapOf(), + ) + + /** + * Cancellation target. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cancellationTarget(): CancellationTarget = + cancellationTarget.getRequired("cancellation_target") + + /** + * Merchant contact methods. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantContactMethods(): MerchantContactMethods = + merchantContactMethods.getRequired("merchant_contact_methods") + + /** + * Transaction or account canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun transactionOrAccountCanceledAt(): LocalDate = + transactionOrAccountCanceledAt.getRequired("transaction_or_account_canceled_at") + + /** + * Other form of payment explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun otherFormOfPaymentExplanation(): Optional = + otherFormOfPaymentExplanation.getOptional("other_form_of_payment_explanation") + + /** + * Returns the raw JSON value of [cancellationTarget]. + * + * Unlike [cancellationTarget], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cancellation_target") + @ExcludeMissing + fun _cancellationTarget(): JsonField = cancellationTarget + + /** + * Returns the raw JSON value of [merchantContactMethods]. + * + * Unlike [merchantContactMethods], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_contact_methods") + @ExcludeMissing + fun _merchantContactMethods(): JsonField = + merchantContactMethods + + /** + * Returns the raw JSON value of [transactionOrAccountCanceledAt]. + * + * Unlike [transactionOrAccountCanceledAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("transaction_or_account_canceled_at") + @ExcludeMissing + fun _transactionOrAccountCanceledAt(): JsonField = + transactionOrAccountCanceledAt + + /** + * Returns the raw JSON value of [otherFormOfPaymentExplanation]. + * + * Unlike [otherFormOfPaymentExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_form_of_payment_explanation") + @ExcludeMissing + fun _otherFormOfPaymentExplanation(): JsonField = otherFormOfPaymentExplanation + + @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 + * [ConsumerCanceledRecurringTransaction]. + * + * The following fields are required: + * ```java + * .cancellationTarget() + * .merchantContactMethods() + * .transactionOrAccountCanceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledRecurringTransaction]. */ + class Builder internal constructor() { + + private var cancellationTarget: JsonField? = null + private var merchantContactMethods: JsonField? = null + private var transactionOrAccountCanceledAt: JsonField? = null + private var otherFormOfPaymentExplanation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerCanceledRecurringTransaction: ConsumerCanceledRecurringTransaction + ) = apply { + cancellationTarget = consumerCanceledRecurringTransaction.cancellationTarget + merchantContactMethods = + consumerCanceledRecurringTransaction.merchantContactMethods + transactionOrAccountCanceledAt = + consumerCanceledRecurringTransaction.transactionOrAccountCanceledAt + otherFormOfPaymentExplanation = + consumerCanceledRecurringTransaction.otherFormOfPaymentExplanation + additionalProperties = + consumerCanceledRecurringTransaction.additionalProperties.toMutableMap() + } + + /** Cancellation target. */ + fun cancellationTarget(cancellationTarget: CancellationTarget) = + cancellationTarget(JsonField.of(cancellationTarget)) + + /** + * Sets [Builder.cancellationTarget] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationTarget] with a well-typed + * [CancellationTarget] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cancellationTarget(cancellationTarget: JsonField) = apply { + this.cancellationTarget = cancellationTarget + } + + /** Merchant contact methods. */ + fun merchantContactMethods(merchantContactMethods: MerchantContactMethods) = + merchantContactMethods(JsonField.of(merchantContactMethods)) + + /** + * Sets [Builder.merchantContactMethods] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantContactMethods] with a well-typed + * [MerchantContactMethods] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun merchantContactMethods( + merchantContactMethods: JsonField + ) = apply { this.merchantContactMethods = merchantContactMethods } + + /** Transaction or account canceled at. */ + fun transactionOrAccountCanceledAt(transactionOrAccountCanceledAt: LocalDate) = + transactionOrAccountCanceledAt(JsonField.of(transactionOrAccountCanceledAt)) + + /** + * Sets [Builder.transactionOrAccountCanceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionOrAccountCanceledAt] with a + * well-typed [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transactionOrAccountCanceledAt( + transactionOrAccountCanceledAt: JsonField + ) = apply { this.transactionOrAccountCanceledAt = transactionOrAccountCanceledAt } + + /** Other form of payment explanation. */ + fun otherFormOfPaymentExplanation(otherFormOfPaymentExplanation: String) = + otherFormOfPaymentExplanation(JsonField.of(otherFormOfPaymentExplanation)) + + /** + * Sets [Builder.otherFormOfPaymentExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherFormOfPaymentExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun otherFormOfPaymentExplanation( + otherFormOfPaymentExplanation: JsonField + ) = apply { this.otherFormOfPaymentExplanation = otherFormOfPaymentExplanation } + + 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 [ConsumerCanceledRecurringTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationTarget() + * .merchantContactMethods() + * .transactionOrAccountCanceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledRecurringTransaction = + ConsumerCanceledRecurringTransaction( + checkRequired("cancellationTarget", cancellationTarget), + checkRequired("merchantContactMethods", merchantContactMethods), + checkRequired( + "transactionOrAccountCanceledAt", + transactionOrAccountCanceledAt, + ), + otherFormOfPaymentExplanation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledRecurringTransaction = apply { + if (validated) { + return@apply + } + + cancellationTarget().validate() + merchantContactMethods().validate() + transactionOrAccountCanceledAt() + otherFormOfPaymentExplanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationTarget.asKnown().getOrNull()?.validity() ?: 0) + + (merchantContactMethods.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionOrAccountCanceledAt.asKnown().isPresent) 1 else 0) + + (if (otherFormOfPaymentExplanation.asKnown().isPresent) 1 else 0) + + /** Cancellation target. */ + class CancellationTarget + @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 { + + /** Account. */ + @JvmField val ACCOUNT = of("account") + + /** Transaction. */ + @JvmField val TRANSACTION = of("transaction") + + @JvmStatic fun of(value: String) = CancellationTarget(JsonField.of(value)) + } + + /** An enum containing [CancellationTarget]'s known values. */ + enum class Known { + /** Account. */ + ACCOUNT, + /** Transaction. */ + TRANSACTION, + } + + /** + * An enum containing [CancellationTarget]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [CancellationTarget] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may 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. */ + ACCOUNT, + /** Transaction. */ + TRANSACTION, + /** + * An enum member indicating that [CancellationTarget] 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 -> Value.ACCOUNT + 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 IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACCOUNT -> Known.ACCOUNT + TRANSACTION -> Known.TRANSACTION + else -> + throw IncreaseInvalidDataException("Unknown CancellationTarget: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationTarget = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationTarget && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant contact methods. */ + class MerchantContactMethods + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val applicationName: JsonField, + private val callCenterPhoneNumber: JsonField, + private val emailAddress: JsonField, + private val inPersonAddress: JsonField, + private val mailingAddress: JsonField, + private val textPhoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("application_name") + @ExcludeMissing + applicationName: JsonField = JsonMissing.of(), + @JsonProperty("call_center_phone_number") + @ExcludeMissing + callCenterPhoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("email_address") + @ExcludeMissing + emailAddress: JsonField = JsonMissing.of(), + @JsonProperty("in_person_address") + @ExcludeMissing + inPersonAddress: JsonField = JsonMissing.of(), + @JsonProperty("mailing_address") + @ExcludeMissing + mailingAddress: JsonField = JsonMissing.of(), + @JsonProperty("text_phone_number") + @ExcludeMissing + textPhoneNumber: JsonField = JsonMissing.of(), + ) : this( + applicationName, + callCenterPhoneNumber, + emailAddress, + inPersonAddress, + mailingAddress, + textPhoneNumber, + mutableMapOf(), + ) + + /** + * Application name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicationName(): Optional = + applicationName.getOptional("application_name") + + /** + * Call center phone number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun callCenterPhoneNumber(): Optional = + callCenterPhoneNumber.getOptional("call_center_phone_number") + + /** + * Email address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun emailAddress(): Optional = emailAddress.getOptional("email_address") + + /** + * In person address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun inPersonAddress(): Optional = + inPersonAddress.getOptional("in_person_address") + + /** + * Mailing address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun mailingAddress(): Optional = + mailingAddress.getOptional("mailing_address") + + /** + * Text phone number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textPhoneNumber(): Optional = + textPhoneNumber.getOptional("text_phone_number") + + /** + * Returns the raw JSON value of [applicationName]. + * + * Unlike [applicationName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("application_name") + @ExcludeMissing + fun _applicationName(): JsonField = applicationName + + /** + * Returns the raw JSON value of [callCenterPhoneNumber]. + * + * Unlike [callCenterPhoneNumber], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("call_center_phone_number") + @ExcludeMissing + fun _callCenterPhoneNumber(): JsonField = callCenterPhoneNumber + + /** + * Returns the raw JSON value of [emailAddress]. + * + * Unlike [emailAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("email_address") + @ExcludeMissing + fun _emailAddress(): JsonField = emailAddress + + /** + * Returns the raw JSON value of [inPersonAddress]. + * + * Unlike [inPersonAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("in_person_address") + @ExcludeMissing + fun _inPersonAddress(): JsonField = inPersonAddress + + /** + * Returns the raw JSON value of [mailingAddress]. + * + * Unlike [mailingAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mailing_address") + @ExcludeMissing + fun _mailingAddress(): JsonField = mailingAddress + + /** + * Returns the raw JSON value of [textPhoneNumber]. + * + * Unlike [textPhoneNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("text_phone_number") + @ExcludeMissing + fun _textPhoneNumber(): JsonField = textPhoneNumber + + @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 + * [MerchantContactMethods]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantContactMethods]. */ + class Builder internal constructor() { + + private var applicationName: JsonField = JsonMissing.of() + private var callCenterPhoneNumber: JsonField = JsonMissing.of() + private var emailAddress: JsonField = JsonMissing.of() + private var inPersonAddress: JsonField = JsonMissing.of() + private var mailingAddress: JsonField = JsonMissing.of() + private var textPhoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantContactMethods: MerchantContactMethods) = apply { + applicationName = merchantContactMethods.applicationName + callCenterPhoneNumber = merchantContactMethods.callCenterPhoneNumber + emailAddress = merchantContactMethods.emailAddress + inPersonAddress = merchantContactMethods.inPersonAddress + mailingAddress = merchantContactMethods.mailingAddress + textPhoneNumber = merchantContactMethods.textPhoneNumber + additionalProperties = + merchantContactMethods.additionalProperties.toMutableMap() + } + + /** Application name. */ + fun applicationName(applicationName: String) = + applicationName(JsonField.of(applicationName)) + + /** + * Sets [Builder.applicationName] to an arbitrary JSON value. + * + * You should usually call [Builder.applicationName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun applicationName(applicationName: JsonField) = apply { + this.applicationName = applicationName + } + + /** Call center phone number. */ + fun callCenterPhoneNumber(callCenterPhoneNumber: String) = + callCenterPhoneNumber(JsonField.of(callCenterPhoneNumber)) + + /** + * Sets [Builder.callCenterPhoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.callCenterPhoneNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun callCenterPhoneNumber(callCenterPhoneNumber: JsonField) = apply { + this.callCenterPhoneNumber = callCenterPhoneNumber + } + + /** Email address. */ + fun emailAddress(emailAddress: String) = + emailAddress(JsonField.of(emailAddress)) + + /** + * Sets [Builder.emailAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.emailAddress] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun emailAddress(emailAddress: JsonField) = apply { + this.emailAddress = emailAddress + } + + /** In person address. */ + fun inPersonAddress(inPersonAddress: String) = + inPersonAddress(JsonField.of(inPersonAddress)) + + /** + * Sets [Builder.inPersonAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.inPersonAddress] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun inPersonAddress(inPersonAddress: JsonField) = apply { + this.inPersonAddress = inPersonAddress + } + + /** Mailing address. */ + fun mailingAddress(mailingAddress: String) = + mailingAddress(JsonField.of(mailingAddress)) + + /** + * Sets [Builder.mailingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.mailingAddress] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun mailingAddress(mailingAddress: JsonField) = apply { + this.mailingAddress = mailingAddress + } + + /** Text phone number. */ + fun textPhoneNumber(textPhoneNumber: String) = + textPhoneNumber(JsonField.of(textPhoneNumber)) + + /** + * Sets [Builder.textPhoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.textPhoneNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun textPhoneNumber(textPhoneNumber: JsonField) = apply { + this.textPhoneNumber = textPhoneNumber + } + + 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 [MerchantContactMethods]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MerchantContactMethods = + MerchantContactMethods( + applicationName, + callCenterPhoneNumber, + emailAddress, + inPersonAddress, + mailingAddress, + textPhoneNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantContactMethods = apply { + if (validated) { + return@apply + } + + applicationName() + callCenterPhoneNumber() + emailAddress() + inPersonAddress() + mailingAddress() + textPhoneNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (applicationName.asKnown().isPresent) 1 else 0) + + (if (callCenterPhoneNumber.asKnown().isPresent) 1 else 0) + + (if (emailAddress.asKnown().isPresent) 1 else 0) + + (if (inPersonAddress.asKnown().isPresent) 1 else 0) + + (if (mailingAddress.asKnown().isPresent) 1 else 0) + + (if (textPhoneNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantContactMethods && + applicationName == other.applicationName && + callCenterPhoneNumber == other.callCenterPhoneNumber && + emailAddress == other.emailAddress && + inPersonAddress == other.inPersonAddress && + mailingAddress == other.mailingAddress && + textPhoneNumber == other.textPhoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + applicationName, + callCenterPhoneNumber, + emailAddress, + inPersonAddress, + mailingAddress, + textPhoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantContactMethods{applicationName=$applicationName, callCenterPhoneNumber=$callCenterPhoneNumber, emailAddress=$emailAddress, inPersonAddress=$inPersonAddress, mailingAddress=$mailingAddress, textPhoneNumber=$textPhoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCanceledRecurringTransaction && + cancellationTarget == other.cancellationTarget && + merchantContactMethods == other.merchantContactMethods && + transactionOrAccountCanceledAt == other.transactionOrAccountCanceledAt && + otherFormOfPaymentExplanation == other.otherFormOfPaymentExplanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationTarget, + merchantContactMethods, + transactionOrAccountCanceledAt, + otherFormOfPaymentExplanation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledRecurringTransaction{cancellationTarget=$cancellationTarget, merchantContactMethods=$merchantContactMethods, transactionOrAccountCanceledAt=$transactionOrAccountCanceledAt, otherFormOfPaymentExplanation=$otherFormOfPaymentExplanation, additionalProperties=$additionalProperties}" + } + + /** + * Canceled services. Required if and only if `category` is `consumer_canceled_services`. + */ + class ConsumerCanceledServices + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val contractedAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val purchaseExplanation: JsonField, + private val serviceType: JsonField, + private val guaranteedReservation: JsonField, + private val other: JsonValue, + private val timeshare: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty("contracted_at") + @ExcludeMissing + contractedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("service_type") + @ExcludeMissing + serviceType: JsonField = JsonMissing.of(), + @JsonProperty("guaranteed_reservation") + @ExcludeMissing + guaranteedReservation: JsonField = JsonMissing.of(), + @JsonProperty("other") @ExcludeMissing other: JsonValue = JsonMissing.of(), + @JsonProperty("timeshare") @ExcludeMissing timeshare: JsonValue = JsonMissing.of(), + ) : this( + cardholderCancellation, + contractedAt, + merchantResolutionAttempted, + purchaseExplanation, + serviceType, + guaranteedReservation, + other, + timeshare, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Contracted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun contractedAt(): LocalDate = contractedAt.getRequired("contracted_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Service type. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun serviceType(): ServiceType = serviceType.getRequired("service_type") + + /** + * Guaranteed reservation explanation. Required if and only if `service_type` is + * `guaranteed_reservation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun guaranteedReservation(): Optional = + guaranteedReservation.getOptional("guaranteed_reservation") + + /** + * Other service type explanation. Required if and only if `service_type` is `other`. + */ + @JsonProperty("other") @ExcludeMissing fun _other(): JsonValue = other + + /** Timeshare explanation. Required if and only if `service_type` is `timeshare`. */ + @JsonProperty("timeshare") @ExcludeMissing fun _timeshare(): JsonValue = timeshare + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [contractedAt]. + * + * Unlike [contractedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("contracted_at") + @ExcludeMissing + fun _contractedAt(): JsonField = contractedAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [serviceType]. + * + * Unlike [serviceType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("service_type") + @ExcludeMissing + fun _serviceType(): JsonField = serviceType + + /** + * Returns the raw JSON value of [guaranteedReservation]. + * + * Unlike [guaranteedReservation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("guaranteed_reservation") + @ExcludeMissing + fun _guaranteedReservation(): JsonField = guaranteedReservation + + @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 + * [ConsumerCanceledServices]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .contractedAt() + * .merchantResolutionAttempted() + * .purchaseExplanation() + * .serviceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledServices]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = null + private var contractedAt: JsonField? = null + private var merchantResolutionAttempted: JsonField? = + null + private var purchaseExplanation: JsonField? = null + private var serviceType: JsonField? = null + private var guaranteedReservation: JsonField = + JsonMissing.of() + private var other: JsonValue = JsonMissing.of() + private var timeshare: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCanceledServices: ConsumerCanceledServices) = apply { + cardholderCancellation = consumerCanceledServices.cardholderCancellation + contractedAt = consumerCanceledServices.contractedAt + merchantResolutionAttempted = + consumerCanceledServices.merchantResolutionAttempted + purchaseExplanation = consumerCanceledServices.purchaseExplanation + serviceType = consumerCanceledServices.serviceType + guaranteedReservation = consumerCanceledServices.guaranteedReservation + other = consumerCanceledServices.other + timeshare = consumerCanceledServices.timeshare + additionalProperties = + consumerCanceledServices.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Contracted at. */ + fun contractedAt(contractedAt: LocalDate) = contractedAt(JsonField.of(contractedAt)) + + /** + * Sets [Builder.contractedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.contractedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun contractedAt(contractedAt: JsonField) = apply { + this.contractedAt = contractedAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Service type. */ + fun serviceType(serviceType: ServiceType) = serviceType(JsonField.of(serviceType)) + + /** + * Sets [Builder.serviceType] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceType] with a well-typed [ServiceType] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun serviceType(serviceType: JsonField) = apply { + this.serviceType = serviceType + } + + /** + * Guaranteed reservation explanation. Required if and only if `service_type` is + * `guaranteed_reservation`. + */ + fun guaranteedReservation(guaranteedReservation: GuaranteedReservation) = + guaranteedReservation(JsonField.of(guaranteedReservation)) + + /** + * Sets [Builder.guaranteedReservation] to an arbitrary JSON value. + * + * You should usually call [Builder.guaranteedReservation] with a well-typed + * [GuaranteedReservation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun guaranteedReservation(guaranteedReservation: JsonField) = + apply { + this.guaranteedReservation = guaranteedReservation + } + + /** + * Other service type explanation. Required if and only if `service_type` is + * `other`. + */ + fun other(other: JsonValue) = apply { this.other = other } + + /** Timeshare explanation. Required if and only if `service_type` is `timeshare`. */ + fun timeshare(timeshare: JsonValue) = apply { this.timeshare = timeshare } + + 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 [ConsumerCanceledServices]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .contractedAt() + * .merchantResolutionAttempted() + * .purchaseExplanation() + * .serviceType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledServices = + ConsumerCanceledServices( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired("contractedAt", contractedAt), + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("serviceType", serviceType), + guaranteedReservation, + other, + timeshare, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledServices = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + contractedAt() + merchantResolutionAttempted().validate() + purchaseExplanation() + serviceType().validate() + guaranteedReservation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (if (contractedAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (serviceType.asKnown().getOrNull()?.validity() ?: 0) + + (guaranteedReservation.asKnown().getOrNull()?.validity() ?: 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val cancellationPolicyProvided: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + cancellationPolicyProvided: JsonField = + JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, cancellationPolicyProvided, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Cancellation policy provided. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationPolicyProvided(): CancellationPolicyProvided = + cancellationPolicyProvided.getRequired("cancellation_policy_provided") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * Returns the raw JSON value of [cancellationPolicyProvided]. + * + * Unlike [cancellationPolicyProvided], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + fun _cancellationPolicyProvided(): JsonField = + cancellationPolicyProvided + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .cancellationPolicyProvided() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var cancellationPolicyProvided: JsonField? = + null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + canceledAt = cardholderCancellation.canceledAt + cancellationPolicyProvided = + cardholderCancellation.cancellationPolicyProvided + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Cancellation policy provided. */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: CancellationPolicyProvided + ) = cancellationPolicyProvided(JsonField.of(cancellationPolicyProvided)) + + /** + * Sets [Builder.cancellationPolicyProvided] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationPolicyProvided] with a + * well-typed [CancellationPolicyProvided] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: JsonField + ) = apply { this.cancellationPolicyProvided = cancellationPolicyProvided } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .cancellationPolicyProvided() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("canceledAt", canceledAt), + checkRequired("cancellationPolicyProvided", cancellationPolicyProvided), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + cancellationPolicyProvided().validate() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (cancellationPolicyProvided.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Cancellation policy provided. */ + class CancellationPolicyProvided + @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 { + + /** Not provided. */ + @JvmField val NOT_PROVIDED = of("not_provided") + + /** Provided. */ + @JvmField val PROVIDED = of("provided") + + @JvmStatic + fun of(value: String) = CancellationPolicyProvided(JsonField.of(value)) + } + + /** An enum containing [CancellationPolicyProvided]'s known values. */ + enum class Known { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + } + + /** + * An enum containing [CancellationPolicyProvided]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CancellationPolicyProvided] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + /** + * An enum member indicating that [CancellationPolicyProvided] 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) { + NOT_PROVIDED -> Value.NOT_PROVIDED + PROVIDED -> Value.PROVIDED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_PROVIDED -> Known.NOT_PROVIDED + PROVIDED -> Known.PROVIDED + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationPolicyProvided: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationPolicyProvided = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationPolicyProvided && 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 CardholderCancellation && + canceledAt == other.canceledAt && + cancellationPolicyProvided == other.cancellationPolicyProvided && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + canceledAt, + cancellationPolicyProvided, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{canceledAt=$canceledAt, cancellationPolicyProvided=$cancellationPolicyProvided, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Service type. */ + class ServiceType + @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 { + + /** Guaranteed reservation. */ + @JvmField val GUARANTEED_RESERVATION = of("guaranteed_reservation") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Timeshare. */ + @JvmField val TIMESHARE = of("timeshare") + + @JvmStatic fun of(value: String) = ServiceType(JsonField.of(value)) + } + + /** An enum containing [ServiceType]'s known values. */ + enum class Known { + /** Guaranteed reservation. */ + GUARANTEED_RESERVATION, + /** Other. */ + OTHER, + /** Timeshare. */ + TIMESHARE, + } + + /** + * An enum containing [ServiceType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ServiceType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Guaranteed reservation. */ + GUARANTEED_RESERVATION, + /** Other. */ + OTHER, + /** Timeshare. */ + TIMESHARE, + /** + * An enum member indicating that [ServiceType] 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) { + GUARANTEED_RESERVATION -> Value.GUARANTEED_RESERVATION + OTHER -> Value.OTHER + TIMESHARE -> Value.TIMESHARE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_RESERVATION -> Known.GUARANTEED_RESERVATION + OTHER -> Known.OTHER + TIMESHARE -> Known.TIMESHARE + else -> throw IncreaseInvalidDataException("Unknown ServiceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ServiceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Guaranteed reservation explanation. Required if and only if `service_type` is + * `guaranteed_reservation`. + */ + class GuaranteedReservation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): Explanation = explanation.getRequired("explanation") + + /** + * 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 + + @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 + * [GuaranteedReservation]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GuaranteedReservation]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(guaranteedReservation: GuaranteedReservation) = apply { + explanation = guaranteedReservation.explanation + additionalProperties = + guaranteedReservation.additionalProperties.toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: Explanation) = + explanation(JsonField.of(explanation)) + + /** + * Sets [Builder.explanation] to an arbitrary JSON value. + * + * You should usually call [Builder.explanation] with a well-typed [Explanation] + * 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 + } + + 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 [GuaranteedReservation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GuaranteedReservation = + GuaranteedReservation( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GuaranteedReservation = apply { + if (validated) { + return@apply + } + + explanation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (explanation.asKnown().getOrNull()?.validity() ?: 0) + + /** Explanation. */ + class Explanation + @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 { + + /** Cardholder canceled prior to service. */ + @JvmField + val CARDHOLDER_CANCELED_PRIOR_TO_SERVICE = + of("cardholder_canceled_prior_to_service") + + /** Cardholder cancellation attempt within 24 hours of confirmation. */ + @JvmField + val CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION = + of("cardholder_cancellation_attempt_within_24_hours_of_confirmation") + + /** Merchant billed for no-show. */ + @JvmField val MERCHANT_BILLED_NO_SHOW = of("merchant_billed_no_show") + + @JvmStatic fun of(value: String) = Explanation(JsonField.of(value)) + } + + /** An enum containing [Explanation]'s known values. */ + enum class Known { + /** Cardholder canceled prior to service. */ + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE, + /** Cardholder cancellation attempt within 24 hours of confirmation. */ + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION, + /** Merchant billed for no-show. */ + MERCHANT_BILLED_NO_SHOW, + } + + /** + * An enum containing [Explanation]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Explanation] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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 canceled prior to service. */ + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE, + /** Cardholder cancellation attempt within 24 hours of confirmation. */ + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION, + /** Merchant billed for no-show. */ + MERCHANT_BILLED_NO_SHOW, + /** + * An enum member indicating that [Explanation] 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_CANCELED_PRIOR_TO_SERVICE -> + Value.CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION -> + Value + .CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION + MERCHANT_BILLED_NO_SHOW -> Value.MERCHANT_BILLED_NO_SHOW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE -> + Known.CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION -> + Known + .CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION + MERCHANT_BILLED_NO_SHOW -> Known.MERCHANT_BILLED_NO_SHOW + else -> + throw IncreaseInvalidDataException("Unknown Explanation: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Explanation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Explanation && 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 GuaranteedReservation && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GuaranteedReservation{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCanceledServices && + cardholderCancellation == other.cardholderCancellation && + contractedAt == other.contractedAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseExplanation == other.purchaseExplanation && + serviceType == other.serviceType && + guaranteedReservation == other.guaranteedReservation && + this.other == other.other && + timeshare == other.timeshare && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + contractedAt, + merchantResolutionAttempted, + purchaseExplanation, + serviceType, + guaranteedReservation, + other, + timeshare, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledServices{cardholderCancellation=$cardholderCancellation, contractedAt=$contractedAt, merchantResolutionAttempted=$merchantResolutionAttempted, purchaseExplanation=$purchaseExplanation, serviceType=$serviceType, guaranteedReservation=$guaranteedReservation, other=$other, timeshare=$timeshare, additionalProperties=$additionalProperties}" + } + + /** + * Counterfeit merchandise. Required if and only if `category` is + * `consumer_counterfeit_merchandise`. + */ + class ConsumerCounterfeitMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val counterfeitExplanation: JsonField, + private val dispositionExplanation: JsonField, + private val orderExplanation: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("counterfeit_explanation") + @ExcludeMissing + counterfeitExplanation: JsonField = JsonMissing.of(), + @JsonProperty("disposition_explanation") + @ExcludeMissing + dispositionExplanation: JsonField = JsonMissing.of(), + @JsonProperty("order_explanation") + @ExcludeMissing + orderExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + counterfeitExplanation, + dispositionExplanation, + orderExplanation, + receivedAt, + mutableMapOf(), + ) + + /** + * Counterfeit explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun counterfeitExplanation(): String = + counterfeitExplanation.getRequired("counterfeit_explanation") + + /** + * Disposition explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun dispositionExplanation(): String = + dispositionExplanation.getRequired("disposition_explanation") + + /** + * Order explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun orderExplanation(): String = orderExplanation.getRequired("order_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [counterfeitExplanation]. + * + * Unlike [counterfeitExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("counterfeit_explanation") + @ExcludeMissing + fun _counterfeitExplanation(): JsonField = counterfeitExplanation + + /** + * Returns the raw JSON value of [dispositionExplanation]. + * + * Unlike [dispositionExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("disposition_explanation") + @ExcludeMissing + fun _dispositionExplanation(): JsonField = dispositionExplanation + + /** + * Returns the raw JSON value of [orderExplanation]. + * + * Unlike [orderExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("order_explanation") + @ExcludeMissing + fun _orderExplanation(): JsonField = orderExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerCounterfeitMerchandise]. + * + * The following fields are required: + * ```java + * .counterfeitExplanation() + * .dispositionExplanation() + * .orderExplanation() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCounterfeitMerchandise]. */ + class Builder internal constructor() { + + private var counterfeitExplanation: JsonField? = null + private var dispositionExplanation: JsonField? = null + private var orderExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCounterfeitMerchandise: ConsumerCounterfeitMerchandise) = + apply { + counterfeitExplanation = + consumerCounterfeitMerchandise.counterfeitExplanation + dispositionExplanation = + consumerCounterfeitMerchandise.dispositionExplanation + orderExplanation = consumerCounterfeitMerchandise.orderExplanation + receivedAt = consumerCounterfeitMerchandise.receivedAt + additionalProperties = + consumerCounterfeitMerchandise.additionalProperties.toMutableMap() + } + + /** Counterfeit explanation. */ + fun counterfeitExplanation(counterfeitExplanation: String) = + counterfeitExplanation(JsonField.of(counterfeitExplanation)) + + /** + * Sets [Builder.counterfeitExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.counterfeitExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun counterfeitExplanation(counterfeitExplanation: JsonField) = apply { + this.counterfeitExplanation = counterfeitExplanation + } + + /** Disposition explanation. */ + fun dispositionExplanation(dispositionExplanation: String) = + dispositionExplanation(JsonField.of(dispositionExplanation)) + + /** + * Sets [Builder.dispositionExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.dispositionExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dispositionExplanation(dispositionExplanation: JsonField) = apply { + this.dispositionExplanation = dispositionExplanation + } + + /** Order explanation. */ + fun orderExplanation(orderExplanation: String) = + orderExplanation(JsonField.of(orderExplanation)) + + /** + * Sets [Builder.orderExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.orderExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun orderExplanation(orderExplanation: JsonField) = apply { + this.orderExplanation = orderExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerCounterfeitMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .counterfeitExplanation() + * .dispositionExplanation() + * .orderExplanation() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCounterfeitMerchandise = + ConsumerCounterfeitMerchandise( + checkRequired("counterfeitExplanation", counterfeitExplanation), + checkRequired("dispositionExplanation", dispositionExplanation), + checkRequired("orderExplanation", orderExplanation), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCounterfeitMerchandise = apply { + if (validated) { + return@apply + } + + counterfeitExplanation() + dispositionExplanation() + orderExplanation() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (counterfeitExplanation.asKnown().isPresent) 1 else 0) + + (if (dispositionExplanation.asKnown().isPresent) 1 else 0) + + (if (orderExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCounterfeitMerchandise && + counterfeitExplanation == other.counterfeitExplanation && + dispositionExplanation == other.dispositionExplanation && + orderExplanation == other.orderExplanation && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + counterfeitExplanation, + dispositionExplanation, + orderExplanation, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCounterfeitMerchandise{counterfeitExplanation=$counterfeitExplanation, dispositionExplanation=$dispositionExplanation, orderExplanation=$orderExplanation, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Credit not processed. Required if and only if `category` is + * `consumer_credit_not_processed`. + */ + class ConsumerCreditNotProcessed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledOrReturnedAt: JsonField, + private val creditExpectedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_or_returned_at") + @ExcludeMissing + canceledOrReturnedAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_expected_at") + @ExcludeMissing + creditExpectedAt: JsonField = JsonMissing.of(), + ) : this(canceledOrReturnedAt, creditExpectedAt, mutableMapOf()) + + /** + * Canceled or returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun canceledOrReturnedAt(): Optional = + canceledOrReturnedAt.getOptional("canceled_or_returned_at") + + /** + * Credit expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun creditExpectedAt(): Optional = + creditExpectedAt.getOptional("credit_expected_at") + + /** + * Returns the raw JSON value of [canceledOrReturnedAt]. + * + * Unlike [canceledOrReturnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_or_returned_at") + @ExcludeMissing + fun _canceledOrReturnedAt(): JsonField = canceledOrReturnedAt + + /** + * Returns the raw JSON value of [creditExpectedAt]. + * + * Unlike [creditExpectedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credit_expected_at") + @ExcludeMissing + fun _creditExpectedAt(): JsonField = creditExpectedAt + + @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 + * [ConsumerCreditNotProcessed]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCreditNotProcessed]. */ + class Builder internal constructor() { + + private var canceledOrReturnedAt: JsonField = JsonMissing.of() + private var creditExpectedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCreditNotProcessed: ConsumerCreditNotProcessed) = apply { + canceledOrReturnedAt = consumerCreditNotProcessed.canceledOrReturnedAt + creditExpectedAt = consumerCreditNotProcessed.creditExpectedAt + additionalProperties = + consumerCreditNotProcessed.additionalProperties.toMutableMap() + } + + /** Canceled or returned at. */ + fun canceledOrReturnedAt(canceledOrReturnedAt: LocalDate) = + canceledOrReturnedAt(JsonField.of(canceledOrReturnedAt)) + + /** + * Sets [Builder.canceledOrReturnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledOrReturnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledOrReturnedAt(canceledOrReturnedAt: JsonField) = apply { + this.canceledOrReturnedAt = canceledOrReturnedAt + } + + /** Credit expected at. */ + fun creditExpectedAt(creditExpectedAt: LocalDate) = + creditExpectedAt(JsonField.of(creditExpectedAt)) + + /** + * Sets [Builder.creditExpectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.creditExpectedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun creditExpectedAt(creditExpectedAt: JsonField) = apply { + this.creditExpectedAt = creditExpectedAt + } + + 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 [ConsumerCreditNotProcessed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ConsumerCreditNotProcessed = + ConsumerCreditNotProcessed( + canceledOrReturnedAt, + creditExpectedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCreditNotProcessed = apply { + if (validated) { + return@apply + } + + canceledOrReturnedAt() + creditExpectedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledOrReturnedAt.asKnown().isPresent) 1 else 0) + + (if (creditExpectedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCreditNotProcessed && + canceledOrReturnedAt == other.canceledOrReturnedAt && + creditExpectedAt == other.creditExpectedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledOrReturnedAt, creditExpectedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCreditNotProcessed{canceledOrReturnedAt=$canceledOrReturnedAt, creditExpectedAt=$creditExpectedAt, additionalProperties=$additionalProperties}" + } + + /** + * Damaged or defective merchandise. Required if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + */ + class ConsumerDamagedOrDefectiveMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val orderAndIssueExplanation: JsonField, + private val receivedAt: JsonField, + private val returnOutcome: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("order_and_issue_explanation") + @ExcludeMissing + orderAndIssueExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + orderAndIssueExplanation, + receivedAt, + returnOutcome, + notReturned, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Order and issue explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun orderAndIssueExplanation(): String = + orderAndIssueExplanation.getRequired("order_and_issue_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [orderAndIssueExplanation]. + * + * Unlike [orderAndIssueExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("order_and_issue_explanation") + @ExcludeMissing + fun _orderAndIssueExplanation(): JsonField = orderAndIssueExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerDamagedOrDefectiveMerchandise]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .orderAndIssueExplanation() + * .receivedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerDamagedOrDefectiveMerchandise]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: JsonField? = + null + private var orderAndIssueExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var notReturned: JsonValue = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerDamagedOrDefectiveMerchandise: ConsumerDamagedOrDefectiveMerchandise + ) = apply { + merchantResolutionAttempted = + consumerDamagedOrDefectiveMerchandise.merchantResolutionAttempted + orderAndIssueExplanation = + consumerDamagedOrDefectiveMerchandise.orderAndIssueExplanation + receivedAt = consumerDamagedOrDefectiveMerchandise.receivedAt + returnOutcome = consumerDamagedOrDefectiveMerchandise.returnOutcome + notReturned = consumerDamagedOrDefectiveMerchandise.notReturned + returnAttempted = consumerDamagedOrDefectiveMerchandise.returnAttempted + returned = consumerDamagedOrDefectiveMerchandise.returned + additionalProperties = + consumerDamagedOrDefectiveMerchandise.additionalProperties.toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Order and issue explanation. */ + fun orderAndIssueExplanation(orderAndIssueExplanation: String) = + orderAndIssueExplanation(JsonField.of(orderAndIssueExplanation)) + + /** + * Sets [Builder.orderAndIssueExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.orderAndIssueExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orderAndIssueExplanation(orderAndIssueExplanation: JsonField) = apply { + this.orderAndIssueExplanation = orderAndIssueExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed [ReturnOutcome] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { this.notReturned = notReturned } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerDamagedOrDefectiveMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .orderAndIssueExplanation() + * .receivedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerDamagedOrDefectiveMerchandise = + ConsumerDamagedOrDefectiveMerchandise( + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("orderAndIssueExplanation", orderAndIssueExplanation), + checkRequired("receivedAt", receivedAt), + checkRequired("returnOutcome", returnOutcome), + notReturned, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerDamagedOrDefectiveMerchandise = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + orderAndIssueExplanation() + receivedAt() + returnOutcome().validate() + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (orderAndIssueExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return attempted. Required if and only if `return_outcome` is `return_attempted`. */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException("Unknown AttemptReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: JsonField) = + apply { + this.merchantReceivedReturnAt = merchantReceivedReturnAt + } + + /** Other explanation. Required if and only if the return method is `other`. */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException("Unknown ReturnMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerDamagedOrDefectiveMerchandise && + merchantResolutionAttempted == other.merchantResolutionAttempted && + orderAndIssueExplanation == other.orderAndIssueExplanation && + receivedAt == other.receivedAt && + returnOutcome == other.returnOutcome && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + orderAndIssueExplanation, + receivedAt, + returnOutcome, + notReturned, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerDamagedOrDefectiveMerchandise{merchantResolutionAttempted=$merchantResolutionAttempted, orderAndIssueExplanation=$orderAndIssueExplanation, receivedAt=$receivedAt, returnOutcome=$returnOutcome, notReturned=$notReturned, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise misrepresentation. Required if and only if `category` is + * `consumer_merchandise_misrepresentation`. + */ + class ConsumerMerchandiseMisrepresentation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val misrepresentationExplanation: JsonField, + private val purchaseExplanation: JsonField, + private val receivedAt: JsonField, + private val returnOutcome: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + misrepresentationExplanation: JsonField = JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + returnOutcome, + notReturned, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Misrepresentation explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun misrepresentationExplanation(): String = + misrepresentationExplanation.getRequired("misrepresentation_explanation") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [misrepresentationExplanation]. + * + * Unlike [misrepresentationExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + fun _misrepresentationExplanation(): JsonField = misrepresentationExplanation + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerMerchandiseMisrepresentation]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseMisrepresentation]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: JsonField? = + null + private var misrepresentationExplanation: JsonField? = null + private var purchaseExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var notReturned: JsonValue = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerMerchandiseMisrepresentation: ConsumerMerchandiseMisrepresentation + ) = apply { + merchantResolutionAttempted = + consumerMerchandiseMisrepresentation.merchantResolutionAttempted + misrepresentationExplanation = + consumerMerchandiseMisrepresentation.misrepresentationExplanation + purchaseExplanation = consumerMerchandiseMisrepresentation.purchaseExplanation + receivedAt = consumerMerchandiseMisrepresentation.receivedAt + returnOutcome = consumerMerchandiseMisrepresentation.returnOutcome + notReturned = consumerMerchandiseMisrepresentation.notReturned + returnAttempted = consumerMerchandiseMisrepresentation.returnAttempted + returned = consumerMerchandiseMisrepresentation.returned + additionalProperties = + consumerMerchandiseMisrepresentation.additionalProperties.toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Misrepresentation explanation. */ + fun misrepresentationExplanation(misrepresentationExplanation: String) = + misrepresentationExplanation(JsonField.of(misrepresentationExplanation)) + + /** + * Sets [Builder.misrepresentationExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.misrepresentationExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun misrepresentationExplanation(misrepresentationExplanation: JsonField) = + apply { + this.misrepresentationExplanation = misrepresentationExplanation + } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed [ReturnOutcome] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { this.notReturned = notReturned } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerMerchandiseMisrepresentation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseMisrepresentation = + ConsumerMerchandiseMisrepresentation( + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("misrepresentationExplanation", misrepresentationExplanation), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedAt", receivedAt), + checkRequired("returnOutcome", returnOutcome), + notReturned, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseMisrepresentation = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + misrepresentationExplanation() + purchaseExplanation() + receivedAt() + returnOutcome().validate() + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (misrepresentationExplanation.asKnown().isPresent) 1 else 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return attempted. Required if and only if `return_outcome` is `return_attempted`. */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException("Unknown AttemptReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: JsonField) = + apply { + this.merchantReceivedReturnAt = merchantReceivedReturnAt + } + + /** Other explanation. Required if and only if the return method is `other`. */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException("Unknown ReturnMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerMerchandiseMisrepresentation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + misrepresentationExplanation == other.misrepresentationExplanation && + purchaseExplanation == other.purchaseExplanation && + receivedAt == other.receivedAt && + returnOutcome == other.returnOutcome && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + returnOutcome, + notReturned, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseMisrepresentation{merchantResolutionAttempted=$merchantResolutionAttempted, misrepresentationExplanation=$misrepresentationExplanation, purchaseExplanation=$purchaseExplanation, receivedAt=$receivedAt, returnOutcome=$returnOutcome, notReturned=$notReturned, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise not as described. Required if and only if `category` is + * `consumer_merchandise_not_as_described`. + */ + class ConsumerMerchandiseNotAsDescribed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val receivedAt: JsonField, + private val returnOutcome: JsonField, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + receivedAt, + returnOutcome, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerMerchandiseNotAsDescribed]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .receivedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseNotAsDescribed]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: JsonField? = + null + private var receivedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerMerchandiseNotAsDescribed: ConsumerMerchandiseNotAsDescribed + ) = apply { + merchantResolutionAttempted = + consumerMerchandiseNotAsDescribed.merchantResolutionAttempted + receivedAt = consumerMerchandiseNotAsDescribed.receivedAt + returnOutcome = consumerMerchandiseNotAsDescribed.returnOutcome + returnAttempted = consumerMerchandiseNotAsDescribed.returnAttempted + returned = consumerMerchandiseNotAsDescribed.returned + additionalProperties = + consumerMerchandiseNotAsDescribed.additionalProperties.toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed [ReturnOutcome] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerMerchandiseNotAsDescribed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .receivedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseNotAsDescribed = + ConsumerMerchandiseNotAsDescribed( + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("receivedAt", receivedAt), + checkRequired("returnOutcome", returnOutcome), + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseNotAsDescribed = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + receivedAt() + returnOutcome().validate() + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return attempted. Required if and only if `return_outcome` is `return_attempted`. */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException("Unknown AttemptReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: JsonField) = + apply { + this.merchantReceivedReturnAt = merchantReceivedReturnAt + } + + /** Other explanation. Required if and only if the return method is `other`. */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException("Unknown ReturnMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerMerchandiseNotAsDescribed && + merchantResolutionAttempted == other.merchantResolutionAttempted && + receivedAt == other.receivedAt && + returnOutcome == other.returnOutcome && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + receivedAt, + returnOutcome, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseNotAsDescribed{merchantResolutionAttempted=$merchantResolutionAttempted, receivedAt=$receivedAt, returnOutcome=$returnOutcome, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise not received. Required if and only if `category` is + * `consumer_merchandise_not_received`. + */ + class ConsumerMerchandiseNotReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationOutcome: JsonField, + private val deliveryIssue: JsonField, + private val lastExpectedReceiptAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val purchaseInfoAndExplanation: JsonField, + private val cardholderCancellationPriorToExpectedReceipt: + JsonField, + private val delayed: JsonField, + private val deliveredToWrongLocation: JsonField, + private val merchantCancellation: JsonField, + private val noCancellation: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_outcome") + @ExcludeMissing + cancellationOutcome: JsonField = JsonMissing.of(), + @JsonProperty("delivery_issue") + @ExcludeMissing + deliveryIssue: JsonField = JsonMissing.of(), + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + lastExpectedReceiptAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + purchaseInfoAndExplanation: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of(), + @JsonProperty("delayed") + @ExcludeMissing + delayed: JsonField = JsonMissing.of(), + @JsonProperty("delivered_to_wrong_location") + @ExcludeMissing + deliveredToWrongLocation: JsonField = JsonMissing.of(), + @JsonProperty("merchant_cancellation") + @ExcludeMissing + merchantCancellation: JsonField = JsonMissing.of(), + @JsonProperty("no_cancellation") + @ExcludeMissing + noCancellation: JsonValue = JsonMissing.of(), + ) : this( + cancellationOutcome, + deliveryIssue, + lastExpectedReceiptAt, + merchantResolutionAttempted, + purchaseInfoAndExplanation, + cardholderCancellationPriorToExpectedReceipt, + delayed, + deliveredToWrongLocation, + merchantCancellation, + noCancellation, + mutableMapOf(), + ) + + /** + * Cancellation outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cancellationOutcome(): CancellationOutcome = + cancellationOutcome.getRequired("cancellation_outcome") + + /** + * Delivery issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun deliveryIssue(): DeliveryIssue = deliveryIssue.getRequired("delivery_issue") + + /** + * Last expected receipt at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lastExpectedReceiptAt(): LocalDate = + lastExpectedReceiptAt.getRequired("last_expected_receipt_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase information and explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun purchaseInfoAndExplanation(): String = + purchaseInfoAndExplanation.getRequired("purchase_info_and_explanation") + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun cardholderCancellationPriorToExpectedReceipt(): + Optional = + cardholderCancellationPriorToExpectedReceipt.getOptional( + "cardholder_cancellation_prior_to_expected_receipt" + ) + + /** + * Delayed. Required if and only if `delivery_issue` is `delayed`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun delayed(): Optional = delayed.getOptional("delayed") + + /** + * Delivered to wrong location. Required if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun deliveredToWrongLocation(): Optional = + deliveredToWrongLocation.getOptional("delivered_to_wrong_location") + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun merchantCancellation(): Optional = + merchantCancellation.getOptional("merchant_cancellation") + + /** + * No cancellation. Required if and only if `cancellation_outcome` is `no_cancellation`. + */ + @JsonProperty("no_cancellation") + @ExcludeMissing + fun _noCancellation(): JsonValue = noCancellation + + /** + * Returns the raw JSON value of [cancellationOutcome]. + * + * Unlike [cancellationOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cancellation_outcome") + @ExcludeMissing + fun _cancellationOutcome(): JsonField = cancellationOutcome + + /** + * Returns the raw JSON value of [deliveryIssue]. + * + * Unlike [deliveryIssue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("delivery_issue") + @ExcludeMissing + fun _deliveryIssue(): JsonField = deliveryIssue + + /** + * Returns the raw JSON value of [lastExpectedReceiptAt]. + * + * Unlike [lastExpectedReceiptAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + fun _lastExpectedReceiptAt(): JsonField = lastExpectedReceiptAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseInfoAndExplanation]. + * + * Unlike [purchaseInfoAndExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + fun _purchaseInfoAndExplanation(): JsonField = purchaseInfoAndExplanation + + /** + * Returns the raw JSON value of [cardholderCancellationPriorToExpectedReceipt]. + * + * Unlike [cardholderCancellationPriorToExpectedReceipt], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + fun _cardholderCancellationPriorToExpectedReceipt(): + JsonField = + cardholderCancellationPriorToExpectedReceipt + + /** + * Returns the raw JSON value of [delayed]. + * + * Unlike [delayed], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delayed") @ExcludeMissing fun _delayed(): JsonField = delayed + + /** + * Returns the raw JSON value of [deliveredToWrongLocation]. + * + * Unlike [deliveredToWrongLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("delivered_to_wrong_location") + @ExcludeMissing + fun _deliveredToWrongLocation(): JsonField = + deliveredToWrongLocation + + /** + * Returns the raw JSON value of [merchantCancellation]. + * + * Unlike [merchantCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_cancellation") + @ExcludeMissing + fun _merchantCancellation(): JsonField = merchantCancellation + + @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 + * [ConsumerMerchandiseNotReceived]. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .deliveryIssue() + * .lastExpectedReceiptAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndExplanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseNotReceived]. */ + class Builder internal constructor() { + + private var cancellationOutcome: JsonField? = null + private var deliveryIssue: JsonField? = null + private var lastExpectedReceiptAt: JsonField? = null + private var merchantResolutionAttempted: JsonField? = + null + private var purchaseInfoAndExplanation: JsonField? = null + private var cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of() + private var delayed: JsonField = JsonMissing.of() + private var deliveredToWrongLocation: JsonField = + JsonMissing.of() + private var merchantCancellation: JsonField = JsonMissing.of() + private var noCancellation: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerMerchandiseNotReceived: ConsumerMerchandiseNotReceived) = + apply { + cancellationOutcome = consumerMerchandiseNotReceived.cancellationOutcome + deliveryIssue = consumerMerchandiseNotReceived.deliveryIssue + lastExpectedReceiptAt = consumerMerchandiseNotReceived.lastExpectedReceiptAt + merchantResolutionAttempted = + consumerMerchandiseNotReceived.merchantResolutionAttempted + purchaseInfoAndExplanation = + consumerMerchandiseNotReceived.purchaseInfoAndExplanation + cardholderCancellationPriorToExpectedReceipt = + consumerMerchandiseNotReceived + .cardholderCancellationPriorToExpectedReceipt + delayed = consumerMerchandiseNotReceived.delayed + deliveredToWrongLocation = + consumerMerchandiseNotReceived.deliveredToWrongLocation + merchantCancellation = consumerMerchandiseNotReceived.merchantCancellation + noCancellation = consumerMerchandiseNotReceived.noCancellation + additionalProperties = + consumerMerchandiseNotReceived.additionalProperties.toMutableMap() + } + + /** Cancellation outcome. */ + fun cancellationOutcome(cancellationOutcome: CancellationOutcome) = + cancellationOutcome(JsonField.of(cancellationOutcome)) + + /** + * Sets [Builder.cancellationOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationOutcome] with a well-typed + * [CancellationOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cancellationOutcome(cancellationOutcome: JsonField) = + apply { + this.cancellationOutcome = cancellationOutcome + } + + /** Delivery issue. */ + fun deliveryIssue(deliveryIssue: DeliveryIssue) = + deliveryIssue(JsonField.of(deliveryIssue)) + + /** + * Sets [Builder.deliveryIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveryIssue] with a well-typed [DeliveryIssue] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun deliveryIssue(deliveryIssue: JsonField) = apply { + this.deliveryIssue = deliveryIssue + } + + /** Last expected receipt at. */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: LocalDate) = + lastExpectedReceiptAt(JsonField.of(lastExpectedReceiptAt)) + + /** + * Sets [Builder.lastExpectedReceiptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastExpectedReceiptAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: JsonField) = apply { + this.lastExpectedReceiptAt = lastExpectedReceiptAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase information and explanation. */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: String) = + purchaseInfoAndExplanation(JsonField.of(purchaseInfoAndExplanation)) + + /** + * Sets [Builder.purchaseInfoAndExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: JsonField) = + apply { + this.purchaseInfoAndExplanation = purchaseInfoAndExplanation + } + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = + cardholderCancellationPriorToExpectedReceipt( + JsonField.of(cardholderCancellationPriorToExpectedReceipt) + ) + + /** + * Sets [Builder.cardholderCancellationPriorToExpectedReceipt] to an arbitrary JSON + * value. + * + * You should usually call [Builder.cardholderCancellationPriorToExpectedReceipt] + * with a well-typed [CardholderCancellationPriorToExpectedReceipt] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + JsonField + ) = apply { + this.cardholderCancellationPriorToExpectedReceipt = + cardholderCancellationPriorToExpectedReceipt + } + + /** Delayed. Required if and only if `delivery_issue` is `delayed`. */ + fun delayed(delayed: Delayed) = delayed(JsonField.of(delayed)) + + /** + * Sets [Builder.delayed] to an arbitrary JSON value. + * + * You should usually call [Builder.delayed] with a well-typed [Delayed] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun delayed(delayed: JsonField) = apply { this.delayed = delayed } + + /** + * Delivered to wrong location. Required if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + */ + fun deliveredToWrongLocation(deliveredToWrongLocation: DeliveredToWrongLocation) = + deliveredToWrongLocation(JsonField.of(deliveredToWrongLocation)) + + /** + * Sets [Builder.deliveredToWrongLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveredToWrongLocation] with a well-typed + * [DeliveredToWrongLocation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun deliveredToWrongLocation( + deliveredToWrongLocation: JsonField + ) = apply { this.deliveredToWrongLocation = deliveredToWrongLocation } + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + fun merchantCancellation(merchantCancellation: MerchantCancellation) = + merchantCancellation(JsonField.of(merchantCancellation)) + + /** + * Sets [Builder.merchantCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCancellation] with a well-typed + * [MerchantCancellation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun merchantCancellation(merchantCancellation: JsonField) = + apply { + this.merchantCancellation = merchantCancellation + } + + /** + * No cancellation. Required if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + fun noCancellation(noCancellation: JsonValue) = apply { + this.noCancellation = noCancellation + } + + 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 [ConsumerMerchandiseNotReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .deliveryIssue() + * .lastExpectedReceiptAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndExplanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseNotReceived = + ConsumerMerchandiseNotReceived( + checkRequired("cancellationOutcome", cancellationOutcome), + checkRequired("deliveryIssue", deliveryIssue), + checkRequired("lastExpectedReceiptAt", lastExpectedReceiptAt), + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("purchaseInfoAndExplanation", purchaseInfoAndExplanation), + cardholderCancellationPriorToExpectedReceipt, + delayed, + deliveredToWrongLocation, + merchantCancellation, + noCancellation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseNotReceived = apply { + if (validated) { + return@apply + } + + cancellationOutcome().validate() + deliveryIssue().validate() + lastExpectedReceiptAt() + merchantResolutionAttempted().validate() + purchaseInfoAndExplanation() + cardholderCancellationPriorToExpectedReceipt().ifPresent { it.validate() } + delayed().ifPresent { it.validate() } + deliveredToWrongLocation().ifPresent { it.validate() } + merchantCancellation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (deliveryIssue.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastExpectedReceiptAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndExplanation.asKnown().isPresent) 1 else 0) + + (cardholderCancellationPriorToExpectedReceipt.asKnown().getOrNull()?.validity() + ?: 0) + + (delayed.asKnown().getOrNull()?.validity() ?: 0) + + (deliveredToWrongLocation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCancellation.asKnown().getOrNull()?.validity() ?: 0) + + /** Cancellation outcome. */ + class CancellationOutcome + @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 { + + /** Cardholder cancellation prior to expected receipt. */ + @JvmField + val CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT = + of("cardholder_cancellation_prior_to_expected_receipt") + + /** Merchant cancellation. */ + @JvmField val MERCHANT_CANCELLATION = of("merchant_cancellation") + + /** No cancellation. */ + @JvmField val NO_CANCELLATION = of("no_cancellation") + + @JvmStatic fun of(value: String) = CancellationOutcome(JsonField.of(value)) + } + + /** An enum containing [CancellationOutcome]'s known values. */ + enum class Known { + /** Cardholder cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + } + + /** + * An enum containing [CancellationOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [CancellationOutcome] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may 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 cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + /** + * An enum member indicating that [CancellationOutcome] 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_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Value.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Value.MERCHANT_CANCELLATION + NO_CANCELLATION -> Value.NO_CANCELLATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Known.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Known.MERCHANT_CANCELLATION + NO_CANCELLATION -> Known.NO_CANCELLATION + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Delivery issue. */ + class DeliveryIssue + @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 { + + /** Delayed. */ + @JvmField val DELAYED = of("delayed") + + /** Delivered to wrong location. */ + @JvmField val DELIVERED_TO_WRONG_LOCATION = of("delivered_to_wrong_location") + + @JvmStatic fun of(value: String) = DeliveryIssue(JsonField.of(value)) + } + + /** An enum containing [DeliveryIssue]'s known values. */ + enum class Known { + /** Delayed. */ + DELAYED, + /** Delivered to wrong location. */ + DELIVERED_TO_WRONG_LOCATION, + } + + /** + * An enum containing [DeliveryIssue]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DeliveryIssue] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Delayed. */ + DELAYED, + /** Delivered to wrong location. */ + DELIVERED_TO_WRONG_LOCATION, + /** + * An enum member indicating that [DeliveryIssue] 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) { + DELAYED -> Value.DELAYED + DELIVERED_TO_WRONG_LOCATION -> Value.DELIVERED_TO_WRONG_LOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + DELAYED -> Known.DELAYED + DELIVERED_TO_WRONG_LOCATION -> Known.DELIVERED_TO_WRONG_LOCATION + else -> throw IncreaseInvalidDataException("Unknown DeliveryIssue: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DeliveryIssue = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeliveryIssue && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + */ + class CardholderCancellationPriorToExpectedReceipt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellationPriorToExpectedReceipt]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = apply { + canceledAt = cardholderCancellationPriorToExpectedReceipt.canceledAt + reason = cardholderCancellationPriorToExpectedReceipt.reason + additionalProperties = + cardholderCancellationPriorToExpectedReceipt.additionalProperties + .toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellationPriorToExpectedReceipt = + CardholderCancellationPriorToExpectedReceipt( + checkRequired("canceledAt", canceledAt), + reason, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellationPriorToExpectedReceipt = apply { + if (validated) { + return@apply + } + + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderCancellationPriorToExpectedReceipt && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellationPriorToExpectedReceipt{canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Delayed. Required if and only if `delivery_issue` is `delayed`. */ + class Delayed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val returnOutcome: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + explanation, + returnOutcome, + notReturned, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * 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 [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 [Delayed]. + * + * The following fields are required: + * ```java + * .explanation() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Delayed]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var returnOutcome: JsonField? = null + private var notReturned: JsonValue = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(delayed: Delayed) = apply { + explanation = delayed.explanation + returnOutcome = delayed.returnOutcome + notReturned = delayed.notReturned + returnAttempted = delayed.returnAttempted + returned = delayed.returned + additionalProperties = delayed.additionalProperties.toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [Delayed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Delayed = + Delayed( + checkRequired("explanation", explanation), + checkRequired("returnOutcome", returnOutcome), + notReturned, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Delayed = apply { + if (validated) { + return@apply + } + + explanation() + returnOutcome().validate() + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of() + ) : this(attemptedAt, mutableMapOf()) + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptedAt = returnAttempted.attemptedAt + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptedAt", attemptedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (attemptedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnAttempted && + attemptedAt == other.attemptedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attemptedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptedAt=$attemptedAt, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantReceivedReturnAt: JsonField, + private val returnedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + ) : this(merchantReceivedReturnAt, returnedAt, mutableMapOf()) + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantReceivedReturnAt(): LocalDate = + merchantReceivedReturnAt.getRequired("merchant_received_return_at") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + @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 [Returned]. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var merchantReceivedReturnAt: JsonField? = null + private var returnedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + returnedAt = returned.returnedAt + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("merchantReceivedReturnAt", merchantReceivedReturnAt), + checkRequired("returnedAt", returnedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + merchantReceivedReturnAt() + returnedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Returned && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + returnedAt == other.returnedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(merchantReceivedReturnAt, returnedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{merchantReceivedReturnAt=$merchantReceivedReturnAt, returnedAt=$returnedAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Delayed && + explanation == other.explanation && + returnOutcome == other.returnOutcome && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + returnOutcome, + notReturned, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Delayed{explanation=$explanation, returnOutcome=$returnOutcome, notReturned=$notReturned, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Delivered to wrong location. Required if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + */ + class DeliveredToWrongLocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agreedLocation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agreed_location") + @ExcludeMissing + agreedLocation: JsonField = JsonMissing.of() + ) : this(agreedLocation, mutableMapOf()) + + /** + * Agreed location. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun agreedLocation(): String = agreedLocation.getRequired("agreed_location") + + /** + * Returns the raw JSON value of [agreedLocation]. + * + * Unlike [agreedLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("agreed_location") + @ExcludeMissing + fun _agreedLocation(): JsonField = agreedLocation + + @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 + * [DeliveredToWrongLocation]. + * + * The following fields are required: + * ```java + * .agreedLocation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeliveredToWrongLocation]. */ + class Builder internal constructor() { + + private var agreedLocation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(deliveredToWrongLocation: DeliveredToWrongLocation) = apply { + agreedLocation = deliveredToWrongLocation.agreedLocation + additionalProperties = + deliveredToWrongLocation.additionalProperties.toMutableMap() + } + + /** Agreed location. */ + fun agreedLocation(agreedLocation: String) = + agreedLocation(JsonField.of(agreedLocation)) + + /** + * Sets [Builder.agreedLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.agreedLocation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun agreedLocation(agreedLocation: JsonField) = apply { + this.agreedLocation = agreedLocation + } + + 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 [DeliveredToWrongLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agreedLocation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeliveredToWrongLocation = + DeliveredToWrongLocation( + checkRequired("agreedLocation", agreedLocation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DeliveredToWrongLocation = apply { + if (validated) { + return@apply + } + + agreedLocation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (agreedLocation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeliveredToWrongLocation && + agreedLocation == other.agreedLocation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(agreedLocation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DeliveredToWrongLocation{agreedLocation=$agreedLocation, additionalProperties=$additionalProperties}" + } + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + class MerchantCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of() + ) : this(canceledAt, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + @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 + * [MerchantCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCancellation: MerchantCancellation) = apply { + canceledAt = merchantCancellation.canceledAt + additionalProperties = + merchantCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + 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 [MerchantCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCancellation = + MerchantCancellation( + checkRequired("canceledAt", canceledAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (canceledAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCancellation && + canceledAt == other.canceledAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(canceledAt, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCancellation{canceledAt=$canceledAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerMerchandiseNotReceived && + cancellationOutcome == other.cancellationOutcome && + deliveryIssue == other.deliveryIssue && + lastExpectedReceiptAt == other.lastExpectedReceiptAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseInfoAndExplanation == other.purchaseInfoAndExplanation && + cardholderCancellationPriorToExpectedReceipt == + other.cardholderCancellationPriorToExpectedReceipt && + delayed == other.delayed && + deliveredToWrongLocation == other.deliveredToWrongLocation && + merchantCancellation == other.merchantCancellation && + noCancellation == other.noCancellation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationOutcome, + deliveryIssue, + lastExpectedReceiptAt, + merchantResolutionAttempted, + purchaseInfoAndExplanation, + cardholderCancellationPriorToExpectedReceipt, + delayed, + deliveredToWrongLocation, + merchantCancellation, + noCancellation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseNotReceived{cancellationOutcome=$cancellationOutcome, deliveryIssue=$deliveryIssue, lastExpectedReceiptAt=$lastExpectedReceiptAt, merchantResolutionAttempted=$merchantResolutionAttempted, purchaseInfoAndExplanation=$purchaseInfoAndExplanation, cardholderCancellationPriorToExpectedReceipt=$cardholderCancellationPriorToExpectedReceipt, delayed=$delayed, deliveredToWrongLocation=$deliveredToWrongLocation, merchantCancellation=$merchantCancellation, noCancellation=$noCancellation, additionalProperties=$additionalProperties}" + } + + /** + * Original Credit Transaction (OCT) not accepted. Required if and only if `category` is + * `consumer_original_credit_transaction_not_accepted`. + */ + class ConsumerOriginalCreditTransactionNotAccepted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + ) : this(explanation, reason, mutableMapOf()) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun reason(): Reason = reason.getRequired("reason") + + /** + * 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 [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @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 + * [ConsumerOriginalCreditTransactionNotAccepted]. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerOriginalCreditTransactionNotAccepted]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerOriginalCreditTransactionNotAccepted: + ConsumerOriginalCreditTransactionNotAccepted + ) = apply { + explanation = consumerOriginalCreditTransactionNotAccepted.explanation + reason = consumerOriginalCreditTransactionNotAccepted.reason + additionalProperties = + consumerOriginalCreditTransactionNotAccepted.additionalProperties + .toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Reason. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [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 } + + 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 [ConsumerOriginalCreditTransactionNotAccepted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerOriginalCreditTransactionNotAccepted = + ConsumerOriginalCreditTransactionNotAccepted( + checkRequired("explanation", explanation), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerOriginalCreditTransactionNotAccepted = apply { + if (validated) { + return@apply + } + + explanation() + reason().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** Reason. */ + class Reason @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 { + + /** Prohibited by local laws or regulation. */ + @JvmField + val PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION = + of("prohibited_by_local_laws_or_regulation") + + /** Recipient refused. */ + @JvmField val RECIPIENT_REFUSED = of("recipient_refused") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** Prohibited by local laws or regulation. */ + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION, + /** Recipient refused. */ + RECIPIENT_REFUSED, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Prohibited by local laws or regulation. */ + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION, + /** Recipient refused. */ + RECIPIENT_REFUSED, + /** + * An enum member indicating that [Reason] 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) { + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION -> + Value.PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + RECIPIENT_REFUSED -> Value.RECIPIENT_REFUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION -> + Known.PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + RECIPIENT_REFUSED -> Known.RECIPIENT_REFUSED + else -> throw IncreaseInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && 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 ConsumerOriginalCreditTransactionNotAccepted && + explanation == other.explanation && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerOriginalCreditTransactionNotAccepted{explanation=$explanation, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise quality issue. Required if and only if `category` is + * `consumer_quality_merchandise`. + */ + class ConsumerQualityMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expectedAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val purchaseInfoAndQualityIssue: JsonField, + private val receivedAt: JsonField, + private val returnOutcome: JsonField, + private val notReturned: JsonValue, + private val ongoingNegotiations: JsonField, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expected_at") + @ExcludeMissing + expectedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + purchaseInfoAndQualityIssue: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + ongoingNegotiations: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + expectedAt, + merchantResolutionAttempted, + purchaseInfoAndQualityIssue, + receivedAt, + returnOutcome, + notReturned, + ongoingNegotiations, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun expectedAt(): LocalDate = expectedAt.getRequired("expected_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase information and quality issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun purchaseInfoAndQualityIssue(): String = + purchaseInfoAndQualityIssue.getRequired("purchase_info_and_quality_issue") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun ongoingNegotiations(): Optional = + ongoingNegotiations.getOptional("ongoing_negotiations") + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [expectedAt]. + * + * Unlike [expectedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expected_at") + @ExcludeMissing + fun _expectedAt(): JsonField = expectedAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseInfoAndQualityIssue]. + * + * Unlike [purchaseInfoAndQualityIssue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + fun _purchaseInfoAndQualityIssue(): JsonField = purchaseInfoAndQualityIssue + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [ongoingNegotiations]. + * + * Unlike [ongoingNegotiations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + fun _ongoingNegotiations(): JsonField = ongoingNegotiations + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerQualityMerchandise]. + * + * The following fields are required: + * ```java + * .expectedAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndQualityIssue() + * .receivedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerQualityMerchandise]. */ + class Builder internal constructor() { + + private var expectedAt: JsonField? = null + private var merchantResolutionAttempted: JsonField? = + null + private var purchaseInfoAndQualityIssue: JsonField? = null + private var receivedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var notReturned: JsonValue = JsonMissing.of() + private var ongoingNegotiations: JsonField = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerQualityMerchandise: ConsumerQualityMerchandise) = apply { + expectedAt = consumerQualityMerchandise.expectedAt + merchantResolutionAttempted = + consumerQualityMerchandise.merchantResolutionAttempted + purchaseInfoAndQualityIssue = + consumerQualityMerchandise.purchaseInfoAndQualityIssue + receivedAt = consumerQualityMerchandise.receivedAt + returnOutcome = consumerQualityMerchandise.returnOutcome + notReturned = consumerQualityMerchandise.notReturned + ongoingNegotiations = consumerQualityMerchandise.ongoingNegotiations + returnAttempted = consumerQualityMerchandise.returnAttempted + returned = consumerQualityMerchandise.returned + additionalProperties = + consumerQualityMerchandise.additionalProperties.toMutableMap() + } + + /** Expected at. */ + fun expectedAt(expectedAt: LocalDate) = expectedAt(JsonField.of(expectedAt)) + + /** + * Sets [Builder.expectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedAt] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun expectedAt(expectedAt: JsonField) = apply { + this.expectedAt = expectedAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase information and quality issue. */ + fun purchaseInfoAndQualityIssue(purchaseInfoAndQualityIssue: String) = + purchaseInfoAndQualityIssue(JsonField.of(purchaseInfoAndQualityIssue)) + + /** + * Sets [Builder.purchaseInfoAndQualityIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndQualityIssue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun purchaseInfoAndQualityIssue(purchaseInfoAndQualityIssue: JsonField) = + apply { + this.purchaseInfoAndQualityIssue = purchaseInfoAndQualityIssue + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed [ReturnOutcome] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { this.notReturned = notReturned } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. + */ + fun ongoingNegotiations(ongoingNegotiations: OngoingNegotiations) = + ongoingNegotiations(JsonField.of(ongoingNegotiations)) + + /** + * Sets [Builder.ongoingNegotiations] to an arbitrary JSON value. + * + * You should usually call [Builder.ongoingNegotiations] with a well-typed + * [OngoingNegotiations] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun ongoingNegotiations(ongoingNegotiations: JsonField) = + apply { + this.ongoingNegotiations = ongoingNegotiations + } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerQualityMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expectedAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndQualityIssue() + * .receivedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerQualityMerchandise = + ConsumerQualityMerchandise( + checkRequired("expectedAt", expectedAt), + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("purchaseInfoAndQualityIssue", purchaseInfoAndQualityIssue), + checkRequired("receivedAt", receivedAt), + checkRequired("returnOutcome", returnOutcome), + notReturned, + ongoingNegotiations, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerQualityMerchandise = apply { + if (validated) { + return@apply + } + + expectedAt() + merchantResolutionAttempted().validate() + purchaseInfoAndQualityIssue() + receivedAt() + returnOutcome().validate() + ongoingNegotiations().ifPresent { it.validate() } + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expectedAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndQualityIssue.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (ongoingNegotiations.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. */ + class OngoingNegotiations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val issuerFirstNotifiedAt: JsonField, + private val startedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + issuerFirstNotifiedAt: JsonField = JsonMissing.of(), + @JsonProperty("started_at") + @ExcludeMissing + startedAt: JsonField = JsonMissing.of(), + ) : this(explanation, issuerFirstNotifiedAt, startedAt, mutableMapOf()) + + /** + * Explanation of the previous ongoing negotiations between the cardholder and + * merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Date the cardholder first notified the issuer of the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun issuerFirstNotifiedAt(): LocalDate = + issuerFirstNotifiedAt.getRequired("issuer_first_notified_at") + + /** + * Started at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startedAt(): LocalDate = startedAt.getRequired("started_at") + + /** + * 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 [issuerFirstNotifiedAt]. + * + * Unlike [issuerFirstNotifiedAt], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + fun _issuerFirstNotifiedAt(): JsonField = issuerFirstNotifiedAt + + /** + * Returns the raw JSON value of [startedAt]. + * + * Unlike [startedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("started_at") + @ExcludeMissing + fun _startedAt(): JsonField = startedAt + + @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 + * [OngoingNegotiations]. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OngoingNegotiations]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var issuerFirstNotifiedAt: JsonField? = null + private var startedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(ongoingNegotiations: OngoingNegotiations) = apply { + explanation = ongoingNegotiations.explanation + issuerFirstNotifiedAt = ongoingNegotiations.issuerFirstNotifiedAt + startedAt = ongoingNegotiations.startedAt + additionalProperties = + ongoingNegotiations.additionalProperties.toMutableMap() + } + + /** + * Explanation of the previous ongoing negotiations between the cardholder and + * merchant. + */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Date the cardholder first notified the issuer of the dispute. */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: LocalDate) = + issuerFirstNotifiedAt(JsonField.of(issuerFirstNotifiedAt)) + + /** + * Sets [Builder.issuerFirstNotifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerFirstNotifiedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: JsonField) = apply { + this.issuerFirstNotifiedAt = issuerFirstNotifiedAt + } + + /** Started at. */ + fun startedAt(startedAt: LocalDate) = startedAt(JsonField.of(startedAt)) + + /** + * Sets [Builder.startedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun startedAt(startedAt: JsonField) = apply { + this.startedAt = startedAt + } + + 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 [OngoingNegotiations]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OngoingNegotiations = + OngoingNegotiations( + checkRequired("explanation", explanation), + checkRequired("issuerFirstNotifiedAt", issuerFirstNotifiedAt), + checkRequired("startedAt", startedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OngoingNegotiations = apply { + if (validated) { + return@apply + } + + explanation() + issuerFirstNotifiedAt() + startedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (issuerFirstNotifiedAt.asKnown().isPresent) 1 else 0) + + (if (startedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OngoingNegotiations && + explanation == other.explanation && + issuerFirstNotifiedAt == other.issuerFirstNotifiedAt && + startedAt == other.startedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + issuerFirstNotifiedAt, + startedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OngoingNegotiations{explanation=$explanation, issuerFirstNotifiedAt=$issuerFirstNotifiedAt, startedAt=$startedAt, additionalProperties=$additionalProperties}" + } + + /** Return attempted. Required if and only if `return_outcome` is `return_attempted`. */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException("Unknown AttemptReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: JsonField) = + apply { + this.merchantReceivedReturnAt = merchantReceivedReturnAt + } + + /** Other explanation. Required if and only if the return method is `other`. */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException("Unknown ReturnMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerQualityMerchandise && + expectedAt == other.expectedAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseInfoAndQualityIssue == other.purchaseInfoAndQualityIssue && + receivedAt == other.receivedAt && + returnOutcome == other.returnOutcome && + notReturned == other.notReturned && + ongoingNegotiations == other.ongoingNegotiations && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + expectedAt, + merchantResolutionAttempted, + purchaseInfoAndQualityIssue, + receivedAt, + returnOutcome, + notReturned, + ongoingNegotiations, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerQualityMerchandise{expectedAt=$expectedAt, merchantResolutionAttempted=$merchantResolutionAttempted, purchaseInfoAndQualityIssue=$purchaseInfoAndQualityIssue, receivedAt=$receivedAt, returnOutcome=$returnOutcome, notReturned=$notReturned, ongoingNegotiations=$ongoingNegotiations, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Services quality issue. Required if and only if `category` is + * `consumer_quality_services`. + */ + class ConsumerQualityServices + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField, + private val purchaseInfoAndQualityIssue: JsonField, + private val servicesReceivedAt: JsonField, + private val cardholderPaidToHaveWorkRedone: JsonField, + private val ongoingNegotiations: JsonField, + private val restaurantFoodRelated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + @ExcludeMissing + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField = + JsonMissing.of(), + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + purchaseInfoAndQualityIssue: JsonField = JsonMissing.of(), + @JsonProperty("services_received_at") + @ExcludeMissing + servicesReceivedAt: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_paid_to_have_work_redone") + @ExcludeMissing + cardholderPaidToHaveWorkRedone: JsonField = + JsonMissing.of(), + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + ongoingNegotiations: JsonField = JsonMissing.of(), + @JsonProperty("restaurant_food_related") + @ExcludeMissing + restaurantFoodRelated: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + purchaseInfoAndQualityIssue, + servicesReceivedAt, + cardholderPaidToHaveWorkRedone, + ongoingNegotiations, + restaurantFoodRelated, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Non-fiat currency or non-fungible token related and not matching description. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription(): + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription.getRequired( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + + /** + * Purchase information and quality issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun purchaseInfoAndQualityIssue(): String = + purchaseInfoAndQualityIssue.getRequired("purchase_info_and_quality_issue") + + /** + * Services received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun servicesReceivedAt(): LocalDate = + servicesReceivedAt.getRequired("services_received_at") + + /** + * Cardholder paid to have work redone. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun cardholderPaidToHaveWorkRedone(): Optional = + cardholderPaidToHaveWorkRedone.getOptional("cardholder_paid_to_have_work_redone") + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun ongoingNegotiations(): Optional = + ongoingNegotiations.getOptional("ongoing_negotiations") + + /** + * Whether the dispute is related to the quality of food from an eating place or + * restaurant. Must be provided when Merchant Category Code (MCC) is 5812, 5813 or 5814. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun restaurantFoodRelated(): Optional = + restaurantFoodRelated.getOptional("restaurant_food_related") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of + * [nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]. + * + * Unlike [nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription], this + * method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + @ExcludeMissing + fun _nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription(): + JsonField = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + + /** + * Returns the raw JSON value of [purchaseInfoAndQualityIssue]. + * + * Unlike [purchaseInfoAndQualityIssue], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + fun _purchaseInfoAndQualityIssue(): JsonField = purchaseInfoAndQualityIssue + + /** + * Returns the raw JSON value of [servicesReceivedAt]. + * + * Unlike [servicesReceivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("services_received_at") + @ExcludeMissing + fun _servicesReceivedAt(): JsonField = servicesReceivedAt + + /** + * Returns the raw JSON value of [cardholderPaidToHaveWorkRedone]. + * + * Unlike [cardholderPaidToHaveWorkRedone], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("cardholder_paid_to_have_work_redone") + @ExcludeMissing + fun _cardholderPaidToHaveWorkRedone(): JsonField = + cardholderPaidToHaveWorkRedone + + /** + * Returns the raw JSON value of [ongoingNegotiations]. + * + * Unlike [ongoingNegotiations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + fun _ongoingNegotiations(): JsonField = ongoingNegotiations + + /** + * Returns the raw JSON value of [restaurantFoodRelated]. + * + * Unlike [restaurantFoodRelated], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("restaurant_food_related") + @ExcludeMissing + fun _restaurantFoodRelated(): JsonField = restaurantFoodRelated + + @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 + * [ConsumerQualityServices]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription() + * .purchaseInfoAndQualityIssue() + * .servicesReceivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerQualityServices]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = null + private var nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField? = + null + private var purchaseInfoAndQualityIssue: JsonField? = null + private var servicesReceivedAt: JsonField? = null + private var cardholderPaidToHaveWorkRedone: + JsonField = + JsonMissing.of() + private var ongoingNegotiations: JsonField = JsonMissing.of() + private var restaurantFoodRelated: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerQualityServices: ConsumerQualityServices) = apply { + cardholderCancellation = consumerQualityServices.cardholderCancellation + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + consumerQualityServices + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + purchaseInfoAndQualityIssue = + consumerQualityServices.purchaseInfoAndQualityIssue + servicesReceivedAt = consumerQualityServices.servicesReceivedAt + cardholderPaidToHaveWorkRedone = + consumerQualityServices.cardholderPaidToHaveWorkRedone + ongoingNegotiations = consumerQualityServices.ongoingNegotiations + restaurantFoodRelated = consumerQualityServices.restaurantFoodRelated + additionalProperties = + consumerQualityServices.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Non-fiat currency or non-fungible token related and not matching description. */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + ) = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + JsonField.of( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + ) + ) + + /** + * Sets [Builder.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] + * to an arbitrary JSON value. + * + * You should usually call + * [Builder.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] with + * a well-typed [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField + ) = apply { + this.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + } + + /** Purchase information and quality issue. */ + fun purchaseInfoAndQualityIssue(purchaseInfoAndQualityIssue: String) = + purchaseInfoAndQualityIssue(JsonField.of(purchaseInfoAndQualityIssue)) + + /** + * Sets [Builder.purchaseInfoAndQualityIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndQualityIssue] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun purchaseInfoAndQualityIssue(purchaseInfoAndQualityIssue: JsonField) = + apply { + this.purchaseInfoAndQualityIssue = purchaseInfoAndQualityIssue + } + + /** Services received at. */ + fun servicesReceivedAt(servicesReceivedAt: LocalDate) = + servicesReceivedAt(JsonField.of(servicesReceivedAt)) + + /** + * Sets [Builder.servicesReceivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.servicesReceivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun servicesReceivedAt(servicesReceivedAt: JsonField) = apply { + this.servicesReceivedAt = servicesReceivedAt + } + + /** Cardholder paid to have work redone. */ + fun cardholderPaidToHaveWorkRedone( + cardholderPaidToHaveWorkRedone: CardholderPaidToHaveWorkRedone + ) = cardholderPaidToHaveWorkRedone(JsonField.of(cardholderPaidToHaveWorkRedone)) + + /** + * Sets [Builder.cardholderPaidToHaveWorkRedone] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderPaidToHaveWorkRedone] with a + * well-typed [CardholderPaidToHaveWorkRedone] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun cardholderPaidToHaveWorkRedone( + cardholderPaidToHaveWorkRedone: JsonField + ) = apply { this.cardholderPaidToHaveWorkRedone = cardholderPaidToHaveWorkRedone } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. + */ + fun ongoingNegotiations(ongoingNegotiations: OngoingNegotiations) = + ongoingNegotiations(JsonField.of(ongoingNegotiations)) + + /** + * Sets [Builder.ongoingNegotiations] to an arbitrary JSON value. + * + * You should usually call [Builder.ongoingNegotiations] with a well-typed + * [OngoingNegotiations] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun ongoingNegotiations(ongoingNegotiations: JsonField) = + apply { + this.ongoingNegotiations = ongoingNegotiations + } + + /** + * Whether the dispute is related to the quality of food from an eating place or + * restaurant. Must be provided when Merchant Category Code (MCC) is 5812, 5813 + * or 5814. + */ + fun restaurantFoodRelated(restaurantFoodRelated: RestaurantFoodRelated) = + restaurantFoodRelated(JsonField.of(restaurantFoodRelated)) + + /** + * Sets [Builder.restaurantFoodRelated] to an arbitrary JSON value. + * + * You should usually call [Builder.restaurantFoodRelated] with a well-typed + * [RestaurantFoodRelated] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun restaurantFoodRelated(restaurantFoodRelated: JsonField) = + apply { + this.restaurantFoodRelated = restaurantFoodRelated + } + + 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 [ConsumerQualityServices]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription() + * .purchaseInfoAndQualityIssue() + * .servicesReceivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerQualityServices = + ConsumerQualityServices( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired( + "nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription", + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + ), + checkRequired("purchaseInfoAndQualityIssue", purchaseInfoAndQualityIssue), + checkRequired("servicesReceivedAt", servicesReceivedAt), + cardholderPaidToHaveWorkRedone, + ongoingNegotiations, + restaurantFoodRelated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerQualityServices = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription().validate() + purchaseInfoAndQualityIssue() + servicesReceivedAt() + cardholderPaidToHaveWorkRedone().ifPresent { it.validate() } + ongoingNegotiations().ifPresent { it.validate() } + restaurantFoodRelated().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .asKnown() + .getOrNull() + ?.validity() ?: 0) + + (if (purchaseInfoAndQualityIssue.asKnown().isPresent) 1 else 0) + + (if (servicesReceivedAt.asKnown().isPresent) 1 else 0) + + (cardholderPaidToHaveWorkRedone.asKnown().getOrNull()?.validity() ?: 0) + + (ongoingNegotiations.asKnown().getOrNull()?.validity() ?: 0) + + (restaurantFoodRelated.asKnown().getOrNull()?.validity() ?: 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a well-typed + * [AcceptedByMerchant] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun acceptedByMerchant(acceptedByMerchant: JsonField) = + apply { + this.acceptedByMerchant = acceptedByMerchant + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(acceptedByMerchant, canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Non-fiat currency or non-fungible token related and not matching description. */ + class NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + @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 { + + /** Not related. */ + @JvmField val NOT_RELATED = of("not_related") + + /** Related. */ + @JvmField val RELATED = of("related") + + @JvmStatic + fun of(value: String) = + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + JsonField.of(value) + ) + } + + /** + * An enum containing + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]'s known + * values. + */ + enum class Known { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + } + + /** + * An enum containing + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]'s known + * values, as well as an [_UNKNOWN] member. + * + * An instance of + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] can contain + * an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + /** + * An enum member indicating that + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] 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) { + NOT_RELATED -> Value.NOT_RELATED + RELATED -> Value.RELATED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NOT_RELATED -> Known.NOT_RELATED + RELATED -> Known.RELATED + else -> + throw IncreaseInvalidDataException( + "Unknown NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription && + value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Cardholder paid to have work redone. */ + class CardholderPaidToHaveWorkRedone + @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 { + + /** Cardholder did not pay to have work redone. */ + @JvmField + val DID_NOT_PAY_TO_HAVE_WORK_REDONE = of("did_not_pay_to_have_work_redone") + + /** Cardholder paid to have work redone. */ + @JvmField val PAID_TO_HAVE_WORK_REDONE = of("paid_to_have_work_redone") + + @JvmStatic + fun of(value: String) = CardholderPaidToHaveWorkRedone(JsonField.of(value)) + } + + /** An enum containing [CardholderPaidToHaveWorkRedone]'s known values. */ + enum class Known { + /** Cardholder did not pay to have work redone. */ + DID_NOT_PAY_TO_HAVE_WORK_REDONE, + /** Cardholder paid to have work redone. */ + PAID_TO_HAVE_WORK_REDONE, + } + + /** + * An enum containing [CardholderPaidToHaveWorkRedone]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CardholderPaidToHaveWorkRedone] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may 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 did not pay to have work redone. */ + DID_NOT_PAY_TO_HAVE_WORK_REDONE, + /** Cardholder paid to have work redone. */ + PAID_TO_HAVE_WORK_REDONE, + /** + * An enum member indicating that [CardholderPaidToHaveWorkRedone] 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) { + DID_NOT_PAY_TO_HAVE_WORK_REDONE -> Value.DID_NOT_PAY_TO_HAVE_WORK_REDONE + PAID_TO_HAVE_WORK_REDONE -> Value.PAID_TO_HAVE_WORK_REDONE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + DID_NOT_PAY_TO_HAVE_WORK_REDONE -> Known.DID_NOT_PAY_TO_HAVE_WORK_REDONE + PAID_TO_HAVE_WORK_REDONE -> Known.PAID_TO_HAVE_WORK_REDONE + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderPaidToHaveWorkRedone: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CardholderPaidToHaveWorkRedone = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderPaidToHaveWorkRedone && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. */ + class OngoingNegotiations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val issuerFirstNotifiedAt: JsonField, + private val startedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + issuerFirstNotifiedAt: JsonField = JsonMissing.of(), + @JsonProperty("started_at") + @ExcludeMissing + startedAt: JsonField = JsonMissing.of(), + ) : this(explanation, issuerFirstNotifiedAt, startedAt, mutableMapOf()) + + /** + * Explanation of the previous ongoing negotiations between the cardholder and + * merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Date the cardholder first notified the issuer of the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun issuerFirstNotifiedAt(): LocalDate = + issuerFirstNotifiedAt.getRequired("issuer_first_notified_at") + + /** + * Started at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startedAt(): LocalDate = startedAt.getRequired("started_at") + + /** + * 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 [issuerFirstNotifiedAt]. + * + * Unlike [issuerFirstNotifiedAt], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + fun _issuerFirstNotifiedAt(): JsonField = issuerFirstNotifiedAt + + /** + * Returns the raw JSON value of [startedAt]. + * + * Unlike [startedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("started_at") + @ExcludeMissing + fun _startedAt(): JsonField = startedAt + + @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 + * [OngoingNegotiations]. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OngoingNegotiations]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var issuerFirstNotifiedAt: JsonField? = null + private var startedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(ongoingNegotiations: OngoingNegotiations) = apply { + explanation = ongoingNegotiations.explanation + issuerFirstNotifiedAt = ongoingNegotiations.issuerFirstNotifiedAt + startedAt = ongoingNegotiations.startedAt + additionalProperties = + ongoingNegotiations.additionalProperties.toMutableMap() + } + + /** + * Explanation of the previous ongoing negotiations between the cardholder and + * merchant. + */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Date the cardholder first notified the issuer of the dispute. */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: LocalDate) = + issuerFirstNotifiedAt(JsonField.of(issuerFirstNotifiedAt)) + + /** + * Sets [Builder.issuerFirstNotifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerFirstNotifiedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: JsonField) = apply { + this.issuerFirstNotifiedAt = issuerFirstNotifiedAt + } + + /** Started at. */ + fun startedAt(startedAt: LocalDate) = startedAt(JsonField.of(startedAt)) + + /** + * Sets [Builder.startedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun startedAt(startedAt: JsonField) = apply { + this.startedAt = startedAt + } + + 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 [OngoingNegotiations]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OngoingNegotiations = + OngoingNegotiations( + checkRequired("explanation", explanation), + checkRequired("issuerFirstNotifiedAt", issuerFirstNotifiedAt), + checkRequired("startedAt", startedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OngoingNegotiations = apply { + if (validated) { + return@apply + } + + explanation() + issuerFirstNotifiedAt() + startedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (issuerFirstNotifiedAt.asKnown().isPresent) 1 else 0) + + (if (startedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OngoingNegotiations && + explanation == other.explanation && + issuerFirstNotifiedAt == other.issuerFirstNotifiedAt && + startedAt == other.startedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + issuerFirstNotifiedAt, + startedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OngoingNegotiations{explanation=$explanation, issuerFirstNotifiedAt=$issuerFirstNotifiedAt, startedAt=$startedAt, additionalProperties=$additionalProperties}" + } + + /** + * Whether the dispute is related to the quality of food from an eating place or + * restaurant. Must be provided when Merchant Category Code (MCC) is 5812, 5813 or 5814. + */ + class RestaurantFoodRelated + @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 { + + /** Not related. */ + @JvmField val NOT_RELATED = of("not_related") + + /** Related. */ + @JvmField val RELATED = of("related") + + @JvmStatic fun of(value: String) = RestaurantFoodRelated(JsonField.of(value)) + } + + /** An enum containing [RestaurantFoodRelated]'s known values. */ + enum class Known { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + } + + /** + * An enum containing [RestaurantFoodRelated]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RestaurantFoodRelated] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + /** + * An enum member indicating that [RestaurantFoodRelated] 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) { + NOT_RELATED -> Value.NOT_RELATED + RELATED -> Value.RELATED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NOT_RELATED -> Known.NOT_RELATED + RELATED -> Known.RELATED + else -> + throw IncreaseInvalidDataException( + "Unknown RestaurantFoodRelated: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RestaurantFoodRelated = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RestaurantFoodRelated && 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 ConsumerQualityServices && + cardholderCancellation == other.cardholderCancellation && + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription == + other.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription && + purchaseInfoAndQualityIssue == other.purchaseInfoAndQualityIssue && + servicesReceivedAt == other.servicesReceivedAt && + cardholderPaidToHaveWorkRedone == other.cardholderPaidToHaveWorkRedone && + ongoingNegotiations == other.ongoingNegotiations && + restaurantFoodRelated == other.restaurantFoodRelated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + purchaseInfoAndQualityIssue, + servicesReceivedAt, + cardholderPaidToHaveWorkRedone, + ongoingNegotiations, + restaurantFoodRelated, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerQualityServices{cardholderCancellation=$cardholderCancellation, nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription=$nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, purchaseInfoAndQualityIssue=$purchaseInfoAndQualityIssue, servicesReceivedAt=$servicesReceivedAt, cardholderPaidToHaveWorkRedone=$cardholderPaidToHaveWorkRedone, ongoingNegotiations=$ongoingNegotiations, restaurantFoodRelated=$restaurantFoodRelated, additionalProperties=$additionalProperties}" + } + + /** + * Services misrepresentation. Required if and only if `category` is + * `consumer_services_misrepresentation`. + */ + class ConsumerServicesMisrepresentation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val misrepresentationExplanation: JsonField, + private val purchaseExplanation: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + misrepresentationExplanation: JsonField = JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Misrepresentation explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun misrepresentationExplanation(): String = + misrepresentationExplanation.getRequired("misrepresentation_explanation") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [misrepresentationExplanation]. + * + * Unlike [misrepresentationExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + fun _misrepresentationExplanation(): JsonField = misrepresentationExplanation + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerServicesMisrepresentation]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesMisrepresentation]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = null + private var merchantResolutionAttempted: JsonField? = + null + private var misrepresentationExplanation: JsonField? = null + private var purchaseExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerServicesMisrepresentation: ConsumerServicesMisrepresentation + ) = apply { + cardholderCancellation = + consumerServicesMisrepresentation.cardholderCancellation + merchantResolutionAttempted = + consumerServicesMisrepresentation.merchantResolutionAttempted + misrepresentationExplanation = + consumerServicesMisrepresentation.misrepresentationExplanation + purchaseExplanation = consumerServicesMisrepresentation.purchaseExplanation + receivedAt = consumerServicesMisrepresentation.receivedAt + additionalProperties = + consumerServicesMisrepresentation.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Misrepresentation explanation. */ + fun misrepresentationExplanation(misrepresentationExplanation: String) = + misrepresentationExplanation(JsonField.of(misrepresentationExplanation)) + + /** + * Sets [Builder.misrepresentationExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.misrepresentationExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun misrepresentationExplanation(misrepresentationExplanation: JsonField) = + apply { + this.misrepresentationExplanation = misrepresentationExplanation + } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerServicesMisrepresentation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesMisrepresentation = + ConsumerServicesMisrepresentation( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("misrepresentationExplanation", misrepresentationExplanation), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesMisrepresentation = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + merchantResolutionAttempted().validate() + misrepresentationExplanation() + purchaseExplanation() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (misrepresentationExplanation.asKnown().isPresent) 1 else 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a well-typed + * [AcceptedByMerchant] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun acceptedByMerchant(acceptedByMerchant: JsonField) = + apply { + this.acceptedByMerchant = acceptedByMerchant + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(acceptedByMerchant, canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && 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 ConsumerServicesMisrepresentation && + cardholderCancellation == other.cardholderCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + misrepresentationExplanation == other.misrepresentationExplanation && + purchaseExplanation == other.purchaseExplanation && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesMisrepresentation{cardholderCancellation=$cardholderCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, misrepresentationExplanation=$misrepresentationExplanation, purchaseExplanation=$purchaseExplanation, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Services not as described. Required if and only if `category` is + * `consumer_services_not_as_described`. + */ + class ConsumerServicesNotAsDescribed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + merchantResolutionAttempted, + receivedAt, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerServicesNotAsDescribed]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesNotAsDescribed]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = null + private var merchantResolutionAttempted: JsonField? = + null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerServicesNotAsDescribed: ConsumerServicesNotAsDescribed) = + apply { + cardholderCancellation = + consumerServicesNotAsDescribed.cardholderCancellation + merchantResolutionAttempted = + consumerServicesNotAsDescribed.merchantResolutionAttempted + receivedAt = consumerServicesNotAsDescribed.receivedAt + additionalProperties = + consumerServicesNotAsDescribed.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerServicesNotAsDescribed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesNotAsDescribed = + ConsumerServicesNotAsDescribed( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesNotAsDescribed = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + merchantResolutionAttempted().validate() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a well-typed + * [AcceptedByMerchant] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun acceptedByMerchant(acceptedByMerchant: JsonField) = + apply { + this.acceptedByMerchant = acceptedByMerchant + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(acceptedByMerchant, canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && 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 ConsumerServicesNotAsDescribed && + cardholderCancellation == other.cardholderCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + merchantResolutionAttempted, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesNotAsDescribed{cardholderCancellation=$cardholderCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Services not received. Required if and only if `category` is + * `consumer_services_not_received`. + */ + class ConsumerServicesNotReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationOutcome: JsonField, + private val lastExpectedReceiptAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val purchaseInfoAndExplanation: JsonField, + private val cardholderCancellationPriorToExpectedReceipt: + JsonField, + private val merchantCancellation: JsonField, + private val noCancellation: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_outcome") + @ExcludeMissing + cancellationOutcome: JsonField = JsonMissing.of(), + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + lastExpectedReceiptAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + purchaseInfoAndExplanation: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of(), + @JsonProperty("merchant_cancellation") + @ExcludeMissing + merchantCancellation: JsonField = JsonMissing.of(), + @JsonProperty("no_cancellation") + @ExcludeMissing + noCancellation: JsonValue = JsonMissing.of(), + ) : this( + cancellationOutcome, + lastExpectedReceiptAt, + merchantResolutionAttempted, + purchaseInfoAndExplanation, + cardholderCancellationPriorToExpectedReceipt, + merchantCancellation, + noCancellation, + mutableMapOf(), + ) + + /** + * Cancellation outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun cancellationOutcome(): CancellationOutcome = + cancellationOutcome.getRequired("cancellation_outcome") + + /** + * Last expected receipt at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun lastExpectedReceiptAt(): LocalDate = + lastExpectedReceiptAt.getRequired("last_expected_receipt_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase information and explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun purchaseInfoAndExplanation(): String = + purchaseInfoAndExplanation.getRequired("purchase_info_and_explanation") + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun cardholderCancellationPriorToExpectedReceipt(): + Optional = + cardholderCancellationPriorToExpectedReceipt.getOptional( + "cardholder_cancellation_prior_to_expected_receipt" + ) + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun merchantCancellation(): Optional = + merchantCancellation.getOptional("merchant_cancellation") + + /** + * No cancellation. Required if and only if `cancellation_outcome` is `no_cancellation`. + */ + @JsonProperty("no_cancellation") + @ExcludeMissing + fun _noCancellation(): JsonValue = noCancellation + + /** + * Returns the raw JSON value of [cancellationOutcome]. + * + * Unlike [cancellationOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cancellation_outcome") + @ExcludeMissing + fun _cancellationOutcome(): JsonField = cancellationOutcome + + /** + * Returns the raw JSON value of [lastExpectedReceiptAt]. + * + * Unlike [lastExpectedReceiptAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + fun _lastExpectedReceiptAt(): JsonField = lastExpectedReceiptAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseInfoAndExplanation]. + * + * Unlike [purchaseInfoAndExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + fun _purchaseInfoAndExplanation(): JsonField = purchaseInfoAndExplanation + + /** + * Returns the raw JSON value of [cardholderCancellationPriorToExpectedReceipt]. + * + * Unlike [cardholderCancellationPriorToExpectedReceipt], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + fun _cardholderCancellationPriorToExpectedReceipt(): + JsonField = + cardholderCancellationPriorToExpectedReceipt + + /** + * Returns the raw JSON value of [merchantCancellation]. + * + * Unlike [merchantCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_cancellation") + @ExcludeMissing + fun _merchantCancellation(): JsonField = merchantCancellation + + @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 + * [ConsumerServicesNotReceived]. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .lastExpectedReceiptAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndExplanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesNotReceived]. */ + class Builder internal constructor() { + + private var cancellationOutcome: JsonField? = null + private var lastExpectedReceiptAt: JsonField? = null + private var merchantResolutionAttempted: JsonField? = + null + private var purchaseInfoAndExplanation: JsonField? = null + private var cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of() + private var merchantCancellation: JsonField = JsonMissing.of() + private var noCancellation: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerServicesNotReceived: ConsumerServicesNotReceived) = + apply { + cancellationOutcome = consumerServicesNotReceived.cancellationOutcome + lastExpectedReceiptAt = consumerServicesNotReceived.lastExpectedReceiptAt + merchantResolutionAttempted = + consumerServicesNotReceived.merchantResolutionAttempted + purchaseInfoAndExplanation = + consumerServicesNotReceived.purchaseInfoAndExplanation + cardholderCancellationPriorToExpectedReceipt = + consumerServicesNotReceived.cardholderCancellationPriorToExpectedReceipt + merchantCancellation = consumerServicesNotReceived.merchantCancellation + noCancellation = consumerServicesNotReceived.noCancellation + additionalProperties = + consumerServicesNotReceived.additionalProperties.toMutableMap() + } + + /** Cancellation outcome. */ + fun cancellationOutcome(cancellationOutcome: CancellationOutcome) = + cancellationOutcome(JsonField.of(cancellationOutcome)) + + /** + * Sets [Builder.cancellationOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationOutcome] with a well-typed + * [CancellationOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cancellationOutcome(cancellationOutcome: JsonField) = + apply { + this.cancellationOutcome = cancellationOutcome + } + + /** Last expected receipt at. */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: LocalDate) = + lastExpectedReceiptAt(JsonField.of(lastExpectedReceiptAt)) + + /** + * Sets [Builder.lastExpectedReceiptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastExpectedReceiptAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: JsonField) = apply { + this.lastExpectedReceiptAt = lastExpectedReceiptAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase information and explanation. */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: String) = + purchaseInfoAndExplanation(JsonField.of(purchaseInfoAndExplanation)) + + /** + * Sets [Builder.purchaseInfoAndExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: JsonField) = + apply { + this.purchaseInfoAndExplanation = purchaseInfoAndExplanation + } + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = + cardholderCancellationPriorToExpectedReceipt( + JsonField.of(cardholderCancellationPriorToExpectedReceipt) + ) + + /** + * Sets [Builder.cardholderCancellationPriorToExpectedReceipt] to an arbitrary JSON + * value. + * + * You should usually call [Builder.cardholderCancellationPriorToExpectedReceipt] + * with a well-typed [CardholderCancellationPriorToExpectedReceipt] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + JsonField + ) = apply { + this.cardholderCancellationPriorToExpectedReceipt = + cardholderCancellationPriorToExpectedReceipt + } + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + fun merchantCancellation(merchantCancellation: MerchantCancellation) = + merchantCancellation(JsonField.of(merchantCancellation)) + + /** + * Sets [Builder.merchantCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCancellation] with a well-typed + * [MerchantCancellation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun merchantCancellation(merchantCancellation: JsonField) = + apply { + this.merchantCancellation = merchantCancellation + } + + /** + * No cancellation. Required if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + fun noCancellation(noCancellation: JsonValue) = apply { + this.noCancellation = noCancellation + } + + 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 [ConsumerServicesNotReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .lastExpectedReceiptAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndExplanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesNotReceived = + ConsumerServicesNotReceived( + checkRequired("cancellationOutcome", cancellationOutcome), + checkRequired("lastExpectedReceiptAt", lastExpectedReceiptAt), + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + checkRequired("purchaseInfoAndExplanation", purchaseInfoAndExplanation), + cardholderCancellationPriorToExpectedReceipt, + merchantCancellation, + noCancellation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesNotReceived = apply { + if (validated) { + return@apply + } + + cancellationOutcome().validate() + lastExpectedReceiptAt() + merchantResolutionAttempted().validate() + purchaseInfoAndExplanation() + cardholderCancellationPriorToExpectedReceipt().ifPresent { it.validate() } + merchantCancellation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastExpectedReceiptAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndExplanation.asKnown().isPresent) 1 else 0) + + (cardholderCancellationPriorToExpectedReceipt.asKnown().getOrNull()?.validity() + ?: 0) + + (merchantCancellation.asKnown().getOrNull()?.validity() ?: 0) + + /** Cancellation outcome. */ + class CancellationOutcome + @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 { + + /** Cardholder cancellation prior to expected receipt. */ + @JvmField + val CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT = + of("cardholder_cancellation_prior_to_expected_receipt") + + /** Merchant cancellation. */ + @JvmField val MERCHANT_CANCELLATION = of("merchant_cancellation") + + /** No cancellation. */ + @JvmField val NO_CANCELLATION = of("no_cancellation") + + @JvmStatic fun of(value: String) = CancellationOutcome(JsonField.of(value)) + } + + /** An enum containing [CancellationOutcome]'s known values. */ + enum class Known { + /** Cardholder cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + } + + /** + * An enum containing [CancellationOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [CancellationOutcome] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may 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 cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + /** + * An enum member indicating that [CancellationOutcome] 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_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Value.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Value.MERCHANT_CANCELLATION + NO_CANCELLATION -> Value.NO_CANCELLATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Known.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Known.MERCHANT_CANCELLATION + NO_CANCELLATION -> Known.NO_CANCELLATION + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + */ + class CardholderCancellationPriorToExpectedReceipt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellationPriorToExpectedReceipt]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = apply { + canceledAt = cardholderCancellationPriorToExpectedReceipt.canceledAt + reason = cardholderCancellationPriorToExpectedReceipt.reason + additionalProperties = + cardholderCancellationPriorToExpectedReceipt.additionalProperties + .toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellationPriorToExpectedReceipt = + CardholderCancellationPriorToExpectedReceipt( + checkRequired("canceledAt", canceledAt), + reason, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellationPriorToExpectedReceipt = apply { + if (validated) { + return@apply + } + + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderCancellationPriorToExpectedReceipt && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellationPriorToExpectedReceipt{canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + class MerchantCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of() + ) : this(canceledAt, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + @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 + * [MerchantCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCancellation: MerchantCancellation) = apply { + canceledAt = merchantCancellation.canceledAt + additionalProperties = + merchantCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + 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 [MerchantCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCancellation = + MerchantCancellation( + checkRequired("canceledAt", canceledAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (canceledAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCancellation && + canceledAt == other.canceledAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(canceledAt, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCancellation{canceledAt=$canceledAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerServicesNotReceived && + cancellationOutcome == other.cancellationOutcome && + lastExpectedReceiptAt == other.lastExpectedReceiptAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseInfoAndExplanation == other.purchaseInfoAndExplanation && + cardholderCancellationPriorToExpectedReceipt == + other.cardholderCancellationPriorToExpectedReceipt && + merchantCancellation == other.merchantCancellation && + noCancellation == other.noCancellation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationOutcome, + lastExpectedReceiptAt, + merchantResolutionAttempted, + purchaseInfoAndExplanation, + cardholderCancellationPriorToExpectedReceipt, + merchantCancellation, + noCancellation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesNotReceived{cancellationOutcome=$cancellationOutcome, lastExpectedReceiptAt=$lastExpectedReceiptAt, merchantResolutionAttempted=$merchantResolutionAttempted, purchaseInfoAndExplanation=$purchaseInfoAndExplanation, cardholderCancellationPriorToExpectedReceipt=$cardholderCancellationPriorToExpectedReceipt, merchantCancellation=$merchantCancellation, noCancellation=$noCancellation, additionalProperties=$additionalProperties}" + } + + /** Fraud. Required if and only if `category` is `fraud`. */ + class Fraud + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fraudType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fraud_type") + @ExcludeMissing + fraudType: JsonField = JsonMissing.of() + ) : this(fraudType, mutableMapOf()) + + /** + * Fraud type. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun fraudType(): FraudType = fraudType.getRequired("fraud_type") + + /** + * Returns the raw JSON value of [fraudType]. + * + * Unlike [fraudType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fraud_type") + @ExcludeMissing + fun _fraudType(): JsonField = fraudType + + @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 [Fraud]. + * + * The following fields are required: + * ```java + * .fraudType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Fraud]. */ + class Builder internal constructor() { + + private var fraudType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fraud: Fraud) = apply { + fraudType = fraud.fraudType + additionalProperties = fraud.additionalProperties.toMutableMap() + } + + /** Fraud type. */ + fun fraudType(fraudType: FraudType) = fraudType(JsonField.of(fraudType)) + + /** + * Sets [Builder.fraudType] to an arbitrary JSON value. + * + * You should usually call [Builder.fraudType] with a well-typed [FraudType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun fraudType(fraudType: JsonField) = apply { + this.fraudType = fraudType + } + + 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 [Fraud]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fraudType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Fraud = + Fraud( + checkRequired("fraudType", fraudType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Fraud = apply { + if (validated) { + return@apply + } + + fraudType().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (fraudType.asKnown().getOrNull()?.validity() ?: 0) + + /** Fraud type. */ + class FraudType @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 { + + /** Account or credentials takeover. */ + @JvmField + val ACCOUNT_OR_CREDENTIALS_TAKEOVER = of("account_or_credentials_takeover") + + /** Card not received as issued. */ + @JvmField val CARD_NOT_RECEIVED_AS_ISSUED = of("card_not_received_as_issued") + + /** Fraudulent application. */ + @JvmField val FRAUDULENT_APPLICATION = of("fraudulent_application") + + /** Fraudulent use of account number. */ + @JvmField + val FRAUDULENT_USE_OF_ACCOUNT_NUMBER = of("fraudulent_use_of_account_number") + + /** Incorrect processing. */ + @JvmField val INCORRECT_PROCESSING = of("incorrect_processing") + + /** Issuer reported counterfeit. */ + @JvmField val ISSUER_REPORTED_COUNTERFEIT = of("issuer_reported_counterfeit") + + /** Lost. */ + @JvmField val LOST = of("lost") + + /** Manipulation of account holder. */ + @JvmField + val MANIPULATION_OF_ACCOUNT_HOLDER = of("manipulation_of_account_holder") + + /** Merchant misrepresentation. */ + @JvmField val MERCHANT_MISREPRESENTATION = of("merchant_misrepresentation") + + /** Miscellaneous. */ + @JvmField val MISCELLANEOUS = of("miscellaneous") + + /** Stolen. */ + @JvmField val STOLEN = of("stolen") + + @JvmStatic fun of(value: String) = FraudType(JsonField.of(value)) + } + + /** An enum containing [FraudType]'s known values. */ + enum class Known { + /** Account or credentials takeover. */ + ACCOUNT_OR_CREDENTIALS_TAKEOVER, + /** Card not received as issued. */ + CARD_NOT_RECEIVED_AS_ISSUED, + /** Fraudulent application. */ + FRAUDULENT_APPLICATION, + /** Fraudulent use of account number. */ + FRAUDULENT_USE_OF_ACCOUNT_NUMBER, + /** Incorrect processing. */ + INCORRECT_PROCESSING, + /** Issuer reported counterfeit. */ + ISSUER_REPORTED_COUNTERFEIT, + /** Lost. */ + LOST, + /** Manipulation of account holder. */ + MANIPULATION_OF_ACCOUNT_HOLDER, + /** Merchant misrepresentation. */ + MERCHANT_MISREPRESENTATION, + /** Miscellaneous. */ + MISCELLANEOUS, + /** Stolen. */ + STOLEN, + } + + /** + * An enum containing [FraudType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FraudType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may 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 or credentials takeover. */ + ACCOUNT_OR_CREDENTIALS_TAKEOVER, + /** Card not received as issued. */ + CARD_NOT_RECEIVED_AS_ISSUED, + /** Fraudulent application. */ + FRAUDULENT_APPLICATION, + /** Fraudulent use of account number. */ + FRAUDULENT_USE_OF_ACCOUNT_NUMBER, + /** Incorrect processing. */ + INCORRECT_PROCESSING, + /** Issuer reported counterfeit. */ + ISSUER_REPORTED_COUNTERFEIT, + /** Lost. */ + LOST, + /** Manipulation of account holder. */ + MANIPULATION_OF_ACCOUNT_HOLDER, + /** Merchant misrepresentation. */ + MERCHANT_MISREPRESENTATION, + /** Miscellaneous. */ + MISCELLANEOUS, + /** Stolen. */ + STOLEN, + /** + * An enum member indicating that [FraudType] 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_OR_CREDENTIALS_TAKEOVER -> Value.ACCOUNT_OR_CREDENTIALS_TAKEOVER + CARD_NOT_RECEIVED_AS_ISSUED -> Value.CARD_NOT_RECEIVED_AS_ISSUED + FRAUDULENT_APPLICATION -> Value.FRAUDULENT_APPLICATION + FRAUDULENT_USE_OF_ACCOUNT_NUMBER -> Value.FRAUDULENT_USE_OF_ACCOUNT_NUMBER + INCORRECT_PROCESSING -> Value.INCORRECT_PROCESSING + ISSUER_REPORTED_COUNTERFEIT -> Value.ISSUER_REPORTED_COUNTERFEIT + LOST -> Value.LOST + MANIPULATION_OF_ACCOUNT_HOLDER -> Value.MANIPULATION_OF_ACCOUNT_HOLDER + MERCHANT_MISREPRESENTATION -> Value.MERCHANT_MISREPRESENTATION + MISCELLANEOUS -> Value.MISCELLANEOUS + STOLEN -> Value.STOLEN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_OR_CREDENTIALS_TAKEOVER -> Known.ACCOUNT_OR_CREDENTIALS_TAKEOVER + CARD_NOT_RECEIVED_AS_ISSUED -> Known.CARD_NOT_RECEIVED_AS_ISSUED + FRAUDULENT_APPLICATION -> Known.FRAUDULENT_APPLICATION + FRAUDULENT_USE_OF_ACCOUNT_NUMBER -> Known.FRAUDULENT_USE_OF_ACCOUNT_NUMBER + INCORRECT_PROCESSING -> Known.INCORRECT_PROCESSING + ISSUER_REPORTED_COUNTERFEIT -> Known.ISSUER_REPORTED_COUNTERFEIT + LOST -> Known.LOST + MANIPULATION_OF_ACCOUNT_HOLDER -> Known.MANIPULATION_OF_ACCOUNT_HOLDER + MERCHANT_MISREPRESENTATION -> Known.MERCHANT_MISREPRESENTATION + MISCELLANEOUS -> Known.MISCELLANEOUS + STOLEN -> Known.STOLEN + else -> throw IncreaseInvalidDataException("Unknown FraudType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): FraudType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FraudType && 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 Fraud && + fraudType == other.fraudType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fraudType, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Fraud{fraudType=$fraudType, additionalProperties=$additionalProperties}" + } + + /** Processing error. Required if and only if `category` is `processing_error`. */ + class ProcessingError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val errorReason: JsonField, + private val merchantResolutionAttempted: JsonField, + private val duplicateTransaction: JsonField, + private val incorrectAmount: JsonField, + private val paidByOtherMeans: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("error_reason") + @ExcludeMissing + errorReason: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("duplicate_transaction") + @ExcludeMissing + duplicateTransaction: JsonField = JsonMissing.of(), + @JsonProperty("incorrect_amount") + @ExcludeMissing + incorrectAmount: JsonField = JsonMissing.of(), + @JsonProperty("paid_by_other_means") + @ExcludeMissing + paidByOtherMeans: JsonField = JsonMissing.of(), + ) : this( + errorReason, + merchantResolutionAttempted, + duplicateTransaction, + incorrectAmount, + paidByOtherMeans, + mutableMapOf(), + ) + + /** + * Error reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun errorReason(): ErrorReason = errorReason.getRequired("error_reason") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Duplicate transaction. Required if and only if `error_reason` is + * `duplicate_transaction`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun duplicateTransaction(): Optional = + duplicateTransaction.getOptional("duplicate_transaction") + + /** + * Incorrect amount. Required if and only if `error_reason` is `incorrect_amount`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun incorrectAmount(): Optional = + incorrectAmount.getOptional("incorrect_amount") + + /** + * Paid by other means. Required if and only if `error_reason` is `paid_by_other_means`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun paidByOtherMeans(): Optional = + paidByOtherMeans.getOptional("paid_by_other_means") + + /** + * Returns the raw JSON value of [errorReason]. + * + * Unlike [errorReason], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("error_reason") + @ExcludeMissing + fun _errorReason(): JsonField = errorReason + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [duplicateTransaction]. + * + * Unlike [duplicateTransaction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("duplicate_transaction") + @ExcludeMissing + fun _duplicateTransaction(): JsonField = duplicateTransaction + + /** + * Returns the raw JSON value of [incorrectAmount]. + * + * Unlike [incorrectAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("incorrect_amount") + @ExcludeMissing + fun _incorrectAmount(): JsonField = incorrectAmount + + /** + * Returns the raw JSON value of [paidByOtherMeans]. + * + * Unlike [paidByOtherMeans], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("paid_by_other_means") + @ExcludeMissing + fun _paidByOtherMeans(): JsonField = paidByOtherMeans + + @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 [ProcessingError]. + * + * The following fields are required: + * ```java + * .errorReason() + * .merchantResolutionAttempted() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProcessingError]. */ + class Builder internal constructor() { + + private var errorReason: JsonField? = null + private var merchantResolutionAttempted: JsonField? = + null + private var duplicateTransaction: JsonField = JsonMissing.of() + private var incorrectAmount: JsonField = JsonMissing.of() + private var paidByOtherMeans: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(processingError: ProcessingError) = apply { + errorReason = processingError.errorReason + merchantResolutionAttempted = processingError.merchantResolutionAttempted + duplicateTransaction = processingError.duplicateTransaction + incorrectAmount = processingError.incorrectAmount + paidByOtherMeans = processingError.paidByOtherMeans + additionalProperties = processingError.additionalProperties.toMutableMap() + } + + /** Error reason. */ + fun errorReason(errorReason: ErrorReason) = errorReason(JsonField.of(errorReason)) + + /** + * Sets [Builder.errorReason] to an arbitrary JSON value. + * + * You should usually call [Builder.errorReason] with a well-typed [ErrorReason] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun errorReason(errorReason: JsonField) = apply { + this.errorReason = errorReason + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a well-typed + * [MerchantResolutionAttempted] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * Duplicate transaction. Required if and only if `error_reason` is + * `duplicate_transaction`. + */ + fun duplicateTransaction(duplicateTransaction: DuplicateTransaction) = + duplicateTransaction(JsonField.of(duplicateTransaction)) + + /** + * Sets [Builder.duplicateTransaction] to an arbitrary JSON value. + * + * You should usually call [Builder.duplicateTransaction] with a well-typed + * [DuplicateTransaction] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun duplicateTransaction(duplicateTransaction: JsonField) = + apply { + this.duplicateTransaction = duplicateTransaction + } + + /** + * Incorrect amount. Required if and only if `error_reason` is `incorrect_amount`. + */ + fun incorrectAmount(incorrectAmount: IncorrectAmount) = + incorrectAmount(JsonField.of(incorrectAmount)) + + /** + * Sets [Builder.incorrectAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.incorrectAmount] with a well-typed + * [IncorrectAmount] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun incorrectAmount(incorrectAmount: JsonField) = apply { + this.incorrectAmount = incorrectAmount + } + + /** + * Paid by other means. Required if and only if `error_reason` is + * `paid_by_other_means`. + */ + fun paidByOtherMeans(paidByOtherMeans: PaidByOtherMeans) = + paidByOtherMeans(JsonField.of(paidByOtherMeans)) + + /** + * Sets [Builder.paidByOtherMeans] to an arbitrary JSON value. + * + * You should usually call [Builder.paidByOtherMeans] with a well-typed + * [PaidByOtherMeans] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paidByOtherMeans(paidByOtherMeans: JsonField) = apply { + this.paidByOtherMeans = paidByOtherMeans + } + + 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 [ProcessingError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .errorReason() + * .merchantResolutionAttempted() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProcessingError = + ProcessingError( + checkRequired("errorReason", errorReason), + checkRequired("merchantResolutionAttempted", merchantResolutionAttempted), + duplicateTransaction, + incorrectAmount, + paidByOtherMeans, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProcessingError = apply { + if (validated) { + return@apply + } + + errorReason().validate() + merchantResolutionAttempted().validate() + duplicateTransaction().ifPresent { it.validate() } + incorrectAmount().ifPresent { it.validate() } + paidByOtherMeans().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (errorReason.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (duplicateTransaction.asKnown().getOrNull()?.validity() ?: 0) + + (incorrectAmount.asKnown().getOrNull()?.validity() ?: 0) + + (paidByOtherMeans.asKnown().getOrNull()?.validity() ?: 0) + + /** Error reason. */ + class ErrorReason + @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 { + + /** Duplicate transaction. */ + @JvmField val DUPLICATE_TRANSACTION = of("duplicate_transaction") + + /** Incorrect amount. */ + @JvmField val INCORRECT_AMOUNT = of("incorrect_amount") + + /** Paid by other means. */ + @JvmField val PAID_BY_OTHER_MEANS = of("paid_by_other_means") + + @JvmStatic fun of(value: String) = ErrorReason(JsonField.of(value)) + } + + /** An enum containing [ErrorReason]'s known values. */ + enum class Known { + /** Duplicate transaction. */ + DUPLICATE_TRANSACTION, + /** Incorrect amount. */ + INCORRECT_AMOUNT, + /** Paid by other means. */ + PAID_BY_OTHER_MEANS, + } + + /** + * An enum containing [ErrorReason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ErrorReason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Duplicate transaction. */ + DUPLICATE_TRANSACTION, + /** Incorrect amount. */ + INCORRECT_AMOUNT, + /** Paid by other means. */ + PAID_BY_OTHER_MEANS, + /** + * An enum member indicating that [ErrorReason] 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) { + DUPLICATE_TRANSACTION -> Value.DUPLICATE_TRANSACTION + INCORRECT_AMOUNT -> Value.INCORRECT_AMOUNT + PAID_BY_OTHER_MEANS -> Value.PAID_BY_OTHER_MEANS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + DUPLICATE_TRANSACTION -> Known.DUPLICATE_TRANSACTION + INCORRECT_AMOUNT -> Known.INCORRECT_AMOUNT + PAID_BY_OTHER_MEANS -> Known.PAID_BY_OTHER_MEANS + else -> throw IncreaseInvalidDataException("Unknown ErrorReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ErrorReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ErrorReason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Duplicate transaction. Required if and only if `error_reason` is + * `duplicate_transaction`. + */ + class DuplicateTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val otherTransactionId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("other_transaction_id") + @ExcludeMissing + otherTransactionId: JsonField = JsonMissing.of() + ) : this(otherTransactionId, mutableMapOf()) + + /** + * Other transaction ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun otherTransactionId(): String = + otherTransactionId.getRequired("other_transaction_id") + + /** + * Returns the raw JSON value of [otherTransactionId]. + * + * Unlike [otherTransactionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_transaction_id") + @ExcludeMissing + fun _otherTransactionId(): JsonField = otherTransactionId + + @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 + * [DuplicateTransaction]. + * + * The following fields are required: + * ```java + * .otherTransactionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DuplicateTransaction]. */ + class Builder internal constructor() { + + private var otherTransactionId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(duplicateTransaction: DuplicateTransaction) = apply { + otherTransactionId = duplicateTransaction.otherTransactionId + additionalProperties = + duplicateTransaction.additionalProperties.toMutableMap() + } + + /** Other transaction ID. */ + fun otherTransactionId(otherTransactionId: String) = + otherTransactionId(JsonField.of(otherTransactionId)) + + /** + * Sets [Builder.otherTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.otherTransactionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun otherTransactionId(otherTransactionId: JsonField) = apply { + this.otherTransactionId = otherTransactionId + } + + 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 [DuplicateTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .otherTransactionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DuplicateTransaction = + DuplicateTransaction( + checkRequired("otherTransactionId", otherTransactionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DuplicateTransaction = apply { + if (validated) { + return@apply + } + + otherTransactionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (otherTransactionId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DuplicateTransaction && + otherTransactionId == other.otherTransactionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(otherTransactionId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DuplicateTransaction{otherTransactionId=$otherTransactionId, additionalProperties=$additionalProperties}" + } + + /** Incorrect amount. Required if and only if `error_reason` is `incorrect_amount`. */ + class IncorrectAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expectedAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expected_amount") + @ExcludeMissing + expectedAmount: JsonField = JsonMissing.of() + ) : this(expectedAmount, mutableMapOf()) + + /** + * Expected amount. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun expectedAmount(): Long = expectedAmount.getRequired("expected_amount") + + /** + * Returns the raw JSON value of [expectedAmount]. + * + * Unlike [expectedAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("expected_amount") + @ExcludeMissing + fun _expectedAmount(): JsonField = expectedAmount + + @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 [IncorrectAmount]. + * + * The following fields are required: + * ```java + * .expectedAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IncorrectAmount]. */ + class Builder internal constructor() { + + private var expectedAmount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(incorrectAmount: IncorrectAmount) = apply { + expectedAmount = incorrectAmount.expectedAmount + additionalProperties = incorrectAmount.additionalProperties.toMutableMap() + } + + /** Expected amount. */ + fun expectedAmount(expectedAmount: Long) = + expectedAmount(JsonField.of(expectedAmount)) + + /** + * Sets [Builder.expectedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedAmount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun expectedAmount(expectedAmount: JsonField) = apply { + this.expectedAmount = expectedAmount + } + + 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 [IncorrectAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expectedAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): IncorrectAmount = + IncorrectAmount( + checkRequired("expectedAmount", expectedAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): IncorrectAmount = apply { + if (validated) { + return@apply + } + + expectedAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (expectedAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IncorrectAmount && + expectedAmount == other.expectedAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expectedAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "IncorrectAmount{expectedAmount=$expectedAmount, additionalProperties=$additionalProperties}" + } + + /** + * Paid by other means. Required if and only if `error_reason` is `paid_by_other_means`. + */ + class PaidByOtherMeans + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val otherFormOfPaymentEvidence: JsonField, + private val otherTransactionId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("other_form_of_payment_evidence") + @ExcludeMissing + otherFormOfPaymentEvidence: JsonField = + JsonMissing.of(), + @JsonProperty("other_transaction_id") + @ExcludeMissing + otherTransactionId: JsonField = JsonMissing.of(), + ) : this(otherFormOfPaymentEvidence, otherTransactionId, mutableMapOf()) + + /** + * Other form of payment evidence. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun otherFormOfPaymentEvidence(): OtherFormOfPaymentEvidence = + otherFormOfPaymentEvidence.getRequired("other_form_of_payment_evidence") + + /** + * Other transaction ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherTransactionId(): Optional = + otherTransactionId.getOptional("other_transaction_id") + + /** + * Returns the raw JSON value of [otherFormOfPaymentEvidence]. + * + * Unlike [otherFormOfPaymentEvidence], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("other_form_of_payment_evidence") + @ExcludeMissing + fun _otherFormOfPaymentEvidence(): JsonField = + otherFormOfPaymentEvidence + + /** + * Returns the raw JSON value of [otherTransactionId]. + * + * Unlike [otherTransactionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_transaction_id") + @ExcludeMissing + fun _otherTransactionId(): JsonField = otherTransactionId + + @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 [PaidByOtherMeans]. + * + * The following fields are required: + * ```java + * .otherFormOfPaymentEvidence() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaidByOtherMeans]. */ + class Builder internal constructor() { + + private var otherFormOfPaymentEvidence: JsonField? = + null + private var otherTransactionId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paidByOtherMeans: PaidByOtherMeans) = apply { + otherFormOfPaymentEvidence = paidByOtherMeans.otherFormOfPaymentEvidence + otherTransactionId = paidByOtherMeans.otherTransactionId + additionalProperties = paidByOtherMeans.additionalProperties.toMutableMap() + } + + /** Other form of payment evidence. */ + fun otherFormOfPaymentEvidence( + otherFormOfPaymentEvidence: OtherFormOfPaymentEvidence + ) = otherFormOfPaymentEvidence(JsonField.of(otherFormOfPaymentEvidence)) + + /** + * Sets [Builder.otherFormOfPaymentEvidence] to an arbitrary JSON value. + * + * You should usually call [Builder.otherFormOfPaymentEvidence] with a + * well-typed [OtherFormOfPaymentEvidence] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun otherFormOfPaymentEvidence( + otherFormOfPaymentEvidence: JsonField + ) = apply { this.otherFormOfPaymentEvidence = otherFormOfPaymentEvidence } + + /** Other transaction ID. */ + fun otherTransactionId(otherTransactionId: String) = + otherTransactionId(JsonField.of(otherTransactionId)) + + /** + * Sets [Builder.otherTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.otherTransactionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun otherTransactionId(otherTransactionId: JsonField) = apply { + this.otherTransactionId = otherTransactionId + } + + 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 [PaidByOtherMeans]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .otherFormOfPaymentEvidence() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaidByOtherMeans = + PaidByOtherMeans( + checkRequired("otherFormOfPaymentEvidence", otherFormOfPaymentEvidence), + otherTransactionId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaidByOtherMeans = apply { + if (validated) { + return@apply + } + + otherFormOfPaymentEvidence().validate() + otherTransactionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (otherFormOfPaymentEvidence.asKnown().getOrNull()?.validity() ?: 0) + + (if (otherTransactionId.asKnown().isPresent) 1 else 0) + + /** Other form of payment evidence. */ + class OtherFormOfPaymentEvidence + @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 { + + /** Canceled check. */ + @JvmField val CANCELED_CHECK = of("canceled_check") + + /** Card transaction. */ + @JvmField val CARD_TRANSACTION = of("card_transaction") + + /** Cash receipt. */ + @JvmField val CASH_RECEIPT = of("cash_receipt") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Statement. */ + @JvmField val STATEMENT = of("statement") + + /** Voucher. */ + @JvmField val VOUCHER = of("voucher") + + @JvmStatic + fun of(value: String) = OtherFormOfPaymentEvidence(JsonField.of(value)) + } + + /** An enum containing [OtherFormOfPaymentEvidence]'s known values. */ + enum class Known { + /** Canceled check. */ + CANCELED_CHECK, + /** Card transaction. */ + CARD_TRANSACTION, + /** Cash receipt. */ + CASH_RECEIPT, + /** Other. */ + OTHER, + /** Statement. */ + STATEMENT, + /** Voucher. */ + VOUCHER, + } + + /** + * An enum containing [OtherFormOfPaymentEvidence]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [OtherFormOfPaymentEvidence] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Canceled check. */ + CANCELED_CHECK, + /** Card transaction. */ + CARD_TRANSACTION, + /** Cash receipt. */ + CASH_RECEIPT, + /** Other. */ + OTHER, + /** Statement. */ + STATEMENT, + /** Voucher. */ + VOUCHER, + /** + * An enum member indicating that [OtherFormOfPaymentEvidence] 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) { + CANCELED_CHECK -> Value.CANCELED_CHECK + CARD_TRANSACTION -> Value.CARD_TRANSACTION + CASH_RECEIPT -> Value.CASH_RECEIPT + OTHER -> Value.OTHER + STATEMENT -> Value.STATEMENT + VOUCHER -> Value.VOUCHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CANCELED_CHECK -> Known.CANCELED_CHECK + CARD_TRANSACTION -> Known.CARD_TRANSACTION + CASH_RECEIPT -> Known.CASH_RECEIPT + OTHER -> Known.OTHER + STATEMENT -> Known.STATEMENT + VOUCHER -> Known.VOUCHER + else -> + throw IncreaseInvalidDataException( + "Unknown OtherFormOfPaymentEvidence: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): OtherFormOfPaymentEvidence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OtherFormOfPaymentEvidence && 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 PaidByOtherMeans && + otherFormOfPaymentEvidence == other.otherFormOfPaymentEvidence && + otherTransactionId == other.otherTransactionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + otherFormOfPaymentEvidence, + otherTransactionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaidByOtherMeans{otherFormOfPaymentEvidence=$otherFormOfPaymentEvidence, otherTransactionId=$otherTransactionId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProcessingError && + errorReason == other.errorReason && + merchantResolutionAttempted == other.merchantResolutionAttempted && + duplicateTransaction == other.duplicateTransaction && + incorrectAmount == other.incorrectAmount && + paidByOtherMeans == other.paidByOtherMeans && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + errorReason, + merchantResolutionAttempted, + duplicateTransaction, + incorrectAmount, + paidByOtherMeans, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProcessingError{errorReason=$errorReason, merchantResolutionAttempted=$merchantResolutionAttempted, duplicateTransaction=$duplicateTransaction, incorrectAmount=$incorrectAmount, paidByOtherMeans=$paidByOtherMeans, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Visa && + category == other.category && + authorization == other.authorization && + consumerCanceledMerchandise == other.consumerCanceledMerchandise && + consumerCanceledRecurringTransaction == + other.consumerCanceledRecurringTransaction && + consumerCanceledServices == other.consumerCanceledServices && + consumerCounterfeitMerchandise == other.consumerCounterfeitMerchandise && + consumerCreditNotProcessed == other.consumerCreditNotProcessed && + consumerDamagedOrDefectiveMerchandise == + other.consumerDamagedOrDefectiveMerchandise && + consumerMerchandiseMisrepresentation == + other.consumerMerchandiseMisrepresentation && + consumerMerchandiseNotAsDescribed == other.consumerMerchandiseNotAsDescribed && + consumerMerchandiseNotReceived == other.consumerMerchandiseNotReceived && + consumerNonReceiptOfCash == other.consumerNonReceiptOfCash && + consumerOriginalCreditTransactionNotAccepted == + other.consumerOriginalCreditTransactionNotAccepted && + consumerQualityMerchandise == other.consumerQualityMerchandise && + consumerQualityServices == other.consumerQualityServices && + consumerServicesMisrepresentation == other.consumerServicesMisrepresentation && + consumerServicesNotAsDescribed == other.consumerServicesNotAsDescribed && + consumerServicesNotReceived == other.consumerServicesNotReceived && + fraud == other.fraud && + processingError == other.processingError && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + category, + authorization, + consumerCanceledMerchandise, + consumerCanceledRecurringTransaction, + consumerCanceledServices, + consumerCounterfeitMerchandise, + consumerCreditNotProcessed, + consumerDamagedOrDefectiveMerchandise, + consumerMerchandiseMisrepresentation, + consumerMerchandiseNotAsDescribed, + consumerMerchandiseNotReceived, + consumerNonReceiptOfCash, + consumerOriginalCreditTransactionNotAccepted, + consumerQualityMerchandise, + consumerQualityServices, + consumerServicesMisrepresentation, + consumerServicesNotAsDescribed, + consumerServicesNotReceived, + fraud, + processingError, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Visa{category=$category, authorization=$authorization, consumerCanceledMerchandise=$consumerCanceledMerchandise, consumerCanceledRecurringTransaction=$consumerCanceledRecurringTransaction, consumerCanceledServices=$consumerCanceledServices, consumerCounterfeitMerchandise=$consumerCounterfeitMerchandise, consumerCreditNotProcessed=$consumerCreditNotProcessed, consumerDamagedOrDefectiveMerchandise=$consumerDamagedOrDefectiveMerchandise, consumerMerchandiseMisrepresentation=$consumerMerchandiseMisrepresentation, consumerMerchandiseNotAsDescribed=$consumerMerchandiseNotAsDescribed, consumerMerchandiseNotReceived=$consumerMerchandiseNotReceived, consumerNonReceiptOfCash=$consumerNonReceiptOfCash, consumerOriginalCreditTransactionNotAccepted=$consumerOriginalCreditTransactionNotAccepted, consumerQualityMerchandise=$consumerQualityMerchandise, consumerQualityServices=$consumerQualityServices, consumerServicesMisrepresentation=$consumerServicesMisrepresentation, consumerServicesNotAsDescribed=$consumerServicesNotAsDescribed, consumerServicesNotReceived=$consumerServicesNotReceived, fraud=$fraud, processingError=$processingError, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardDisputeCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardDisputeCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPage.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPage.kt new file mode 100644 index 000000000..abea17ee5 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPage.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.increase.api.core.AutoPager +import com.increase.api.core.Page +import com.increase.api.core.checkRequired +import com.increase.api.services.blocking.CardDisputeService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see CardDisputeService.list */ +class CardDisputeListPage +private constructor( + private val service: CardDisputeService, + private val params: CardDisputeListParams, + private val response: CardDisputeListPageResponse, +) : Page { + + /** + * Delegates to [CardDisputeListPageResponse], but gracefully handles missing data. + * + * @see CardDisputeListPageResponse.data + */ + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardDisputeListPageResponse], but gracefully handles missing data. + * + * @see CardDisputeListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): CardDisputeListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CardDisputeListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): CardDisputeListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardDisputeListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardDisputeListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeListPage]. */ + class Builder internal constructor() { + + private var service: CardDisputeService? = null + private var params: CardDisputeListParams? = null + private var response: CardDisputeListPageResponse? = null + + @JvmSynthetic + internal fun from(cardDisputeListPage: CardDisputeListPage) = apply { + service = cardDisputeListPage.service + params = cardDisputeListPage.params + response = cardDisputeListPage.response + } + + fun service(service: CardDisputeService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: CardDisputeListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardDisputeListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CardDisputeListPage]. + * + * 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(): CardDisputeListPage = + CardDisputeListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardDisputeListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "CardDisputeListPage{service=$service, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageAsync.kt new file mode 100644 index 000000000..a7c681639 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageAsync.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.increase.api.core.AutoPagerAsync +import com.increase.api.core.PageAsync +import com.increase.api.core.checkRequired +import com.increase.api.services.async.CardDisputeServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see CardDisputeServiceAsync.list */ +class CardDisputeListPageAsync +private constructor( + private val service: CardDisputeServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: CardDisputeListParams, + private val response: CardDisputeListPageResponse, +) : PageAsync { + + /** + * Delegates to [CardDisputeListPageResponse], but gracefully handles missing data. + * + * @see CardDisputeListPageResponse.data + */ + fun data(): List = response._data().getOptional("data").getOrNull() ?: emptyList() + + /** + * Delegates to [CardDisputeListPageResponse], but gracefully handles missing data. + * + * @see CardDisputeListPageResponse.nextCursor + */ + fun nextCursor(): Optional = response._nextCursor().getOptional("next_cursor") + + override fun items(): List = data() + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextCursor().isPresent + + fun nextPageParams(): CardDisputeListParams { + val nextCursor = + nextCursor().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() + } + + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) + + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) + + /** The parameters that were used to request this page. */ + fun params(): CardDisputeListParams = params + + /** The response that this page was parsed from. */ + fun response(): CardDisputeListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardDisputeListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeListPageAsync]. */ + class Builder internal constructor() { + + private var service: CardDisputeServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: CardDisputeListParams? = null + private var response: CardDisputeListPageResponse? = null + + @JvmSynthetic + internal fun from(cardDisputeListPageAsync: CardDisputeListPageAsync) = apply { + service = cardDisputeListPageAsync.service + streamHandlerExecutor = cardDisputeListPageAsync.streamHandlerExecutor + params = cardDisputeListPageAsync.params + response = cardDisputeListPageAsync.response + } + + fun service(service: CardDisputeServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: CardDisputeListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: CardDisputeListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [CardDisputeListPageAsync]. + * + * 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(): CardDisputeListPageAsync = + CardDisputeListPageAsync( + 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 CardDisputeListPageAsync && + 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() = + "CardDisputeListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponse.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponse.kt new file mode 100644 index 000000000..8ca9d9a35 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponse.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.increase.api.core.ExcludeMissing +import com.increase.api.core.JsonField +import com.increase.api.core.JsonMissing +import com.increase.api.core.JsonValue +import com.increase.api.core.checkKnown +import com.increase.api.core.checkRequired +import com.increase.api.core.toImmutable +import com.increase.api.errors.IncreaseInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A list of Card Dispute objects. */ +class CardDisputeListPageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField>, + private val nextCursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of(), + @JsonProperty("next_cursor") + @ExcludeMissing + nextCursor: JsonField = JsonMissing.of(), + ) : this(data, nextCursor, mutableMapOf()) + + /** + * The contents of the list. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): List = data.getRequired("data") + + /** + * A pointer to a place in the list. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextCursor(): Optional = nextCursor.getOptional("next_cursor") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + /** + * Returns the raw JSON value of [nextCursor]. + * + * Unlike [nextCursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CardDisputeListPageResponse]. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeListPageResponse]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var nextCursor: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardDisputeListPageResponse: CardDisputeListPageResponse) = apply { + data = cardDisputeListPageResponse.data.map { it.toMutableList() } + nextCursor = cardDisputeListPageResponse.nextCursor + additionalProperties = cardDisputeListPageResponse.additionalProperties.toMutableMap() + } + + /** The contents of the list. */ + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [CardDispute] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: CardDispute) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + /** A pointer to a place in the list. */ + fun nextCursor(nextCursor: String?) = nextCursor(JsonField.ofNullable(nextCursor)) + + /** Alias for calling [Builder.nextCursor] with `nextCursor.orElse(null)`. */ + fun nextCursor(nextCursor: Optional) = nextCursor(nextCursor.getOrNull()) + + /** + * Sets [Builder.nextCursor] to an arbitrary JSON value. + * + * You should usually call [Builder.nextCursor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CardDisputeListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * .nextCursor() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardDisputeListPageResponse = + CardDisputeListPageResponse( + checkRequired("data", data).map { it.toImmutable() }, + checkRequired("nextCursor", nextCursor), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardDisputeListPageResponse = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + nextCursor() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextCursor.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardDisputeListPageResponse && + data == other.data && + nextCursor == other.nextCursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, nextCursor, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardDisputeListPageResponse{data=$data, nextCursor=$nextCursor, additionalProperties=$additionalProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListParams.kt new file mode 100644 index 000000000..cc5110c91 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeListParams.kt @@ -0,0 +1,810 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.fasterxml.jackson.annotation.JsonCreator +import com.increase.api.core.Enum +import com.increase.api.core.JsonField +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable +import com.increase.api.errors.IncreaseInvalidDataException +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Card Disputes */ +class CardDisputeListParams +private constructor( + private val createdAt: CreatedAt?, + private val cursor: String?, + private val idempotencyKey: String?, + private val limit: Long?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun createdAt(): Optional = Optional.ofNullable(createdAt) + + /** Return the page of entries after this one. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** + * Filter records to the one with the specified `idempotency_key` you chose for that object. + * This value is unique across Increase and is used to ensure that a request is only processed + * once. Learn more about [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(): Optional = Optional.ofNullable(idempotencyKey) + + /** Limit the size of the list that is returned. The default (and maximum) is 100 objects. */ + fun limit(): Optional = Optional.ofNullable(limit) + + fun status(): Optional = Optional.ofNullable(status) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardDisputeListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CardDisputeListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeListParams]. */ + class Builder internal constructor() { + + private var createdAt: CreatedAt? = null + private var cursor: String? = null + private var idempotencyKey: String? = null + private var limit: Long? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardDisputeListParams: CardDisputeListParams) = apply { + createdAt = cardDisputeListParams.createdAt + cursor = cardDisputeListParams.cursor + idempotencyKey = cardDisputeListParams.idempotencyKey + limit = cardDisputeListParams.limit + status = cardDisputeListParams.status + additionalHeaders = cardDisputeListParams.additionalHeaders.toBuilder() + additionalQueryParams = cardDisputeListParams.additionalQueryParams.toBuilder() + } + + fun createdAt(createdAt: CreatedAt?) = apply { this.createdAt = createdAt } + + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) + + /** Return the page of entries after this one. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Filter records to the one with the specified `idempotency_key` you chose for that object. + * This value is unique across Increase and is used to ensure that a request is only + * processed once. Learn more about + * [idempotency](https://increase.com/documentation/idempotency-keys). + */ + fun idempotencyKey(idempotencyKey: String?) = apply { this.idempotencyKey = idempotencyKey } + + /** Alias for calling [Builder.idempotencyKey] with `idempotencyKey.orElse(null)`. */ + fun idempotencyKey(idempotencyKey: Optional) = + idempotencyKey(idempotencyKey.getOrNull()) + + /** + * Limit the size of the list that is returned. The default (and maximum) is 100 objects. + */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardDisputeListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardDisputeListParams = + CardDisputeListParams( + createdAt, + cursor, + idempotencyKey, + limit, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + createdAt?.let { + it.after().ifPresent { + put("created_at.after", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + it.before().ifPresent { + put("created_at.before", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) + } + it.onOrAfter().ifPresent { + put( + "created_at.on_or_after", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), + ) + } + it.onOrBefore().ifPresent { + put( + "created_at.on_or_before", + DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it), + ) + } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("created_at.$key", value) + } + } + } + cursor?.let { put("cursor", it) } + idempotencyKey?.let { put("idempotency_key", it) } + limit?.let { put("limit", it.toString()) } + status?.let { + it.in_().ifPresent { put("status.in", it.joinToString(",") { it.toString() }) } + it._additionalProperties().keys().forEach { key -> + it._additionalProperties().values(key).forEach { value -> + put("status.$key", value) + } + } + } + putAll(additionalQueryParams) + } + .build() + + class CreatedAt + private constructor( + private val after: OffsetDateTime?, + private val before: OffsetDateTime?, + private val onOrAfter: OffsetDateTime?, + private val onOrBefore: OffsetDateTime?, + private val additionalProperties: QueryParams, + ) { + + /** + * Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. + */ + fun after(): Optional = Optional.ofNullable(after) + + /** + * Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp. + */ + fun before(): Optional = Optional.ofNullable(before) + + /** + * Return results on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrAfter(): Optional = Optional.ofNullable(onOrAfter) + + /** + * Return results on or before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrBefore(): Optional = Optional.ofNullable(onOrBefore) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CreatedAt]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreatedAt]. */ + class Builder internal constructor() { + + private var after: OffsetDateTime? = null + private var before: OffsetDateTime? = null + private var onOrAfter: OffsetDateTime? = null + private var onOrBefore: OffsetDateTime? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(createdAt: CreatedAt) = apply { + after = createdAt.after + before = createdAt.before + onOrAfter = createdAt.onOrAfter + onOrBefore = createdAt.onOrBefore + additionalProperties = createdAt.additionalProperties.toBuilder() + } + + /** + * Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun after(after: OffsetDateTime?) = apply { this.after = after } + + /** Alias for calling [Builder.after] with `after.orElse(null)`. */ + fun after(after: Optional) = after(after.getOrNull()) + + /** + * Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun before(before: OffsetDateTime?) = apply { this.before = before } + + /** Alias for calling [Builder.before] with `before.orElse(null)`. */ + fun before(before: Optional) = before(before.getOrNull()) + + /** + * Return results on or after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrAfter(onOrAfter: OffsetDateTime?) = apply { this.onOrAfter = onOrAfter } + + /** Alias for calling [Builder.onOrAfter] with `onOrAfter.orElse(null)`. */ + fun onOrAfter(onOrAfter: Optional) = onOrAfter(onOrAfter.getOrNull()) + + /** + * Return results on or before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) + * timestamp. + */ + fun onOrBefore(onOrBefore: OffsetDateTime?) = apply { this.onOrBefore = onOrBefore } + + /** Alias for calling [Builder.onOrBefore] with `onOrBefore.orElse(null)`. */ + fun onOrBefore(onOrBefore: Optional) = + onOrBefore(onOrBefore.getOrNull()) + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [CreatedAt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreatedAt = + CreatedAt(after, before, onOrAfter, onOrBefore, additionalProperties.build()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreatedAt && + after == other.after && + before == other.before && + onOrAfter == other.onOrAfter && + onOrBefore == other.onOrBefore && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(after, before, onOrAfter, onOrBefore, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreatedAt{after=$after, before=$before, onOrAfter=$onOrAfter, onOrBefore=$onOrBefore, additionalProperties=$additionalProperties}" + } + + class Status + private constructor(private val in_: List?, private val additionalProperties: QueryParams) { + + /** + * Filter Card Disputes for those with the specified status or statuses. For GET requests, + * this should be encoded as a comma-delimited string, such as `?in=one,two,three`. + */ + fun in_(): Optional> = Optional.ofNullable(in_) + + /** Query params to send with the request. */ + fun _additionalProperties(): QueryParams = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Status]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Status]. */ + class Builder internal constructor() { + + private var in_: MutableList? = null + private var additionalProperties: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(status: Status) = apply { + in_ = status.in_?.toMutableList() + additionalProperties = status.additionalProperties.toBuilder() + } + + /** + * Filter Card Disputes for those with the specified status or statuses. For GET + * requests, this should be encoded as a comma-delimited string, such as + * `?in=one,two,three`. + */ + fun in_(in_: List?) = apply { this.in_ = in_?.toMutableList() } + + /** Alias for calling [Builder.in_] with `in_.orElse(null)`. */ + fun in_(in_: Optional>) = in_(in_.getOrNull()) + + /** + * Adds a single [In] to [Builder.in_]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIn(in_: In) = apply { + this.in_ = (this.in_ ?: mutableListOf()).apply { add(in_) } + } + + fun additionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun additionalProperties(additionalProperties: Map>) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: String) = apply { + additionalProperties.put(key, value) + } + + fun putAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.put(key, values) + } + + fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun putAllAdditionalProperties(additionalProperties: Map>) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun replaceAdditionalProperties(key: String, value: String) = apply { + additionalProperties.replace(key, value) + } + + fun replaceAdditionalProperties(key: String, values: Iterable) = apply { + additionalProperties.replace(key, values) + } + + fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply { + this.additionalProperties.replaceAll(additionalProperties) + } + + fun replaceAllAdditionalProperties( + additionalProperties: Map> + ) = apply { this.additionalProperties.replaceAll(additionalProperties) } + + fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + additionalProperties.removeAll(keys) + } + + /** + * Returns an immutable instance of [Status]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Status = Status(in_?.toImmutable(), additionalProperties.build()) + } + + class In @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** A User Submission is required to continue with the Card Dispute. */ + @JvmField val USER_SUBMISSION_REQUIRED = of("user_submission_required") + + /** The most recent User Submission is being reviewed. */ + @JvmField + val PENDING_USER_SUBMISSION_REVIEWING = of("pending_user_submission_reviewing") + + /** The most recent User Submission is being submitted to the network. */ + @JvmField + val PENDING_USER_SUBMISSION_SUBMITTING = of("pending_user_submission_submitting") + + /** The user's withdrawal of the Card Dispute is being submitted to the network. */ + @JvmField + val PENDING_USER_WITHDRAWAL_SUBMITTING = of("pending_user_withdrawal_submitting") + + /** The Card Dispute is pending a response from the network. */ + @JvmField val PENDING_RESPONSE = of("pending_response") + + /** + * The Card Dispute has been lost and funds previously credited from the acceptance + * have been debited. + */ + @JvmField val LOST = of("lost") + + /** The Card Dispute has been won and no further action can be taken. */ + @JvmField val WON = of("won") + + @JvmStatic fun of(value: String) = In(JsonField.of(value)) + } + + /** An enum containing [In]'s known values. */ + enum class Known { + /** A User Submission is required to continue with the Card Dispute. */ + USER_SUBMISSION_REQUIRED, + /** The most recent User Submission is being reviewed. */ + PENDING_USER_SUBMISSION_REVIEWING, + /** The most recent User Submission is being submitted to the network. */ + PENDING_USER_SUBMISSION_SUBMITTING, + /** The user's withdrawal of the Card Dispute is being submitted to the network. */ + PENDING_USER_WITHDRAWAL_SUBMITTING, + /** The Card Dispute is pending a response from the network. */ + PENDING_RESPONSE, + /** + * The Card Dispute has been lost and funds previously credited from the acceptance + * have been debited. + */ + LOST, + /** The Card Dispute has been won and no further action can be taken. */ + WON, + } + + /** + * An enum containing [In]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [In] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** A User Submission is required to continue with the Card Dispute. */ + USER_SUBMISSION_REQUIRED, + /** The most recent User Submission is being reviewed. */ + PENDING_USER_SUBMISSION_REVIEWING, + /** The most recent User Submission is being submitted to the network. */ + PENDING_USER_SUBMISSION_SUBMITTING, + /** The user's withdrawal of the Card Dispute is being submitted to the network. */ + PENDING_USER_WITHDRAWAL_SUBMITTING, + /** The Card Dispute is pending a response from the network. */ + PENDING_RESPONSE, + /** + * The Card Dispute has been lost and funds previously credited from the acceptance + * have been debited. + */ + LOST, + /** The Card Dispute has been won and no further action can be taken. */ + WON, + /** An enum member indicating that [In] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USER_SUBMISSION_REQUIRED -> Value.USER_SUBMISSION_REQUIRED + PENDING_USER_SUBMISSION_REVIEWING -> Value.PENDING_USER_SUBMISSION_REVIEWING + PENDING_USER_SUBMISSION_SUBMITTING -> Value.PENDING_USER_SUBMISSION_SUBMITTING + PENDING_USER_WITHDRAWAL_SUBMITTING -> Value.PENDING_USER_WITHDRAWAL_SUBMITTING + PENDING_RESPONSE -> Value.PENDING_RESPONSE + LOST -> Value.LOST + WON -> Value.WON + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USER_SUBMISSION_REQUIRED -> Known.USER_SUBMISSION_REQUIRED + PENDING_USER_SUBMISSION_REVIEWING -> Known.PENDING_USER_SUBMISSION_REVIEWING + PENDING_USER_SUBMISSION_SUBMITTING -> Known.PENDING_USER_SUBMISSION_SUBMITTING + PENDING_USER_WITHDRAWAL_SUBMITTING -> Known.PENDING_USER_WITHDRAWAL_SUBMITTING + PENDING_RESPONSE -> Known.PENDING_RESPONSE + LOST -> Known.LOST + WON -> Known.WON + else -> throw IncreaseInvalidDataException("Unknown In: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): In = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is In && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && + in_ == other.in_ && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(in_, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Status{in_=$in_, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardDisputeListParams && + createdAt == other.createdAt && + cursor == other.cursor && + idempotencyKey == other.idempotencyKey && + limit == other.limit && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + createdAt, + cursor, + idempotencyKey, + limit, + status, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "CardDisputeListParams{createdAt=$createdAt, cursor=$cursor, idempotencyKey=$idempotencyKey, limit=$limit, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeRetrieveParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeRetrieveParams.kt new file mode 100644 index 000000000..2c014dad0 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeRetrieveParams.kt @@ -0,0 +1,199 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Retrieve a Card Dispute */ +class CardDisputeRetrieveParams +private constructor( + private val cardDisputeId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Card Dispute. */ + fun cardDisputeId(): Optional = Optional.ofNullable(cardDisputeId) + + /** 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(): CardDisputeRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CardDisputeRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeRetrieveParams]. */ + class Builder internal constructor() { + + private var cardDisputeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardDisputeRetrieveParams: CardDisputeRetrieveParams) = apply { + cardDisputeId = cardDisputeRetrieveParams.cardDisputeId + additionalHeaders = cardDisputeRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = cardDisputeRetrieveParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Card Dispute. */ + fun cardDisputeId(cardDisputeId: String?) = apply { this.cardDisputeId = cardDisputeId } + + /** Alias for calling [Builder.cardDisputeId] with `cardDisputeId.orElse(null)`. */ + fun cardDisputeId(cardDisputeId: Optional) = + cardDisputeId(cardDisputeId.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 [CardDisputeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardDisputeRetrieveParams = + CardDisputeRetrieveParams( + cardDisputeId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardDisputeId ?: "" + 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 CardDisputeRetrieveParams && + cardDisputeId == other.cardDisputeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cardDisputeId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardDisputeRetrieveParams{cardDisputeId=$cardDisputeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeSubmitUserSubmissionParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeSubmitUserSubmissionParams.kt new file mode 100644 index 000000000..d70b15821 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeSubmitUserSubmissionParams.kt @@ -0,0 +1,27057 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.increase.api.core.Enum +import com.increase.api.core.ExcludeMissing +import com.increase.api.core.JsonField +import com.increase.api.core.JsonMissing +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.checkKnown +import com.increase.api.core.checkRequired +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable +import com.increase.api.errors.IncreaseInvalidDataException +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Submit a User Submission for a Card Dispute */ +class CardDisputeSubmitUserSubmissionParams +private constructor( + private val cardDisputeId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Card Dispute to submit a user submission for. */ + fun cardDisputeId(): Optional = Optional.ofNullable(cardDisputeId) + + /** + * The network of the Card Dispute. Details specific to the network are required under the + * sub-object with the same identifier as the network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): Network = body.network() + + /** + * The adjusted monetary amount of the part of the transaction that is being disputed. This is + * optional and will default to the most recent amount provided. If provided, the amount must be + * less than or equal to the amount of the transaction. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = body.amount() + + /** + * The files to be attached to the user submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attachmentFiles(): Optional> = body.attachmentFiles() + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is `visa`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun visa(): Optional = body.visa() + + /** + * Returns the raw JSON value of [network]. + * + * Unlike [network], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _network(): JsonField = body._network() + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _amount(): JsonField = body._amount() + + /** + * Returns the raw JSON value of [attachmentFiles]. + * + * Unlike [attachmentFiles], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _attachmentFiles(): JsonField> = body._attachmentFiles() + + /** + * Returns the raw JSON value of [visa]. + * + * Unlike [visa], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _visa(): JsonField = body._visa() + + 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 + * [CardDisputeSubmitUserSubmissionParams]. + * + * The following fields are required: + * ```java + * .network() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeSubmitUserSubmissionParams]. */ + class Builder internal constructor() { + + private var cardDisputeId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + cardDisputeSubmitUserSubmissionParams: CardDisputeSubmitUserSubmissionParams + ) = apply { + cardDisputeId = cardDisputeSubmitUserSubmissionParams.cardDisputeId + body = cardDisputeSubmitUserSubmissionParams.body.toBuilder() + additionalHeaders = cardDisputeSubmitUserSubmissionParams.additionalHeaders.toBuilder() + additionalQueryParams = + cardDisputeSubmitUserSubmissionParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Card Dispute to submit a user submission for. */ + fun cardDisputeId(cardDisputeId: String?) = apply { this.cardDisputeId = cardDisputeId } + + /** Alias for calling [Builder.cardDisputeId] with `cardDisputeId.orElse(null)`. */ + fun cardDisputeId(cardDisputeId: Optional) = + cardDisputeId(cardDisputeId.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: + * - [network] + * - [amount] + * - [attachmentFiles] + * - [visa] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The network of the Card Dispute. Details specific to the network are required under the + * sub-object with the same identifier as the network. + */ + fun network(network: Network) = apply { body.network(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 { body.network(network) } + + /** + * The adjusted monetary amount of the part of the transaction that is being disputed. This + * is optional and will default to the most recent amount provided. If provided, the amount + * must be less than or equal to the amount of the transaction. + */ + fun amount(amount: Long) = apply { body.amount(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 { body.amount(amount) } + + /** The files to be attached to the user submission. */ + fun attachmentFiles(attachmentFiles: List) = apply { + body.attachmentFiles(attachmentFiles) + } + + /** + * Sets [Builder.attachmentFiles] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentFiles] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun attachmentFiles(attachmentFiles: JsonField>) = apply { + body.attachmentFiles(attachmentFiles) + } + + /** + * Adds a single [AttachmentFile] to [attachmentFiles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAttachmentFile(attachmentFile: AttachmentFile) = apply { + body.addAttachmentFile(attachmentFile) + } + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is + * `visa`. + */ + fun visa(visa: Visa) = apply { body.visa(visa) } + + /** + * Sets [Builder.visa] to an arbitrary JSON value. + * + * You should usually call [Builder.visa] with a well-typed [Visa] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun visa(visa: JsonField) = apply { body.visa(visa) } + + 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 [CardDisputeSubmitUserSubmissionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .network() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardDisputeSubmitUserSubmissionParams = + CardDisputeSubmitUserSubmissionParams( + cardDisputeId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardDisputeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val network: JsonField, + private val amount: JsonField, + private val attachmentFiles: JsonField>, + private val visa: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("network") @ExcludeMissing network: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attachment_files") + @ExcludeMissing + attachmentFiles: JsonField> = JsonMissing.of(), + @JsonProperty("visa") @ExcludeMissing visa: JsonField = JsonMissing.of(), + ) : this(network, amount, attachmentFiles, visa, mutableMapOf()) + + /** + * The network of the Card Dispute. Details specific to the network are required under the + * sub-object with the same identifier as the network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): Network = network.getRequired("network") + + /** + * The adjusted monetary amount of the part of the transaction that is being disputed. This + * is optional and will default to the most recent amount provided. If provided, the amount + * must be less than or equal to the amount of the transaction. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The files to be attached to the user submission. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun attachmentFiles(): Optional> = + attachmentFiles.getOptional("attachment_files") + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is + * `visa`. + * + * @throws IncreaseInvalidDataException 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 [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 [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 [attachmentFiles]. + * + * Unlike [attachmentFiles], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attachment_files") + @ExcludeMissing + fun _attachmentFiles(): JsonField> = attachmentFiles + + /** + * 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 [Body]. + * + * The following fields are required: + * ```java + * .network() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var network: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var attachmentFiles: JsonField>? = null + private var visa: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + network = body.network + amount = body.amount + attachmentFiles = body.attachmentFiles.map { it.toMutableList() } + visa = body.visa + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The network of the Card Dispute. Details specific to the network are required under + * the sub-object with the same identifier as the network. + */ + 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 } + + /** + * The adjusted monetary amount of the part of the transaction that is being disputed. + * This is optional and will default to the most recent amount provided. If provided, + * the amount must be less than or equal to the amount of the transaction. + */ + 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 files to be attached to the user submission. */ + fun attachmentFiles(attachmentFiles: List) = + attachmentFiles(JsonField.of(attachmentFiles)) + + /** + * Sets [Builder.attachmentFiles] to an arbitrary JSON value. + * + * You should usually call [Builder.attachmentFiles] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attachmentFiles(attachmentFiles: JsonField>) = apply { + this.attachmentFiles = attachmentFiles.map { it.toMutableList() } + } + + /** + * Adds a single [AttachmentFile] to [attachmentFiles]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAttachmentFile(attachmentFile: AttachmentFile) = apply { + attachmentFiles = + (attachmentFiles ?: JsonField.of(mutableListOf())).also { + checkKnown("attachmentFiles", it).add(attachmentFile) + } + } + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is + * `visa`. + */ + fun visa(visa: Visa) = visa(JsonField.of(visa)) + + /** + * Sets [Builder.visa] to an arbitrary JSON value. + * + * You should usually call [Builder.visa] with a well-typed [Visa] 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .network() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("network", network), + amount, + (attachmentFiles ?: JsonMissing.of()).map { it.toImmutable() }, + visa, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + network().validate() + amount() + attachmentFiles().ifPresent { it.forEach { it.validate() } } + visa().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (network.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attachmentFiles.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (visa.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + network == other.network && + amount == other.amount && + attachmentFiles == other.attachmentFiles && + visa == other.visa && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(network, amount, attachmentFiles, visa, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{network=$network, amount=$amount, attachmentFiles=$attachmentFiles, visa=$visa, additionalProperties=$additionalProperties}" + } + + /** + * The network of the Card Dispute. Details specific to the network are required under the + * sub-object with the same identifier as the network. + */ + 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 { + + /** Visa */ + @JvmField val VISA = of("visa") + + @JvmStatic fun of(value: String) = Network(JsonField.of(value)) + } + + /** An enum containing [Network]'s known values. */ + enum class Known { + /** Visa */ + 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 { + /** Visa */ + 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) { + 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 IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VISA -> Known.VISA + else -> throw IncreaseInvalidDataException("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 IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Network = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Network && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class AttachmentFile + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of() + ) : this(fileId, mutableMapOf()) + + /** + * The ID of the file to be attached. The file must have a `purpose` of + * `card_dispute_attachment`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fileId(): String = fileId.getRequired("file_id") + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + @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 [AttachmentFile]. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AttachmentFile]. */ + class Builder internal constructor() { + + private var fileId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attachmentFile: AttachmentFile) = apply { + fileId = attachmentFile.fileId + additionalProperties = attachmentFile.additionalProperties.toMutableMap() + } + + /** + * The ID of the file to be attached. The file must have a `purpose` of + * `card_dispute_attachment`. + */ + fun fileId(fileId: String) = fileId(JsonField.of(fileId)) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + 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 [AttachmentFile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AttachmentFile = + AttachmentFile(checkRequired("fileId", fileId), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AttachmentFile = apply { + if (validated) { + return@apply + } + + fileId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (fileId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttachmentFile && + fileId == other.fileId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fileId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AttachmentFile{fileId=$fileId, additionalProperties=$additionalProperties}" + } + + /** + * The Visa-specific parameters for the dispute. Required if and only if `network` is `visa`. + */ + class Visa + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val category: JsonField, + private val chargeback: JsonField, + private val merchantPrearbitrationDecline: JsonField, + private val userPrearbitration: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("chargeback") + @ExcludeMissing + chargeback: JsonField = JsonMissing.of(), + @JsonProperty("merchant_prearbitration_decline") + @ExcludeMissing + merchantPrearbitrationDecline: JsonField = + JsonMissing.of(), + @JsonProperty("user_prearbitration") + @ExcludeMissing + userPrearbitration: JsonField = JsonMissing.of(), + ) : this( + category, + chargeback, + merchantPrearbitrationDecline, + userPrearbitration, + mutableMapOf(), + ) + + /** + * The category of the user submission. Details specific to the category are required under + * the sub-object with the same identifier as the category. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun category(): Category = category.getRequired("category") + + /** + * The chargeback details for the user submission. Required if and only if `category` is + * `chargeback`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun chargeback(): Optional = chargeback.getOptional("chargeback") + + /** + * The merchant pre-arbitration decline details for the user submission. Required if and + * only if `category` is `merchant_prearbitration_decline`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantPrearbitrationDecline(): Optional = + merchantPrearbitrationDecline.getOptional("merchant_prearbitration_decline") + + /** + * The user pre-arbitration details for the user submission. Required if and only if + * `category` is `user_prearbitration`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun userPrearbitration(): Optional = + userPrearbitration.getOptional("user_prearbitration") + + /** + * 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 [chargeback]. + * + * Unlike [chargeback], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("chargeback") + @ExcludeMissing + fun _chargeback(): JsonField = chargeback + + /** + * Returns the raw JSON value of [merchantPrearbitrationDecline]. + * + * Unlike [merchantPrearbitrationDecline], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_prearbitration_decline") + @ExcludeMissing + fun _merchantPrearbitrationDecline(): JsonField = + merchantPrearbitrationDecline + + /** + * Returns the raw JSON value of [userPrearbitration]. + * + * Unlike [userPrearbitration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("user_prearbitration") + @ExcludeMissing + fun _userPrearbitration(): JsonField = userPrearbitration + + @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 [Visa]. + * + * The following fields are required: + * ```java + * .category() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Visa]. */ + class Builder internal constructor() { + + private var category: JsonField? = null + private var chargeback: JsonField = JsonMissing.of() + private var merchantPrearbitrationDecline: JsonField = + JsonMissing.of() + private var userPrearbitration: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(visa: Visa) = apply { + category = visa.category + chargeback = visa.chargeback + merchantPrearbitrationDecline = visa.merchantPrearbitrationDecline + userPrearbitration = visa.userPrearbitration + additionalProperties = visa.additionalProperties.toMutableMap() + } + + /** + * The category of the user submission. Details specific to the category are required + * under the sub-object with the same identifier as the category. + */ + 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 } + + /** + * The chargeback details for the user submission. Required if and only if `category` is + * `chargeback`. + */ + fun chargeback(chargeback: Chargeback) = chargeback(JsonField.of(chargeback)) + + /** + * Sets [Builder.chargeback] to an arbitrary JSON value. + * + * You should usually call [Builder.chargeback] with a well-typed [Chargeback] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun chargeback(chargeback: JsonField) = apply { + this.chargeback = chargeback + } + + /** + * The merchant pre-arbitration decline details for the user submission. Required if and + * only if `category` is `merchant_prearbitration_decline`. + */ + fun merchantPrearbitrationDecline( + merchantPrearbitrationDecline: MerchantPrearbitrationDecline + ) = merchantPrearbitrationDecline(JsonField.of(merchantPrearbitrationDecline)) + + /** + * Sets [Builder.merchantPrearbitrationDecline] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantPrearbitrationDecline] with a well-typed + * [MerchantPrearbitrationDecline] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantPrearbitrationDecline( + merchantPrearbitrationDecline: JsonField + ) = apply { this.merchantPrearbitrationDecline = merchantPrearbitrationDecline } + + /** + * The user pre-arbitration details for the user submission. Required if and only if + * `category` is `user_prearbitration`. + */ + fun userPrearbitration(userPrearbitration: UserPrearbitration) = + userPrearbitration(JsonField.of(userPrearbitration)) + + /** + * Sets [Builder.userPrearbitration] to an arbitrary JSON value. + * + * You should usually call [Builder.userPrearbitration] with a well-typed + * [UserPrearbitration] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun userPrearbitration(userPrearbitration: JsonField) = apply { + this.userPrearbitration = userPrearbitration + } + + 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 [Visa]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .category() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Visa = + Visa( + checkRequired("category", category), + chargeback, + merchantPrearbitrationDecline, + userPrearbitration, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Visa = apply { + if (validated) { + return@apply + } + + category().validate() + chargeback().ifPresent { it.validate() } + merchantPrearbitrationDecline().ifPresent { it.validate() } + userPrearbitration().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (category.asKnown().getOrNull()?.validity() ?: 0) + + (chargeback.asKnown().getOrNull()?.validity() ?: 0) + + (merchantPrearbitrationDecline.asKnown().getOrNull()?.validity() ?: 0) + + (userPrearbitration.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The category of the user submission. Details specific to the category are required under + * the sub-object with the same identifier as the category. + */ + 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 { + + /** Chargeback. */ + @JvmField val CHARGEBACK = of("chargeback") + + /** Merchant pre-arbitration decline. */ + @JvmField + val MERCHANT_PREARBITRATION_DECLINE = of("merchant_prearbitration_decline") + + /** User pre-arbitration. */ + @JvmField val USER_PREARBITRATION = of("user_prearbitration") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** Chargeback. */ + CHARGEBACK, + /** Merchant pre-arbitration decline. */ + MERCHANT_PREARBITRATION_DECLINE, + /** User pre-arbitration. */ + USER_PREARBITRATION, + } + + /** + * 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 { + /** Chargeback. */ + CHARGEBACK, + /** Merchant pre-arbitration decline. */ + MERCHANT_PREARBITRATION_DECLINE, + /** User pre-arbitration. */ + USER_PREARBITRATION, + /** + * 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) { + CHARGEBACK -> Value.CHARGEBACK + MERCHANT_PREARBITRATION_DECLINE -> Value.MERCHANT_PREARBITRATION_DECLINE + USER_PREARBITRATION -> Value.USER_PREARBITRATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHARGEBACK -> Known.CHARGEBACK + MERCHANT_PREARBITRATION_DECLINE -> Known.MERCHANT_PREARBITRATION_DECLINE + USER_PREARBITRATION -> Known.USER_PREARBITRATION + else -> throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The chargeback details for the user submission. Required if and only if `category` is + * `chargeback`. + */ + class Chargeback + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val category: JsonField, + private val authorization: JsonField, + private val consumerCanceledMerchandise: JsonField, + private val consumerCanceledRecurringTransaction: + JsonField, + private val consumerCanceledServices: JsonField, + private val consumerCounterfeitMerchandise: JsonField, + private val consumerCreditNotProcessed: JsonField, + private val consumerDamagedOrDefectiveMerchandise: + JsonField, + private val consumerMerchandiseMisrepresentation: + JsonField, + private val consumerMerchandiseNotAsDescribed: + JsonField, + private val consumerMerchandiseNotReceived: JsonField, + private val consumerNonReceiptOfCash: JsonValue, + private val consumerOriginalCreditTransactionNotAccepted: + JsonField, + private val consumerQualityMerchandise: JsonField, + private val consumerQualityServices: JsonField, + private val consumerServicesMisrepresentation: + JsonField, + private val consumerServicesNotAsDescribed: JsonField, + private val consumerServicesNotReceived: JsonField, + private val fraud: JsonField, + private val processingError: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("authorization") + @ExcludeMissing + authorization: JsonField = JsonMissing.of(), + @JsonProperty("consumer_canceled_merchandise") + @ExcludeMissing + consumerCanceledMerchandise: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_canceled_recurring_transaction") + @ExcludeMissing + consumerCanceledRecurringTransaction: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_canceled_services") + @ExcludeMissing + consumerCanceledServices: JsonField = JsonMissing.of(), + @JsonProperty("consumer_counterfeit_merchandise") + @ExcludeMissing + consumerCounterfeitMerchandise: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_credit_not_processed") + @ExcludeMissing + consumerCreditNotProcessed: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_damaged_or_defective_merchandise") + @ExcludeMissing + consumerDamagedOrDefectiveMerchandise: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_misrepresentation") + @ExcludeMissing + consumerMerchandiseMisrepresentation: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_not_as_described") + @ExcludeMissing + consumerMerchandiseNotAsDescribed: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_merchandise_not_received") + @ExcludeMissing + consumerMerchandiseNotReceived: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_non_receipt_of_cash") + @ExcludeMissing + consumerNonReceiptOfCash: JsonValue = JsonMissing.of(), + @JsonProperty("consumer_original_credit_transaction_not_accepted") + @ExcludeMissing + consumerOriginalCreditTransactionNotAccepted: + JsonField = + JsonMissing.of(), + @JsonProperty("consumer_quality_merchandise") + @ExcludeMissing + consumerQualityMerchandise: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_quality_services") + @ExcludeMissing + consumerQualityServices: JsonField = JsonMissing.of(), + @JsonProperty("consumer_services_misrepresentation") + @ExcludeMissing + consumerServicesMisrepresentation: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_services_not_as_described") + @ExcludeMissing + consumerServicesNotAsDescribed: JsonField = + JsonMissing.of(), + @JsonProperty("consumer_services_not_received") + @ExcludeMissing + consumerServicesNotReceived: JsonField = + JsonMissing.of(), + @JsonProperty("fraud") @ExcludeMissing fraud: JsonField = JsonMissing.of(), + @JsonProperty("processing_error") + @ExcludeMissing + processingError: JsonField = JsonMissing.of(), + ) : this( + category, + authorization, + consumerCanceledMerchandise, + consumerCanceledRecurringTransaction, + consumerCanceledServices, + consumerCounterfeitMerchandise, + consumerCreditNotProcessed, + consumerDamagedOrDefectiveMerchandise, + consumerMerchandiseMisrepresentation, + consumerMerchandiseNotAsDescribed, + consumerMerchandiseNotReceived, + consumerNonReceiptOfCash, + consumerOriginalCreditTransactionNotAccepted, + consumerQualityMerchandise, + consumerQualityServices, + consumerServicesMisrepresentation, + consumerServicesNotAsDescribed, + consumerServicesNotReceived, + fraud, + processingError, + mutableMapOf(), + ) + + /** + * Category. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun category(): Category = category.getRequired("category") + + /** + * Authorization. Required if and only if `category` is `authorization`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun authorization(): Optional = + authorization.getOptional("authorization") + + /** + * Canceled merchandise. Required if and only if `category` is + * `consumer_canceled_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerCanceledMerchandise(): Optional = + consumerCanceledMerchandise.getOptional("consumer_canceled_merchandise") + + /** + * Canceled recurring transaction. Required if and only if `category` is + * `consumer_canceled_recurring_transaction`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerCanceledRecurringTransaction(): + Optional = + consumerCanceledRecurringTransaction.getOptional( + "consumer_canceled_recurring_transaction" + ) + + /** + * Canceled services. Required if and only if `category` is + * `consumer_canceled_services`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerCanceledServices(): Optional = + consumerCanceledServices.getOptional("consumer_canceled_services") + + /** + * Counterfeit merchandise. Required if and only if `category` is + * `consumer_counterfeit_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerCounterfeitMerchandise(): Optional = + consumerCounterfeitMerchandise.getOptional("consumer_counterfeit_merchandise") + + /** + * Credit not processed. Required if and only if `category` is + * `consumer_credit_not_processed`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerCreditNotProcessed(): Optional = + consumerCreditNotProcessed.getOptional("consumer_credit_not_processed") + + /** + * Damaged or defective merchandise. Required if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerDamagedOrDefectiveMerchandise(): + Optional = + consumerDamagedOrDefectiveMerchandise.getOptional( + "consumer_damaged_or_defective_merchandise" + ) + + /** + * Merchandise misrepresentation. Required if and only if `category` is + * `consumer_merchandise_misrepresentation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerMerchandiseMisrepresentation(): + Optional = + consumerMerchandiseMisrepresentation.getOptional( + "consumer_merchandise_misrepresentation" + ) + + /** + * Merchandise not as described. Required if and only if `category` is + * `consumer_merchandise_not_as_described`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerMerchandiseNotAsDescribed(): Optional = + consumerMerchandiseNotAsDescribed.getOptional( + "consumer_merchandise_not_as_described" + ) + + /** + * Merchandise not received. Required if and only if `category` is + * `consumer_merchandise_not_received`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerMerchandiseNotReceived(): Optional = + consumerMerchandiseNotReceived.getOptional("consumer_merchandise_not_received") + + /** + * Non-receipt of cash. Required if and only if `category` is + * `consumer_non_receipt_of_cash`. + */ + @JsonProperty("consumer_non_receipt_of_cash") + @ExcludeMissing + fun _consumerNonReceiptOfCash(): JsonValue = consumerNonReceiptOfCash + + /** + * Original Credit Transaction (OCT) not accepted. Required if and only if `category` is + * `consumer_original_credit_transaction_not_accepted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerOriginalCreditTransactionNotAccepted(): + Optional = + consumerOriginalCreditTransactionNotAccepted.getOptional( + "consumer_original_credit_transaction_not_accepted" + ) + + /** + * Merchandise quality issue. Required if and only if `category` is + * `consumer_quality_merchandise`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerQualityMerchandise(): Optional = + consumerQualityMerchandise.getOptional("consumer_quality_merchandise") + + /** + * Services quality issue. Required if and only if `category` is + * `consumer_quality_services`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerQualityServices(): Optional = + consumerQualityServices.getOptional("consumer_quality_services") + + /** + * Services misrepresentation. Required if and only if `category` is + * `consumer_services_misrepresentation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerServicesMisrepresentation(): Optional = + consumerServicesMisrepresentation.getOptional("consumer_services_misrepresentation") + + /** + * Services not as described. Required if and only if `category` is + * `consumer_services_not_as_described`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerServicesNotAsDescribed(): Optional = + consumerServicesNotAsDescribed.getOptional("consumer_services_not_as_described") + + /** + * Services not received. Required if and only if `category` is + * `consumer_services_not_received`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun consumerServicesNotReceived(): Optional = + consumerServicesNotReceived.getOptional("consumer_services_not_received") + + /** + * Fraud. Required if and only if `category` is `fraud`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun fraud(): Optional = fraud.getOptional("fraud") + + /** + * Processing error. Required if and only if `category` is `processing_error`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun processingError(): Optional = + processingError.getOptional("processing_error") + + /** + * 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 [authorization]. + * + * Unlike [authorization], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("authorization") + @ExcludeMissing + fun _authorization(): JsonField = authorization + + /** + * Returns the raw JSON value of [consumerCanceledMerchandise]. + * + * Unlike [consumerCanceledMerchandise], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumer_canceled_merchandise") + @ExcludeMissing + fun _consumerCanceledMerchandise(): JsonField = + consumerCanceledMerchandise + + /** + * Returns the raw JSON value of [consumerCanceledRecurringTransaction]. + * + * Unlike [consumerCanceledRecurringTransaction], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_canceled_recurring_transaction") + @ExcludeMissing + fun _consumerCanceledRecurringTransaction(): + JsonField = + consumerCanceledRecurringTransaction + + /** + * Returns the raw JSON value of [consumerCanceledServices]. + * + * Unlike [consumerCanceledServices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumer_canceled_services") + @ExcludeMissing + fun _consumerCanceledServices(): JsonField = + consumerCanceledServices + + /** + * Returns the raw JSON value of [consumerCounterfeitMerchandise]. + * + * Unlike [consumerCounterfeitMerchandise], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_counterfeit_merchandise") + @ExcludeMissing + fun _consumerCounterfeitMerchandise(): JsonField = + consumerCounterfeitMerchandise + + /** + * Returns the raw JSON value of [consumerCreditNotProcessed]. + * + * Unlike [consumerCreditNotProcessed], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumer_credit_not_processed") + @ExcludeMissing + fun _consumerCreditNotProcessed(): JsonField = + consumerCreditNotProcessed + + /** + * Returns the raw JSON value of [consumerDamagedOrDefectiveMerchandise]. + * + * Unlike [consumerDamagedOrDefectiveMerchandise], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_damaged_or_defective_merchandise") + @ExcludeMissing + fun _consumerDamagedOrDefectiveMerchandise(): + JsonField = + consumerDamagedOrDefectiveMerchandise + + /** + * Returns the raw JSON value of [consumerMerchandiseMisrepresentation]. + * + * Unlike [consumerMerchandiseMisrepresentation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_merchandise_misrepresentation") + @ExcludeMissing + fun _consumerMerchandiseMisrepresentation(): + JsonField = + consumerMerchandiseMisrepresentation + + /** + * Returns the raw JSON value of [consumerMerchandiseNotAsDescribed]. + * + * Unlike [consumerMerchandiseNotAsDescribed], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_merchandise_not_as_described") + @ExcludeMissing + fun _consumerMerchandiseNotAsDescribed(): JsonField = + consumerMerchandiseNotAsDescribed + + /** + * Returns the raw JSON value of [consumerMerchandiseNotReceived]. + * + * Unlike [consumerMerchandiseNotReceived], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_merchandise_not_received") + @ExcludeMissing + fun _consumerMerchandiseNotReceived(): JsonField = + consumerMerchandiseNotReceived + + /** + * Returns the raw JSON value of [consumerOriginalCreditTransactionNotAccepted]. + * + * Unlike [consumerOriginalCreditTransactionNotAccepted], this method doesn't throw if + * the JSON field has an unexpected type. + */ + @JsonProperty("consumer_original_credit_transaction_not_accepted") + @ExcludeMissing + fun _consumerOriginalCreditTransactionNotAccepted(): + JsonField = + consumerOriginalCreditTransactionNotAccepted + + /** + * Returns the raw JSON value of [consumerQualityMerchandise]. + * + * Unlike [consumerQualityMerchandise], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumer_quality_merchandise") + @ExcludeMissing + fun _consumerQualityMerchandise(): JsonField = + consumerQualityMerchandise + + /** + * Returns the raw JSON value of [consumerQualityServices]. + * + * Unlike [consumerQualityServices], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("consumer_quality_services") + @ExcludeMissing + fun _consumerQualityServices(): JsonField = + consumerQualityServices + + /** + * Returns the raw JSON value of [consumerServicesMisrepresentation]. + * + * Unlike [consumerServicesMisrepresentation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("consumer_services_misrepresentation") + @ExcludeMissing + fun _consumerServicesMisrepresentation(): JsonField = + consumerServicesMisrepresentation + + /** + * Returns the raw JSON value of [consumerServicesNotAsDescribed]. + * + * Unlike [consumerServicesNotAsDescribed], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_services_not_as_described") + @ExcludeMissing + fun _consumerServicesNotAsDescribed(): JsonField = + consumerServicesNotAsDescribed + + /** + * Returns the raw JSON value of [consumerServicesNotReceived]. + * + * Unlike [consumerServicesNotReceived], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("consumer_services_not_received") + @ExcludeMissing + fun _consumerServicesNotReceived(): JsonField = + consumerServicesNotReceived + + /** + * Returns the raw JSON value of [fraud]. + * + * Unlike [fraud], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fraud") @ExcludeMissing fun _fraud(): JsonField = fraud + + /** + * Returns the raw JSON value of [processingError]. + * + * Unlike [processingError], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("processing_error") + @ExcludeMissing + fun _processingError(): JsonField = processingError + + @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 [Chargeback]. + * + * The following fields are required: + * ```java + * .category() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Chargeback]. */ + class Builder internal constructor() { + + private var category: JsonField? = null + private var authorization: JsonField = JsonMissing.of() + private var consumerCanceledMerchandise: JsonField = + JsonMissing.of() + private var consumerCanceledRecurringTransaction: + JsonField = + JsonMissing.of() + private var consumerCanceledServices: JsonField = + JsonMissing.of() + private var consumerCounterfeitMerchandise: + JsonField = + JsonMissing.of() + private var consumerCreditNotProcessed: JsonField = + JsonMissing.of() + private var consumerDamagedOrDefectiveMerchandise: + JsonField = + JsonMissing.of() + private var consumerMerchandiseMisrepresentation: + JsonField = + JsonMissing.of() + private var consumerMerchandiseNotAsDescribed: + JsonField = + JsonMissing.of() + private var consumerMerchandiseNotReceived: + JsonField = + JsonMissing.of() + private var consumerNonReceiptOfCash: JsonValue = JsonMissing.of() + private var consumerOriginalCreditTransactionNotAccepted: + JsonField = + JsonMissing.of() + private var consumerQualityMerchandise: JsonField = + JsonMissing.of() + private var consumerQualityServices: JsonField = + JsonMissing.of() + private var consumerServicesMisrepresentation: + JsonField = + JsonMissing.of() + private var consumerServicesNotAsDescribed: + JsonField = + JsonMissing.of() + private var consumerServicesNotReceived: JsonField = + JsonMissing.of() + private var fraud: JsonField = JsonMissing.of() + private var processingError: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chargeback: Chargeback) = apply { + category = chargeback.category + authorization = chargeback.authorization + consumerCanceledMerchandise = chargeback.consumerCanceledMerchandise + consumerCanceledRecurringTransaction = + chargeback.consumerCanceledRecurringTransaction + consumerCanceledServices = chargeback.consumerCanceledServices + consumerCounterfeitMerchandise = chargeback.consumerCounterfeitMerchandise + consumerCreditNotProcessed = chargeback.consumerCreditNotProcessed + consumerDamagedOrDefectiveMerchandise = + chargeback.consumerDamagedOrDefectiveMerchandise + consumerMerchandiseMisrepresentation = + chargeback.consumerMerchandiseMisrepresentation + consumerMerchandiseNotAsDescribed = chargeback.consumerMerchandiseNotAsDescribed + consumerMerchandiseNotReceived = chargeback.consumerMerchandiseNotReceived + consumerNonReceiptOfCash = chargeback.consumerNonReceiptOfCash + consumerOriginalCreditTransactionNotAccepted = + chargeback.consumerOriginalCreditTransactionNotAccepted + consumerQualityMerchandise = chargeback.consumerQualityMerchandise + consumerQualityServices = chargeback.consumerQualityServices + consumerServicesMisrepresentation = chargeback.consumerServicesMisrepresentation + consumerServicesNotAsDescribed = chargeback.consumerServicesNotAsDescribed + consumerServicesNotReceived = chargeback.consumerServicesNotReceived + fraud = chargeback.fraud + processingError = chargeback.processingError + additionalProperties = chargeback.additionalProperties.toMutableMap() + } + + /** Category. */ + 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 } + + /** Authorization. Required if and only if `category` is `authorization`. */ + fun authorization(authorization: Authorization) = + authorization(JsonField.of(authorization)) + + /** + * Sets [Builder.authorization] to an arbitrary JSON value. + * + * You should usually call [Builder.authorization] with a well-typed [Authorization] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun authorization(authorization: JsonField) = apply { + this.authorization = authorization + } + + /** + * Canceled merchandise. Required if and only if `category` is + * `consumer_canceled_merchandise`. + */ + fun consumerCanceledMerchandise( + consumerCanceledMerchandise: ConsumerCanceledMerchandise + ) = consumerCanceledMerchandise(JsonField.of(consumerCanceledMerchandise)) + + /** + * Sets [Builder.consumerCanceledMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCanceledMerchandise] with a well-typed + * [ConsumerCanceledMerchandise] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerCanceledMerchandise( + consumerCanceledMerchandise: JsonField + ) = apply { this.consumerCanceledMerchandise = consumerCanceledMerchandise } + + /** + * Canceled recurring transaction. Required if and only if `category` is + * `consumer_canceled_recurring_transaction`. + */ + fun consumerCanceledRecurringTransaction( + consumerCanceledRecurringTransaction: ConsumerCanceledRecurringTransaction + ) = + consumerCanceledRecurringTransaction( + JsonField.of(consumerCanceledRecurringTransaction) + ) + + /** + * Sets [Builder.consumerCanceledRecurringTransaction] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCanceledRecurringTransaction] with a + * well-typed [ConsumerCanceledRecurringTransaction] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerCanceledRecurringTransaction( + consumerCanceledRecurringTransaction: + JsonField + ) = apply { + this.consumerCanceledRecurringTransaction = consumerCanceledRecurringTransaction + } + + /** + * Canceled services. Required if and only if `category` is + * `consumer_canceled_services`. + */ + fun consumerCanceledServices(consumerCanceledServices: ConsumerCanceledServices) = + consumerCanceledServices(JsonField.of(consumerCanceledServices)) + + /** + * Sets [Builder.consumerCanceledServices] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCanceledServices] with a well-typed + * [ConsumerCanceledServices] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerCanceledServices( + consumerCanceledServices: JsonField + ) = apply { this.consumerCanceledServices = consumerCanceledServices } + + /** + * Counterfeit merchandise. Required if and only if `category` is + * `consumer_counterfeit_merchandise`. + */ + fun consumerCounterfeitMerchandise( + consumerCounterfeitMerchandise: ConsumerCounterfeitMerchandise + ) = consumerCounterfeitMerchandise(JsonField.of(consumerCounterfeitMerchandise)) + + /** + * Sets [Builder.consumerCounterfeitMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCounterfeitMerchandise] with a + * well-typed [ConsumerCounterfeitMerchandise] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerCounterfeitMerchandise( + consumerCounterfeitMerchandise: JsonField + ) = apply { this.consumerCounterfeitMerchandise = consumerCounterfeitMerchandise } + + /** + * Credit not processed. Required if and only if `category` is + * `consumer_credit_not_processed`. + */ + fun consumerCreditNotProcessed( + consumerCreditNotProcessed: ConsumerCreditNotProcessed + ) = consumerCreditNotProcessed(JsonField.of(consumerCreditNotProcessed)) + + /** + * Sets [Builder.consumerCreditNotProcessed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerCreditNotProcessed] with a well-typed + * [ConsumerCreditNotProcessed] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerCreditNotProcessed( + consumerCreditNotProcessed: JsonField + ) = apply { this.consumerCreditNotProcessed = consumerCreditNotProcessed } + + /** + * Damaged or defective merchandise. Required if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + */ + fun consumerDamagedOrDefectiveMerchandise( + consumerDamagedOrDefectiveMerchandise: ConsumerDamagedOrDefectiveMerchandise + ) = + consumerDamagedOrDefectiveMerchandise( + JsonField.of(consumerDamagedOrDefectiveMerchandise) + ) + + /** + * Sets [Builder.consumerDamagedOrDefectiveMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerDamagedOrDefectiveMerchandise] with a + * well-typed [ConsumerDamagedOrDefectiveMerchandise] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerDamagedOrDefectiveMerchandise( + consumerDamagedOrDefectiveMerchandise: + JsonField + ) = apply { + this.consumerDamagedOrDefectiveMerchandise = + consumerDamagedOrDefectiveMerchandise + } + + /** + * Merchandise misrepresentation. Required if and only if `category` is + * `consumer_merchandise_misrepresentation`. + */ + fun consumerMerchandiseMisrepresentation( + consumerMerchandiseMisrepresentation: ConsumerMerchandiseMisrepresentation + ) = + consumerMerchandiseMisrepresentation( + JsonField.of(consumerMerchandiseMisrepresentation) + ) + + /** + * Sets [Builder.consumerMerchandiseMisrepresentation] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerMerchandiseMisrepresentation] with a + * well-typed [ConsumerMerchandiseMisrepresentation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerMerchandiseMisrepresentation( + consumerMerchandiseMisrepresentation: + JsonField + ) = apply { + this.consumerMerchandiseMisrepresentation = consumerMerchandiseMisrepresentation + } + + /** + * Merchandise not as described. Required if and only if `category` is + * `consumer_merchandise_not_as_described`. + */ + fun consumerMerchandiseNotAsDescribed( + consumerMerchandiseNotAsDescribed: ConsumerMerchandiseNotAsDescribed + ) = + consumerMerchandiseNotAsDescribed( + JsonField.of(consumerMerchandiseNotAsDescribed) + ) + + /** + * Sets [Builder.consumerMerchandiseNotAsDescribed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerMerchandiseNotAsDescribed] with a + * well-typed [ConsumerMerchandiseNotAsDescribed] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerMerchandiseNotAsDescribed( + consumerMerchandiseNotAsDescribed: JsonField + ) = apply { + this.consumerMerchandiseNotAsDescribed = consumerMerchandiseNotAsDescribed + } + + /** + * Merchandise not received. Required if and only if `category` is + * `consumer_merchandise_not_received`. + */ + fun consumerMerchandiseNotReceived( + consumerMerchandiseNotReceived: ConsumerMerchandiseNotReceived + ) = consumerMerchandiseNotReceived(JsonField.of(consumerMerchandiseNotReceived)) + + /** + * Sets [Builder.consumerMerchandiseNotReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerMerchandiseNotReceived] with a + * well-typed [ConsumerMerchandiseNotReceived] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerMerchandiseNotReceived( + consumerMerchandiseNotReceived: JsonField + ) = apply { this.consumerMerchandiseNotReceived = consumerMerchandiseNotReceived } + + /** + * Non-receipt of cash. Required if and only if `category` is + * `consumer_non_receipt_of_cash`. + */ + fun consumerNonReceiptOfCash(consumerNonReceiptOfCash: JsonValue) = apply { + this.consumerNonReceiptOfCash = consumerNonReceiptOfCash + } + + /** + * Original Credit Transaction (OCT) not accepted. Required if and only if + * `category` is `consumer_original_credit_transaction_not_accepted`. + */ + fun consumerOriginalCreditTransactionNotAccepted( + consumerOriginalCreditTransactionNotAccepted: + ConsumerOriginalCreditTransactionNotAccepted + ) = + consumerOriginalCreditTransactionNotAccepted( + JsonField.of(consumerOriginalCreditTransactionNotAccepted) + ) + + /** + * Sets [Builder.consumerOriginalCreditTransactionNotAccepted] to an arbitrary JSON + * value. + * + * You should usually call [Builder.consumerOriginalCreditTransactionNotAccepted] + * with a well-typed [ConsumerOriginalCreditTransactionNotAccepted] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun consumerOriginalCreditTransactionNotAccepted( + consumerOriginalCreditTransactionNotAccepted: + JsonField + ) = apply { + this.consumerOriginalCreditTransactionNotAccepted = + consumerOriginalCreditTransactionNotAccepted + } + + /** + * Merchandise quality issue. Required if and only if `category` is + * `consumer_quality_merchandise`. + */ + fun consumerQualityMerchandise( + consumerQualityMerchandise: ConsumerQualityMerchandise + ) = consumerQualityMerchandise(JsonField.of(consumerQualityMerchandise)) + + /** + * Sets [Builder.consumerQualityMerchandise] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerQualityMerchandise] with a well-typed + * [ConsumerQualityMerchandise] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerQualityMerchandise( + consumerQualityMerchandise: JsonField + ) = apply { this.consumerQualityMerchandise = consumerQualityMerchandise } + + /** + * Services quality issue. Required if and only if `category` is + * `consumer_quality_services`. + */ + fun consumerQualityServices(consumerQualityServices: ConsumerQualityServices) = + consumerQualityServices(JsonField.of(consumerQualityServices)) + + /** + * Sets [Builder.consumerQualityServices] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerQualityServices] with a well-typed + * [ConsumerQualityServices] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun consumerQualityServices( + consumerQualityServices: JsonField + ) = apply { this.consumerQualityServices = consumerQualityServices } + + /** + * Services misrepresentation. Required if and only if `category` is + * `consumer_services_misrepresentation`. + */ + fun consumerServicesMisrepresentation( + consumerServicesMisrepresentation: ConsumerServicesMisrepresentation + ) = + consumerServicesMisrepresentation( + JsonField.of(consumerServicesMisrepresentation) + ) + + /** + * Sets [Builder.consumerServicesMisrepresentation] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesMisrepresentation] with a + * well-typed [ConsumerServicesMisrepresentation] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerServicesMisrepresentation( + consumerServicesMisrepresentation: JsonField + ) = apply { + this.consumerServicesMisrepresentation = consumerServicesMisrepresentation + } + + /** + * Services not as described. Required if and only if `category` is + * `consumer_services_not_as_described`. + */ + fun consumerServicesNotAsDescribed( + consumerServicesNotAsDescribed: ConsumerServicesNotAsDescribed + ) = consumerServicesNotAsDescribed(JsonField.of(consumerServicesNotAsDescribed)) + + /** + * Sets [Builder.consumerServicesNotAsDescribed] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesNotAsDescribed] with a + * well-typed [ConsumerServicesNotAsDescribed] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun consumerServicesNotAsDescribed( + consumerServicesNotAsDescribed: JsonField + ) = apply { this.consumerServicesNotAsDescribed = consumerServicesNotAsDescribed } + + /** + * Services not received. Required if and only if `category` is + * `consumer_services_not_received`. + */ + fun consumerServicesNotReceived( + consumerServicesNotReceived: ConsumerServicesNotReceived + ) = consumerServicesNotReceived(JsonField.of(consumerServicesNotReceived)) + + /** + * Sets [Builder.consumerServicesNotReceived] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerServicesNotReceived] with a well-typed + * [ConsumerServicesNotReceived] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun consumerServicesNotReceived( + consumerServicesNotReceived: JsonField + ) = apply { this.consumerServicesNotReceived = consumerServicesNotReceived } + + /** Fraud. Required if and only if `category` is `fraud`. */ + fun fraud(fraud: Fraud) = fraud(JsonField.of(fraud)) + + /** + * Sets [Builder.fraud] to an arbitrary JSON value. + * + * You should usually call [Builder.fraud] with a well-typed [Fraud] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fraud(fraud: JsonField) = apply { this.fraud = fraud } + + /** Processing error. Required if and only if `category` is `processing_error`. */ + fun processingError(processingError: ProcessingError) = + processingError(JsonField.of(processingError)) + + /** + * Sets [Builder.processingError] to an arbitrary JSON value. + * + * You should usually call [Builder.processingError] with a well-typed + * [ProcessingError] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun processingError(processingError: JsonField) = apply { + this.processingError = processingError + } + + 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 [Chargeback]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .category() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Chargeback = + Chargeback( + checkRequired("category", category), + authorization, + consumerCanceledMerchandise, + consumerCanceledRecurringTransaction, + consumerCanceledServices, + consumerCounterfeitMerchandise, + consumerCreditNotProcessed, + consumerDamagedOrDefectiveMerchandise, + consumerMerchandiseMisrepresentation, + consumerMerchandiseNotAsDescribed, + consumerMerchandiseNotReceived, + consumerNonReceiptOfCash, + consumerOriginalCreditTransactionNotAccepted, + consumerQualityMerchandise, + consumerQualityServices, + consumerServicesMisrepresentation, + consumerServicesNotAsDescribed, + consumerServicesNotReceived, + fraud, + processingError, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Chargeback = apply { + if (validated) { + return@apply + } + + category().validate() + authorization().ifPresent { it.validate() } + consumerCanceledMerchandise().ifPresent { it.validate() } + consumerCanceledRecurringTransaction().ifPresent { it.validate() } + consumerCanceledServices().ifPresent { it.validate() } + consumerCounterfeitMerchandise().ifPresent { it.validate() } + consumerCreditNotProcessed().ifPresent { it.validate() } + consumerDamagedOrDefectiveMerchandise().ifPresent { it.validate() } + consumerMerchandiseMisrepresentation().ifPresent { it.validate() } + consumerMerchandiseNotAsDescribed().ifPresent { it.validate() } + consumerMerchandiseNotReceived().ifPresent { it.validate() } + consumerOriginalCreditTransactionNotAccepted().ifPresent { it.validate() } + consumerQualityMerchandise().ifPresent { it.validate() } + consumerQualityServices().ifPresent { it.validate() } + consumerServicesMisrepresentation().ifPresent { it.validate() } + consumerServicesNotAsDescribed().ifPresent { it.validate() } + consumerServicesNotReceived().ifPresent { it.validate() } + fraud().ifPresent { it.validate() } + processingError().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (category.asKnown().getOrNull()?.validity() ?: 0) + + (authorization.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCanceledMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCanceledRecurringTransaction.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCanceledServices.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCounterfeitMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerCreditNotProcessed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerDamagedOrDefectiveMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerMerchandiseMisrepresentation.asKnown().getOrNull()?.validity() ?: 0) + + (consumerMerchandiseNotAsDescribed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerMerchandiseNotReceived.asKnown().getOrNull()?.validity() ?: 0) + + (consumerOriginalCreditTransactionNotAccepted.asKnown().getOrNull()?.validity() + ?: 0) + + (consumerQualityMerchandise.asKnown().getOrNull()?.validity() ?: 0) + + (consumerQualityServices.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesMisrepresentation.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesNotAsDescribed.asKnown().getOrNull()?.validity() ?: 0) + + (consumerServicesNotReceived.asKnown().getOrNull()?.validity() ?: 0) + + (fraud.asKnown().getOrNull()?.validity() ?: 0) + + (processingError.asKnown().getOrNull()?.validity() ?: 0) + + /** Category. */ + 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 { + + /** Authorization. */ + @JvmField val AUTHORIZATION = of("authorization") + + /** Consumer: canceled merchandise. */ + @JvmField + val CONSUMER_CANCELED_MERCHANDISE = of("consumer_canceled_merchandise") + + /** Consumer: canceled recurring transaction. */ + @JvmField + val CONSUMER_CANCELED_RECURRING_TRANSACTION = + of("consumer_canceled_recurring_transaction") + + /** Consumer: canceled services. */ + @JvmField val CONSUMER_CANCELED_SERVICES = of("consumer_canceled_services") + + /** Consumer: counterfeit merchandise. */ + @JvmField + val CONSUMER_COUNTERFEIT_MERCHANDISE = of("consumer_counterfeit_merchandise") + + /** Consumer: credit not processed. */ + @JvmField + val CONSUMER_CREDIT_NOT_PROCESSED = of("consumer_credit_not_processed") + + /** Consumer: damaged or defective merchandise. */ + @JvmField + val CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE = + of("consumer_damaged_or_defective_merchandise") + + /** Consumer: merchandise misrepresentation. */ + @JvmField + val CONSUMER_MERCHANDISE_MISREPRESENTATION = + of("consumer_merchandise_misrepresentation") + + /** Consumer: merchandise not as described. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED = + of("consumer_merchandise_not_as_described") + + /** Consumer: merchandise not received. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_RECEIVED = of("consumer_merchandise_not_received") + + /** Consumer: non-receipt of cash. */ + @JvmField val CONSUMER_NON_RECEIPT_OF_CASH = of("consumer_non_receipt_of_cash") + + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + @JvmField + val CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED = + of("consumer_original_credit_transaction_not_accepted") + + /** Consumer: merchandise quality issue. */ + @JvmField val CONSUMER_QUALITY_MERCHANDISE = of("consumer_quality_merchandise") + + /** Consumer: services quality issue. */ + @JvmField val CONSUMER_QUALITY_SERVICES = of("consumer_quality_services") + + /** Consumer: services misrepresentation. */ + @JvmField + val CONSUMER_SERVICES_MISREPRESENTATION = + of("consumer_services_misrepresentation") + + /** Consumer: services not as described. */ + @JvmField + val CONSUMER_SERVICES_NOT_AS_DESCRIBED = + of("consumer_services_not_as_described") + + /** Consumer: services not received. */ + @JvmField + val CONSUMER_SERVICES_NOT_RECEIVED = of("consumer_services_not_received") + + /** Fraud. */ + @JvmField val FRAUD = of("fraud") + + /** Processing error. */ + @JvmField val PROCESSING_ERROR = of("processing_error") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + } + + /** + * 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 { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + /** + * 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) { + AUTHORIZATION -> Value.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Value.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Value.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Value.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> Value.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Value.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Value.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Value.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Value.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> Value.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Value.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Value.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Value.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Value.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> + Value.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> + Value.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> Value.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Value.FRAUD + PROCESSING_ERROR -> Value.PROCESSING_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 IncreaseInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AUTHORIZATION -> Known.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Known.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Known.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Known.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> Known.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Known.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Known.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Known.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Known.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> Known.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Known.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Known.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Known.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Known.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> + Known.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> + Known.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> Known.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Known.FRAUD + PROCESSING_ERROR -> Known.PROCESSING_ERROR + else -> throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Authorization. Required if and only if `category` is `authorization`. */ + class Authorization + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accountStatus: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_status") + @ExcludeMissing + accountStatus: JsonField = JsonMissing.of() + ) : this(accountStatus, mutableMapOf()) + + /** + * Account status. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accountStatus(): AccountStatus = accountStatus.getRequired("account_status") + + /** + * Returns the raw JSON value of [accountStatus]. + * + * Unlike [accountStatus], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("account_status") + @ExcludeMissing + fun _accountStatus(): JsonField = accountStatus + + @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 [Authorization]. + * + * The following fields are required: + * ```java + * .accountStatus() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Authorization]. */ + class Builder internal constructor() { + + private var accountStatus: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authorization: Authorization) = apply { + accountStatus = authorization.accountStatus + additionalProperties = authorization.additionalProperties.toMutableMap() + } + + /** Account status. */ + fun accountStatus(accountStatus: AccountStatus) = + accountStatus(JsonField.of(accountStatus)) + + /** + * Sets [Builder.accountStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.accountStatus] with a well-typed + * [AccountStatus] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun accountStatus(accountStatus: JsonField) = apply { + this.accountStatus = accountStatus + } + + 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 [Authorization]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accountStatus() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Authorization = + Authorization( + checkRequired("accountStatus", accountStatus), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Authorization = apply { + if (validated) { + return@apply + } + + accountStatus().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (accountStatus.asKnown().getOrNull()?.validity() ?: 0) + + /** Account status. */ + class AccountStatus + @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 { + + /** Account closed. */ + @JvmField val ACCOUNT_CLOSED = of("account_closed") + + /** Credit problem. */ + @JvmField val CREDIT_PROBLEM = of("credit_problem") + + /** Fraud. */ + @JvmField val FRAUD = of("fraud") + + @JvmStatic fun of(value: String) = AccountStatus(JsonField.of(value)) + } + + /** An enum containing [AccountStatus]'s known values. */ + enum class Known { + /** Account closed. */ + ACCOUNT_CLOSED, + /** Credit problem. */ + CREDIT_PROBLEM, + /** Fraud. */ + FRAUD, + } + + /** + * An enum containing [AccountStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AccountStatus] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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 closed. */ + ACCOUNT_CLOSED, + /** Credit problem. */ + CREDIT_PROBLEM, + /** Fraud. */ + FRAUD, + /** + * An enum member indicating that [AccountStatus] 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_CLOSED -> Value.ACCOUNT_CLOSED + CREDIT_PROBLEM -> Value.CREDIT_PROBLEM + FRAUD -> Value.FRAUD + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_CLOSED -> Known.ACCOUNT_CLOSED + CREDIT_PROBLEM -> Known.CREDIT_PROBLEM + FRAUD -> Known.FRAUD + else -> + throw IncreaseInvalidDataException("Unknown AccountStatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AccountStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccountStatus && 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 Authorization && + accountStatus == other.accountStatus && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accountStatus, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Authorization{accountStatus=$accountStatus, additionalProperties=$additionalProperties}" + } + + /** + * Canceled merchandise. Required if and only if `category` is + * `consumer_canceled_merchandise`. + */ + class ConsumerCanceledMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val purchaseExplanation: JsonField, + private val receivedOrExpectedAt: JsonField, + private val returnOutcome: JsonField, + private val cardholderCancellation: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_or_expected_at") + @ExcludeMissing + receivedOrExpectedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + purchaseExplanation, + receivedOrExpectedAt, + returnOutcome, + cardholderCancellation, + notReturned, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received or expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedOrExpectedAt(): LocalDate = + receivedOrExpectedAt.getRequired("received_or_expected_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderCancellation(): Optional = + cardholderCancellation.getOptional("cardholder_cancellation") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedOrExpectedAt]. + * + * Unlike [receivedOrExpectedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_or_expected_at") + @ExcludeMissing + fun _receivedOrExpectedAt(): JsonField = receivedOrExpectedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerCanceledMerchandise]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .purchaseExplanation() + * .receivedOrExpectedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledMerchandise]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: + JsonField? = + null + private var purchaseExplanation: JsonField? = null + private var receivedOrExpectedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var cardholderCancellation: JsonField = + JsonMissing.of() + private var notReturned: JsonValue = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCanceledMerchandise: ConsumerCanceledMerchandise) = + apply { + merchantResolutionAttempted = + consumerCanceledMerchandise.merchantResolutionAttempted + purchaseExplanation = consumerCanceledMerchandise.purchaseExplanation + receivedOrExpectedAt = consumerCanceledMerchandise.receivedOrExpectedAt + returnOutcome = consumerCanceledMerchandise.returnOutcome + cardholderCancellation = + consumerCanceledMerchandise.cardholderCancellation + notReturned = consumerCanceledMerchandise.notReturned + returnAttempted = consumerCanceledMerchandise.returnAttempted + returned = consumerCanceledMerchandise.returned + additionalProperties = + consumerCanceledMerchandise.additionalProperties.toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received or expected at. */ + fun receivedOrExpectedAt(receivedOrExpectedAt: LocalDate) = + receivedOrExpectedAt(JsonField.of(receivedOrExpectedAt)) + + /** + * Sets [Builder.receivedOrExpectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedOrExpectedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun receivedOrExpectedAt(receivedOrExpectedAt: JsonField) = apply { + this.receivedOrExpectedAt = receivedOrExpectedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerCanceledMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .purchaseExplanation() + * .receivedOrExpectedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledMerchandise = + ConsumerCanceledMerchandise( + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedOrExpectedAt", receivedOrExpectedAt), + checkRequired("returnOutcome", returnOutcome), + cardholderCancellation, + notReturned, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledMerchandise = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + purchaseExplanation() + receivedOrExpectedAt() + returnOutcome().validate() + cardholderCancellation().ifPresent { it.validate() } + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedOrExpectedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val canceledPriorToShipDate: JsonField, + private val cancellationPolicyProvided: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("canceled_prior_to_ship_date") + @ExcludeMissing + canceledPriorToShipDate: JsonField = + JsonMissing.of(), + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + cancellationPolicyProvided: JsonField = + JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this( + canceledAt, + canceledPriorToShipDate, + cancellationPolicyProvided, + reason, + mutableMapOf(), + ) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Canceled prior to ship date. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledPriorToShipDate(): CanceledPriorToShipDate = + canceledPriorToShipDate.getRequired("canceled_prior_to_ship_date") + + /** + * Cancellation policy provided. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationPolicyProvided(): CancellationPolicyProvided = + cancellationPolicyProvided.getRequired("cancellation_policy_provided") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * Returns the raw JSON value of [canceledPriorToShipDate]. + * + * Unlike [canceledPriorToShipDate], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("canceled_prior_to_ship_date") + @ExcludeMissing + fun _canceledPriorToShipDate(): JsonField = + canceledPriorToShipDate + + /** + * Returns the raw JSON value of [cancellationPolicyProvided]. + * + * Unlike [cancellationPolicyProvided], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + fun _cancellationPolicyProvided(): JsonField = + cancellationPolicyProvided + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .canceledPriorToShipDate() + * .cancellationPolicyProvided() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var canceledPriorToShipDate: JsonField? = + null + private var cancellationPolicyProvided: + JsonField? = + null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + canceledAt = cardholderCancellation.canceledAt + canceledPriorToShipDate = cardholderCancellation.canceledPriorToShipDate + cancellationPolicyProvided = + cardholderCancellation.cancellationPolicyProvided + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Canceled prior to ship date. */ + fun canceledPriorToShipDate( + canceledPriorToShipDate: CanceledPriorToShipDate + ) = canceledPriorToShipDate(JsonField.of(canceledPriorToShipDate)) + + /** + * Sets [Builder.canceledPriorToShipDate] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledPriorToShipDate] with a + * well-typed [CanceledPriorToShipDate] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun canceledPriorToShipDate( + canceledPriorToShipDate: JsonField + ) = apply { this.canceledPriorToShipDate = canceledPriorToShipDate } + + /** Cancellation policy provided. */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: CancellationPolicyProvided + ) = cancellationPolicyProvided(JsonField.of(cancellationPolicyProvided)) + + /** + * Sets [Builder.cancellationPolicyProvided] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationPolicyProvided] with a + * well-typed [CancellationPolicyProvided] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: JsonField + ) = apply { this.cancellationPolicyProvided = cancellationPolicyProvided } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .canceledPriorToShipDate() + * .cancellationPolicyProvided() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("canceledAt", canceledAt), + checkRequired("canceledPriorToShipDate", canceledPriorToShipDate), + checkRequired( + "cancellationPolicyProvided", + cancellationPolicyProvided, + ), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + canceledPriorToShipDate().validate() + cancellationPolicyProvided().validate() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (canceledPriorToShipDate.asKnown().getOrNull()?.validity() ?: 0) + + (cancellationPolicyProvided.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Canceled prior to ship date. */ + class CanceledPriorToShipDate + @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 { + + /** Canceled prior to ship date. */ + @JvmField + val CANCELED_PRIOR_TO_SHIP_DATE = of("canceled_prior_to_ship_date") + + /** Not canceled prior to ship date. */ + @JvmField + val NOT_CANCELED_PRIOR_TO_SHIP_DATE = + of("not_canceled_prior_to_ship_date") + + @JvmStatic + fun of(value: String) = CanceledPriorToShipDate(JsonField.of(value)) + } + + /** An enum containing [CanceledPriorToShipDate]'s known values. */ + enum class Known { + /** Canceled prior to ship date. */ + CANCELED_PRIOR_TO_SHIP_DATE, + /** Not canceled prior to ship date. */ + NOT_CANCELED_PRIOR_TO_SHIP_DATE, + } + + /** + * An enum containing [CanceledPriorToShipDate]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [CanceledPriorToShipDate] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Canceled prior to ship date. */ + CANCELED_PRIOR_TO_SHIP_DATE, + /** Not canceled prior to ship date. */ + NOT_CANCELED_PRIOR_TO_SHIP_DATE, + /** + * An enum member indicating that [CanceledPriorToShipDate] 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) { + CANCELED_PRIOR_TO_SHIP_DATE -> Value.CANCELED_PRIOR_TO_SHIP_DATE + NOT_CANCELED_PRIOR_TO_SHIP_DATE -> + Value.NOT_CANCELED_PRIOR_TO_SHIP_DATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + CANCELED_PRIOR_TO_SHIP_DATE -> Known.CANCELED_PRIOR_TO_SHIP_DATE + NOT_CANCELED_PRIOR_TO_SHIP_DATE -> + Known.NOT_CANCELED_PRIOR_TO_SHIP_DATE + else -> + throw IncreaseInvalidDataException( + "Unknown CanceledPriorToShipDate: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CanceledPriorToShipDate = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CanceledPriorToShipDate && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Cancellation policy provided. */ + class CancellationPolicyProvided + @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 { + + /** Not provided. */ + @JvmField val NOT_PROVIDED = of("not_provided") + + /** Provided. */ + @JvmField val PROVIDED = of("provided") + + @JvmStatic + fun of(value: String) = CancellationPolicyProvided(JsonField.of(value)) + } + + /** An enum containing [CancellationPolicyProvided]'s known values. */ + enum class Known { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + } + + /** + * An enum containing [CancellationPolicyProvided]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [CancellationPolicyProvided] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + /** + * An enum member indicating that [CancellationPolicyProvided] 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) { + NOT_PROVIDED -> Value.NOT_PROVIDED + PROVIDED -> Value.PROVIDED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_PROVIDED -> Known.NOT_PROVIDED + PROVIDED -> Known.PROVIDED + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationPolicyProvided: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationPolicyProvided = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationPolicyProvided && 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 CardholderCancellation && + canceledAt == other.canceledAt && + canceledPriorToShipDate == other.canceledPriorToShipDate && + cancellationPolicyProvided == other.cancellationPolicyProvided && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + canceledAt, + canceledPriorToShipDate, + cancellationPolicyProvided, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{canceledAt=$canceledAt, canceledPriorToShipDate=$canceledPriorToShipDate, cancellationPolicyProvided=$cancellationPolicyProvided, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = + JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is `other`. + */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCanceledMerchandise && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseExplanation == other.purchaseExplanation && + receivedOrExpectedAt == other.receivedOrExpectedAt && + returnOutcome == other.returnOutcome && + cardholderCancellation == other.cardholderCancellation && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + purchaseExplanation, + receivedOrExpectedAt, + returnOutcome, + cardholderCancellation, + notReturned, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledMerchandise{merchantResolutionAttempted=$merchantResolutionAttempted, purchaseExplanation=$purchaseExplanation, receivedOrExpectedAt=$receivedOrExpectedAt, returnOutcome=$returnOutcome, cardholderCancellation=$cardholderCancellation, notReturned=$notReturned, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Canceled recurring transaction. Required if and only if `category` is + * `consumer_canceled_recurring_transaction`. + */ + class ConsumerCanceledRecurringTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationTarget: JsonField, + private val merchantContactMethods: JsonField, + private val transactionOrAccountCanceledAt: JsonField, + private val otherFormOfPaymentExplanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_target") + @ExcludeMissing + cancellationTarget: JsonField = JsonMissing.of(), + @JsonProperty("merchant_contact_methods") + @ExcludeMissing + merchantContactMethods: JsonField = JsonMissing.of(), + @JsonProperty("transaction_or_account_canceled_at") + @ExcludeMissing + transactionOrAccountCanceledAt: JsonField = JsonMissing.of(), + @JsonProperty("other_form_of_payment_explanation") + @ExcludeMissing + otherFormOfPaymentExplanation: JsonField = JsonMissing.of(), + ) : this( + cancellationTarget, + merchantContactMethods, + transactionOrAccountCanceledAt, + otherFormOfPaymentExplanation, + mutableMapOf(), + ) + + /** + * Cancellation target. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationTarget(): CancellationTarget = + cancellationTarget.getRequired("cancellation_target") + + /** + * Merchant contact methods. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantContactMethods(): MerchantContactMethods = + merchantContactMethods.getRequired("merchant_contact_methods") + + /** + * Transaction or account canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun transactionOrAccountCanceledAt(): LocalDate = + transactionOrAccountCanceledAt.getRequired("transaction_or_account_canceled_at") + + /** + * Other form of payment explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherFormOfPaymentExplanation(): Optional = + otherFormOfPaymentExplanation.getOptional("other_form_of_payment_explanation") + + /** + * Returns the raw JSON value of [cancellationTarget]. + * + * Unlike [cancellationTarget], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cancellation_target") + @ExcludeMissing + fun _cancellationTarget(): JsonField = cancellationTarget + + /** + * Returns the raw JSON value of [merchantContactMethods]. + * + * Unlike [merchantContactMethods], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("merchant_contact_methods") + @ExcludeMissing + fun _merchantContactMethods(): JsonField = + merchantContactMethods + + /** + * Returns the raw JSON value of [transactionOrAccountCanceledAt]. + * + * Unlike [transactionOrAccountCanceledAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("transaction_or_account_canceled_at") + @ExcludeMissing + fun _transactionOrAccountCanceledAt(): JsonField = + transactionOrAccountCanceledAt + + /** + * Returns the raw JSON value of [otherFormOfPaymentExplanation]. + * + * Unlike [otherFormOfPaymentExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("other_form_of_payment_explanation") + @ExcludeMissing + fun _otherFormOfPaymentExplanation(): JsonField = + otherFormOfPaymentExplanation + + @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 + * [ConsumerCanceledRecurringTransaction]. + * + * The following fields are required: + * ```java + * .cancellationTarget() + * .merchantContactMethods() + * .transactionOrAccountCanceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledRecurringTransaction]. */ + class Builder internal constructor() { + + private var cancellationTarget: JsonField? = null + private var merchantContactMethods: JsonField? = null + private var transactionOrAccountCanceledAt: JsonField? = null + private var otherFormOfPaymentExplanation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerCanceledRecurringTransaction: ConsumerCanceledRecurringTransaction + ) = apply { + cancellationTarget = consumerCanceledRecurringTransaction.cancellationTarget + merchantContactMethods = + consumerCanceledRecurringTransaction.merchantContactMethods + transactionOrAccountCanceledAt = + consumerCanceledRecurringTransaction.transactionOrAccountCanceledAt + otherFormOfPaymentExplanation = + consumerCanceledRecurringTransaction.otherFormOfPaymentExplanation + additionalProperties = + consumerCanceledRecurringTransaction.additionalProperties.toMutableMap() + } + + /** Cancellation target. */ + fun cancellationTarget(cancellationTarget: CancellationTarget) = + cancellationTarget(JsonField.of(cancellationTarget)) + + /** + * Sets [Builder.cancellationTarget] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationTarget] with a well-typed + * [CancellationTarget] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cancellationTarget(cancellationTarget: JsonField) = + apply { + this.cancellationTarget = cancellationTarget + } + + /** Merchant contact methods. */ + fun merchantContactMethods(merchantContactMethods: MerchantContactMethods) = + merchantContactMethods(JsonField.of(merchantContactMethods)) + + /** + * Sets [Builder.merchantContactMethods] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantContactMethods] with a well-typed + * [MerchantContactMethods] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantContactMethods( + merchantContactMethods: JsonField + ) = apply { this.merchantContactMethods = merchantContactMethods } + + /** Transaction or account canceled at. */ + fun transactionOrAccountCanceledAt(transactionOrAccountCanceledAt: LocalDate) = + transactionOrAccountCanceledAt(JsonField.of(transactionOrAccountCanceledAt)) + + /** + * Sets [Builder.transactionOrAccountCanceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionOrAccountCanceledAt] with a + * well-typed [LocalDate] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun transactionOrAccountCanceledAt( + transactionOrAccountCanceledAt: JsonField + ) = apply { + this.transactionOrAccountCanceledAt = transactionOrAccountCanceledAt + } + + /** Other form of payment explanation. */ + fun otherFormOfPaymentExplanation(otherFormOfPaymentExplanation: String) = + otherFormOfPaymentExplanation(JsonField.of(otherFormOfPaymentExplanation)) + + /** + * Sets [Builder.otherFormOfPaymentExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherFormOfPaymentExplanation] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun otherFormOfPaymentExplanation( + otherFormOfPaymentExplanation: JsonField + ) = apply { this.otherFormOfPaymentExplanation = otherFormOfPaymentExplanation } + + 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 [ConsumerCanceledRecurringTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationTarget() + * .merchantContactMethods() + * .transactionOrAccountCanceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledRecurringTransaction = + ConsumerCanceledRecurringTransaction( + checkRequired("cancellationTarget", cancellationTarget), + checkRequired("merchantContactMethods", merchantContactMethods), + checkRequired( + "transactionOrAccountCanceledAt", + transactionOrAccountCanceledAt, + ), + otherFormOfPaymentExplanation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledRecurringTransaction = apply { + if (validated) { + return@apply + } + + cancellationTarget().validate() + merchantContactMethods().validate() + transactionOrAccountCanceledAt() + otherFormOfPaymentExplanation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationTarget.asKnown().getOrNull()?.validity() ?: 0) + + (merchantContactMethods.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionOrAccountCanceledAt.asKnown().isPresent) 1 else 0) + + (if (otherFormOfPaymentExplanation.asKnown().isPresent) 1 else 0) + + /** Cancellation target. */ + class CancellationTarget + @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 { + + /** Account. */ + @JvmField val ACCOUNT = of("account") + + /** Transaction. */ + @JvmField val TRANSACTION = of("transaction") + + @JvmStatic fun of(value: String) = CancellationTarget(JsonField.of(value)) + } + + /** An enum containing [CancellationTarget]'s known values. */ + enum class Known { + /** Account. */ + ACCOUNT, + /** Transaction. */ + TRANSACTION, + } + + /** + * An enum containing [CancellationTarget]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CancellationTarget] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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. */ + ACCOUNT, + /** Transaction. */ + TRANSACTION, + /** + * An enum member indicating that [CancellationTarget] 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 -> Value.ACCOUNT + 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 IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ACCOUNT -> Known.ACCOUNT + TRANSACTION -> Known.TRANSACTION + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationTarget: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationTarget = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationTarget && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant contact methods. */ + class MerchantContactMethods + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val applicationName: JsonField, + private val callCenterPhoneNumber: JsonField, + private val emailAddress: JsonField, + private val inPersonAddress: JsonField, + private val mailingAddress: JsonField, + private val textPhoneNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("application_name") + @ExcludeMissing + applicationName: JsonField = JsonMissing.of(), + @JsonProperty("call_center_phone_number") + @ExcludeMissing + callCenterPhoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("email_address") + @ExcludeMissing + emailAddress: JsonField = JsonMissing.of(), + @JsonProperty("in_person_address") + @ExcludeMissing + inPersonAddress: JsonField = JsonMissing.of(), + @JsonProperty("mailing_address") + @ExcludeMissing + mailingAddress: JsonField = JsonMissing.of(), + @JsonProperty("text_phone_number") + @ExcludeMissing + textPhoneNumber: JsonField = JsonMissing.of(), + ) : this( + applicationName, + callCenterPhoneNumber, + emailAddress, + inPersonAddress, + mailingAddress, + textPhoneNumber, + mutableMapOf(), + ) + + /** + * Application name. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun applicationName(): Optional = + applicationName.getOptional("application_name") + + /** + * Call center phone number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun callCenterPhoneNumber(): Optional = + callCenterPhoneNumber.getOptional("call_center_phone_number") + + /** + * Email address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun emailAddress(): Optional = emailAddress.getOptional("email_address") + + /** + * In person address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun inPersonAddress(): Optional = + inPersonAddress.getOptional("in_person_address") + + /** + * Mailing address. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun mailingAddress(): Optional = + mailingAddress.getOptional("mailing_address") + + /** + * Text phone number. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun textPhoneNumber(): Optional = + textPhoneNumber.getOptional("text_phone_number") + + /** + * Returns the raw JSON value of [applicationName]. + * + * Unlike [applicationName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("application_name") + @ExcludeMissing + fun _applicationName(): JsonField = applicationName + + /** + * Returns the raw JSON value of [callCenterPhoneNumber]. + * + * Unlike [callCenterPhoneNumber], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("call_center_phone_number") + @ExcludeMissing + fun _callCenterPhoneNumber(): JsonField = callCenterPhoneNumber + + /** + * Returns the raw JSON value of [emailAddress]. + * + * Unlike [emailAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("email_address") + @ExcludeMissing + fun _emailAddress(): JsonField = emailAddress + + /** + * Returns the raw JSON value of [inPersonAddress]. + * + * Unlike [inPersonAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("in_person_address") + @ExcludeMissing + fun _inPersonAddress(): JsonField = inPersonAddress + + /** + * Returns the raw JSON value of [mailingAddress]. + * + * Unlike [mailingAddress], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("mailing_address") + @ExcludeMissing + fun _mailingAddress(): JsonField = mailingAddress + + /** + * Returns the raw JSON value of [textPhoneNumber]. + * + * Unlike [textPhoneNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("text_phone_number") + @ExcludeMissing + fun _textPhoneNumber(): JsonField = textPhoneNumber + + @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 + * [MerchantContactMethods]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantContactMethods]. */ + class Builder internal constructor() { + + private var applicationName: JsonField = JsonMissing.of() + private var callCenterPhoneNumber: JsonField = JsonMissing.of() + private var emailAddress: JsonField = JsonMissing.of() + private var inPersonAddress: JsonField = JsonMissing.of() + private var mailingAddress: JsonField = JsonMissing.of() + private var textPhoneNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(merchantContactMethods: MerchantContactMethods) = apply { + applicationName = merchantContactMethods.applicationName + callCenterPhoneNumber = merchantContactMethods.callCenterPhoneNumber + emailAddress = merchantContactMethods.emailAddress + inPersonAddress = merchantContactMethods.inPersonAddress + mailingAddress = merchantContactMethods.mailingAddress + textPhoneNumber = merchantContactMethods.textPhoneNumber + additionalProperties = + merchantContactMethods.additionalProperties.toMutableMap() + } + + /** Application name. */ + fun applicationName(applicationName: String) = + applicationName(JsonField.of(applicationName)) + + /** + * Sets [Builder.applicationName] to an arbitrary JSON value. + * + * You should usually call [Builder.applicationName] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun applicationName(applicationName: JsonField) = apply { + this.applicationName = applicationName + } + + /** Call center phone number. */ + fun callCenterPhoneNumber(callCenterPhoneNumber: String) = + callCenterPhoneNumber(JsonField.of(callCenterPhoneNumber)) + + /** + * Sets [Builder.callCenterPhoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.callCenterPhoneNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun callCenterPhoneNumber(callCenterPhoneNumber: JsonField) = + apply { + this.callCenterPhoneNumber = callCenterPhoneNumber + } + + /** Email address. */ + fun emailAddress(emailAddress: String) = + emailAddress(JsonField.of(emailAddress)) + + /** + * Sets [Builder.emailAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.emailAddress] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun emailAddress(emailAddress: JsonField) = apply { + this.emailAddress = emailAddress + } + + /** In person address. */ + fun inPersonAddress(inPersonAddress: String) = + inPersonAddress(JsonField.of(inPersonAddress)) + + /** + * Sets [Builder.inPersonAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.inPersonAddress] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun inPersonAddress(inPersonAddress: JsonField) = apply { + this.inPersonAddress = inPersonAddress + } + + /** Mailing address. */ + fun mailingAddress(mailingAddress: String) = + mailingAddress(JsonField.of(mailingAddress)) + + /** + * Sets [Builder.mailingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.mailingAddress] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun mailingAddress(mailingAddress: JsonField) = apply { + this.mailingAddress = mailingAddress + } + + /** Text phone number. */ + fun textPhoneNumber(textPhoneNumber: String) = + textPhoneNumber(JsonField.of(textPhoneNumber)) + + /** + * Sets [Builder.textPhoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.textPhoneNumber] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun textPhoneNumber(textPhoneNumber: JsonField) = apply { + this.textPhoneNumber = textPhoneNumber + } + + 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 [MerchantContactMethods]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MerchantContactMethods = + MerchantContactMethods( + applicationName, + callCenterPhoneNumber, + emailAddress, + inPersonAddress, + mailingAddress, + textPhoneNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantContactMethods = apply { + if (validated) { + return@apply + } + + applicationName() + callCenterPhoneNumber() + emailAddress() + inPersonAddress() + mailingAddress() + textPhoneNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (applicationName.asKnown().isPresent) 1 else 0) + + (if (callCenterPhoneNumber.asKnown().isPresent) 1 else 0) + + (if (emailAddress.asKnown().isPresent) 1 else 0) + + (if (inPersonAddress.asKnown().isPresent) 1 else 0) + + (if (mailingAddress.asKnown().isPresent) 1 else 0) + + (if (textPhoneNumber.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantContactMethods && + applicationName == other.applicationName && + callCenterPhoneNumber == other.callCenterPhoneNumber && + emailAddress == other.emailAddress && + inPersonAddress == other.inPersonAddress && + mailingAddress == other.mailingAddress && + textPhoneNumber == other.textPhoneNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + applicationName, + callCenterPhoneNumber, + emailAddress, + inPersonAddress, + mailingAddress, + textPhoneNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantContactMethods{applicationName=$applicationName, callCenterPhoneNumber=$callCenterPhoneNumber, emailAddress=$emailAddress, inPersonAddress=$inPersonAddress, mailingAddress=$mailingAddress, textPhoneNumber=$textPhoneNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCanceledRecurringTransaction && + cancellationTarget == other.cancellationTarget && + merchantContactMethods == other.merchantContactMethods && + transactionOrAccountCanceledAt == other.transactionOrAccountCanceledAt && + otherFormOfPaymentExplanation == other.otherFormOfPaymentExplanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationTarget, + merchantContactMethods, + transactionOrAccountCanceledAt, + otherFormOfPaymentExplanation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledRecurringTransaction{cancellationTarget=$cancellationTarget, merchantContactMethods=$merchantContactMethods, transactionOrAccountCanceledAt=$transactionOrAccountCanceledAt, otherFormOfPaymentExplanation=$otherFormOfPaymentExplanation, additionalProperties=$additionalProperties}" + } + + /** + * Canceled services. Required if and only if `category` is + * `consumer_canceled_services`. + */ + class ConsumerCanceledServices + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val contractedAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val purchaseExplanation: JsonField, + private val serviceType: JsonField, + private val guaranteedReservation: JsonField, + private val other: JsonValue, + private val timeshare: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty("contracted_at") + @ExcludeMissing + contractedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("service_type") + @ExcludeMissing + serviceType: JsonField = JsonMissing.of(), + @JsonProperty("guaranteed_reservation") + @ExcludeMissing + guaranteedReservation: JsonField = JsonMissing.of(), + @JsonProperty("other") @ExcludeMissing other: JsonValue = JsonMissing.of(), + @JsonProperty("timeshare") + @ExcludeMissing + timeshare: JsonValue = JsonMissing.of(), + ) : this( + cardholderCancellation, + contractedAt, + merchantResolutionAttempted, + purchaseExplanation, + serviceType, + guaranteedReservation, + other, + timeshare, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Contracted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun contractedAt(): LocalDate = contractedAt.getRequired("contracted_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Service type. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceType(): ServiceType = serviceType.getRequired("service_type") + + /** + * Guaranteed reservation explanation. Required if and only if `service_type` is + * `guaranteed_reservation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun guaranteedReservation(): Optional = + guaranteedReservation.getOptional("guaranteed_reservation") + + /** + * Other service type explanation. Required if and only if `service_type` is + * `other`. + */ + @JsonProperty("other") @ExcludeMissing fun _other(): JsonValue = other + + /** Timeshare explanation. Required if and only if `service_type` is `timeshare`. */ + @JsonProperty("timeshare") @ExcludeMissing fun _timeshare(): JsonValue = timeshare + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [contractedAt]. + * + * Unlike [contractedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("contracted_at") + @ExcludeMissing + fun _contractedAt(): JsonField = contractedAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [serviceType]. + * + * Unlike [serviceType], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_type") + @ExcludeMissing + fun _serviceType(): JsonField = serviceType + + /** + * Returns the raw JSON value of [guaranteedReservation]. + * + * Unlike [guaranteedReservation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("guaranteed_reservation") + @ExcludeMissing + fun _guaranteedReservation(): JsonField = + guaranteedReservation + + @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 + * [ConsumerCanceledServices]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .contractedAt() + * .merchantResolutionAttempted() + * .purchaseExplanation() + * .serviceType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCanceledServices]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = null + private var contractedAt: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var purchaseExplanation: JsonField? = null + private var serviceType: JsonField? = null + private var guaranteedReservation: JsonField = + JsonMissing.of() + private var other: JsonValue = JsonMissing.of() + private var timeshare: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCanceledServices: ConsumerCanceledServices) = apply { + cardholderCancellation = consumerCanceledServices.cardholderCancellation + contractedAt = consumerCanceledServices.contractedAt + merchantResolutionAttempted = + consumerCanceledServices.merchantResolutionAttempted + purchaseExplanation = consumerCanceledServices.purchaseExplanation + serviceType = consumerCanceledServices.serviceType + guaranteedReservation = consumerCanceledServices.guaranteedReservation + other = consumerCanceledServices.other + timeshare = consumerCanceledServices.timeshare + additionalProperties = + consumerCanceledServices.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Contracted at. */ + fun contractedAt(contractedAt: LocalDate) = + contractedAt(JsonField.of(contractedAt)) + + /** + * Sets [Builder.contractedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.contractedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun contractedAt(contractedAt: JsonField) = apply { + this.contractedAt = contractedAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Service type. */ + fun serviceType(serviceType: ServiceType) = + serviceType(JsonField.of(serviceType)) + + /** + * Sets [Builder.serviceType] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceType] with a well-typed [ServiceType] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun serviceType(serviceType: JsonField) = apply { + this.serviceType = serviceType + } + + /** + * Guaranteed reservation explanation. Required if and only if `service_type` is + * `guaranteed_reservation`. + */ + fun guaranteedReservation(guaranteedReservation: GuaranteedReservation) = + guaranteedReservation(JsonField.of(guaranteedReservation)) + + /** + * Sets [Builder.guaranteedReservation] to an arbitrary JSON value. + * + * You should usually call [Builder.guaranteedReservation] with a well-typed + * [GuaranteedReservation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun guaranteedReservation( + guaranteedReservation: JsonField + ) = apply { this.guaranteedReservation = guaranteedReservation } + + /** + * Other service type explanation. Required if and only if `service_type` is + * `other`. + */ + fun other(other: JsonValue) = apply { this.other = other } + + /** + * Timeshare explanation. Required if and only if `service_type` is `timeshare`. + */ + fun timeshare(timeshare: JsonValue) = apply { this.timeshare = timeshare } + + 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 [ConsumerCanceledServices]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .contractedAt() + * .merchantResolutionAttempted() + * .purchaseExplanation() + * .serviceType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCanceledServices = + ConsumerCanceledServices( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired("contractedAt", contractedAt), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("serviceType", serviceType), + guaranteedReservation, + other, + timeshare, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCanceledServices = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + contractedAt() + merchantResolutionAttempted().validate() + purchaseExplanation() + serviceType().validate() + guaranteedReservation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (if (contractedAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (serviceType.asKnown().getOrNull()?.validity() ?: 0) + + (guaranteedReservation.asKnown().getOrNull()?.validity() ?: 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val cancellationPolicyProvided: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + cancellationPolicyProvided: JsonField = + JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, cancellationPolicyProvided, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Cancellation policy provided. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationPolicyProvided(): CancellationPolicyProvided = + cancellationPolicyProvided.getRequired("cancellation_policy_provided") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * Returns the raw JSON value of [cancellationPolicyProvided]. + * + * Unlike [cancellationPolicyProvided], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cancellation_policy_provided") + @ExcludeMissing + fun _cancellationPolicyProvided(): JsonField = + cancellationPolicyProvided + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * .cancellationPolicyProvided() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var cancellationPolicyProvided: + JsonField? = + null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + canceledAt = cardholderCancellation.canceledAt + cancellationPolicyProvided = + cardholderCancellation.cancellationPolicyProvided + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Cancellation policy provided. */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: CancellationPolicyProvided + ) = cancellationPolicyProvided(JsonField.of(cancellationPolicyProvided)) + + /** + * Sets [Builder.cancellationPolicyProvided] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationPolicyProvided] with a + * well-typed [CancellationPolicyProvided] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cancellationPolicyProvided( + cancellationPolicyProvided: JsonField + ) = apply { this.cancellationPolicyProvided = cancellationPolicyProvided } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * .cancellationPolicyProvided() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("canceledAt", canceledAt), + checkRequired( + "cancellationPolicyProvided", + cancellationPolicyProvided, + ), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + cancellationPolicyProvided().validate() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (cancellationPolicyProvided.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Cancellation policy provided. */ + class CancellationPolicyProvided + @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 { + + /** Not provided. */ + @JvmField val NOT_PROVIDED = of("not_provided") + + /** Provided. */ + @JvmField val PROVIDED = of("provided") + + @JvmStatic + fun of(value: String) = CancellationPolicyProvided(JsonField.of(value)) + } + + /** An enum containing [CancellationPolicyProvided]'s known values. */ + enum class Known { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + } + + /** + * An enum containing [CancellationPolicyProvided]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [CancellationPolicyProvided] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not provided. */ + NOT_PROVIDED, + /** Provided. */ + PROVIDED, + /** + * An enum member indicating that [CancellationPolicyProvided] 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) { + NOT_PROVIDED -> Value.NOT_PROVIDED + PROVIDED -> Value.PROVIDED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_PROVIDED -> Known.NOT_PROVIDED + PROVIDED -> Known.PROVIDED + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationPolicyProvided: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationPolicyProvided = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationPolicyProvided && 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 CardholderCancellation && + canceledAt == other.canceledAt && + cancellationPolicyProvided == other.cancellationPolicyProvided && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + canceledAt, + cancellationPolicyProvided, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{canceledAt=$canceledAt, cancellationPolicyProvided=$cancellationPolicyProvided, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Service type. */ + class ServiceType + @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 { + + /** Guaranteed reservation. */ + @JvmField val GUARANTEED_RESERVATION = of("guaranteed_reservation") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Timeshare. */ + @JvmField val TIMESHARE = of("timeshare") + + @JvmStatic fun of(value: String) = ServiceType(JsonField.of(value)) + } + + /** An enum containing [ServiceType]'s known values. */ + enum class Known { + /** Guaranteed reservation. */ + GUARANTEED_RESERVATION, + /** Other. */ + OTHER, + /** Timeshare. */ + TIMESHARE, + } + + /** + * An enum containing [ServiceType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ServiceType] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Guaranteed reservation. */ + GUARANTEED_RESERVATION, + /** Other. */ + OTHER, + /** Timeshare. */ + TIMESHARE, + /** + * An enum member indicating that [ServiceType] 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) { + GUARANTEED_RESERVATION -> Value.GUARANTEED_RESERVATION + OTHER -> Value.OTHER + TIMESHARE -> Value.TIMESHARE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + GUARANTEED_RESERVATION -> Known.GUARANTEED_RESERVATION + OTHER -> Known.OTHER + TIMESHARE -> Known.TIMESHARE + else -> + throw IncreaseInvalidDataException("Unknown ServiceType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ServiceType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServiceType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Guaranteed reservation explanation. Required if and only if `service_type` is + * `guaranteed_reservation`. + */ + class GuaranteedReservation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of() + ) : this(explanation, mutableMapOf()) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): Explanation = explanation.getRequired("explanation") + + /** + * 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 + + @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 + * [GuaranteedReservation]. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [GuaranteedReservation]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(guaranteedReservation: GuaranteedReservation) = apply { + explanation = guaranteedReservation.explanation + additionalProperties = + guaranteedReservation.additionalProperties.toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: Explanation) = + explanation(JsonField.of(explanation)) + + /** + * Sets [Builder.explanation] to an arbitrary JSON value. + * + * You should usually call [Builder.explanation] with a well-typed + * [Explanation] 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 + } + + 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 [GuaranteedReservation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): GuaranteedReservation = + GuaranteedReservation( + checkRequired("explanation", explanation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): GuaranteedReservation = apply { + if (validated) { + return@apply + } + + explanation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (explanation.asKnown().getOrNull()?.validity() ?: 0) + + /** Explanation. */ + class Explanation + @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 { + + /** Cardholder canceled prior to service. */ + @JvmField + val CARDHOLDER_CANCELED_PRIOR_TO_SERVICE = + of("cardholder_canceled_prior_to_service") + + /** Cardholder cancellation attempt within 24 hours of confirmation. */ + @JvmField + val CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION = + of( + "cardholder_cancellation_attempt_within_24_hours_of_confirmation" + ) + + /** Merchant billed for no-show. */ + @JvmField val MERCHANT_BILLED_NO_SHOW = of("merchant_billed_no_show") + + @JvmStatic fun of(value: String) = Explanation(JsonField.of(value)) + } + + /** An enum containing [Explanation]'s known values. */ + enum class Known { + /** Cardholder canceled prior to service. */ + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE, + /** Cardholder cancellation attempt within 24 hours of confirmation. */ + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION, + /** Merchant billed for no-show. */ + MERCHANT_BILLED_NO_SHOW, + } + + /** + * An enum containing [Explanation]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Explanation] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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 canceled prior to service. */ + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE, + /** Cardholder cancellation attempt within 24 hours of confirmation. */ + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION, + /** Merchant billed for no-show. */ + MERCHANT_BILLED_NO_SHOW, + /** + * An enum member indicating that [Explanation] 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_CANCELED_PRIOR_TO_SERVICE -> + Value.CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION -> + Value + .CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION + MERCHANT_BILLED_NO_SHOW -> Value.MERCHANT_BILLED_NO_SHOW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELED_PRIOR_TO_SERVICE -> + Known.CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION -> + Known + .CARDHOLDER_CANCELLATION_ATTEMPT_WITHIN_24_HOURS_OF_CONFIRMATION + MERCHANT_BILLED_NO_SHOW -> Known.MERCHANT_BILLED_NO_SHOW + else -> + throw IncreaseInvalidDataException( + "Unknown Explanation: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Explanation = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Explanation && 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 GuaranteedReservation && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "GuaranteedReservation{explanation=$explanation, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCanceledServices && + cardholderCancellation == other.cardholderCancellation && + contractedAt == other.contractedAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseExplanation == other.purchaseExplanation && + serviceType == other.serviceType && + guaranteedReservation == other.guaranteedReservation && + this.other == other.other && + timeshare == other.timeshare && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + contractedAt, + merchantResolutionAttempted, + purchaseExplanation, + serviceType, + guaranteedReservation, + other, + timeshare, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCanceledServices{cardholderCancellation=$cardholderCancellation, contractedAt=$contractedAt, merchantResolutionAttempted=$merchantResolutionAttempted, purchaseExplanation=$purchaseExplanation, serviceType=$serviceType, guaranteedReservation=$guaranteedReservation, other=$other, timeshare=$timeshare, additionalProperties=$additionalProperties}" + } + + /** + * Counterfeit merchandise. Required if and only if `category` is + * `consumer_counterfeit_merchandise`. + */ + class ConsumerCounterfeitMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val counterfeitExplanation: JsonField, + private val dispositionExplanation: JsonField, + private val orderExplanation: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("counterfeit_explanation") + @ExcludeMissing + counterfeitExplanation: JsonField = JsonMissing.of(), + @JsonProperty("disposition_explanation") + @ExcludeMissing + dispositionExplanation: JsonField = JsonMissing.of(), + @JsonProperty("order_explanation") + @ExcludeMissing + orderExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + counterfeitExplanation, + dispositionExplanation, + orderExplanation, + receivedAt, + mutableMapOf(), + ) + + /** + * Counterfeit explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun counterfeitExplanation(): String = + counterfeitExplanation.getRequired("counterfeit_explanation") + + /** + * Disposition explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun dispositionExplanation(): String = + dispositionExplanation.getRequired("disposition_explanation") + + /** + * Order explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun orderExplanation(): String = orderExplanation.getRequired("order_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [counterfeitExplanation]. + * + * Unlike [counterfeitExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("counterfeit_explanation") + @ExcludeMissing + fun _counterfeitExplanation(): JsonField = counterfeitExplanation + + /** + * Returns the raw JSON value of [dispositionExplanation]. + * + * Unlike [dispositionExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("disposition_explanation") + @ExcludeMissing + fun _dispositionExplanation(): JsonField = dispositionExplanation + + /** + * Returns the raw JSON value of [orderExplanation]. + * + * Unlike [orderExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("order_explanation") + @ExcludeMissing + fun _orderExplanation(): JsonField = orderExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerCounterfeitMerchandise]. + * + * The following fields are required: + * ```java + * .counterfeitExplanation() + * .dispositionExplanation() + * .orderExplanation() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCounterfeitMerchandise]. */ + class Builder internal constructor() { + + private var counterfeitExplanation: JsonField? = null + private var dispositionExplanation: JsonField? = null + private var orderExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerCounterfeitMerchandise: ConsumerCounterfeitMerchandise + ) = apply { + counterfeitExplanation = + consumerCounterfeitMerchandise.counterfeitExplanation + dispositionExplanation = + consumerCounterfeitMerchandise.dispositionExplanation + orderExplanation = consumerCounterfeitMerchandise.orderExplanation + receivedAt = consumerCounterfeitMerchandise.receivedAt + additionalProperties = + consumerCounterfeitMerchandise.additionalProperties.toMutableMap() + } + + /** Counterfeit explanation. */ + fun counterfeitExplanation(counterfeitExplanation: String) = + counterfeitExplanation(JsonField.of(counterfeitExplanation)) + + /** + * Sets [Builder.counterfeitExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.counterfeitExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun counterfeitExplanation(counterfeitExplanation: JsonField) = apply { + this.counterfeitExplanation = counterfeitExplanation + } + + /** Disposition explanation. */ + fun dispositionExplanation(dispositionExplanation: String) = + dispositionExplanation(JsonField.of(dispositionExplanation)) + + /** + * Sets [Builder.dispositionExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.dispositionExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun dispositionExplanation(dispositionExplanation: JsonField) = apply { + this.dispositionExplanation = dispositionExplanation + } + + /** Order explanation. */ + fun orderExplanation(orderExplanation: String) = + orderExplanation(JsonField.of(orderExplanation)) + + /** + * Sets [Builder.orderExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.orderExplanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orderExplanation(orderExplanation: JsonField) = apply { + this.orderExplanation = orderExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerCounterfeitMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .counterfeitExplanation() + * .dispositionExplanation() + * .orderExplanation() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerCounterfeitMerchandise = + ConsumerCounterfeitMerchandise( + checkRequired("counterfeitExplanation", counterfeitExplanation), + checkRequired("dispositionExplanation", dispositionExplanation), + checkRequired("orderExplanation", orderExplanation), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCounterfeitMerchandise = apply { + if (validated) { + return@apply + } + + counterfeitExplanation() + dispositionExplanation() + orderExplanation() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (counterfeitExplanation.asKnown().isPresent) 1 else 0) + + (if (dispositionExplanation.asKnown().isPresent) 1 else 0) + + (if (orderExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCounterfeitMerchandise && + counterfeitExplanation == other.counterfeitExplanation && + dispositionExplanation == other.dispositionExplanation && + orderExplanation == other.orderExplanation && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + counterfeitExplanation, + dispositionExplanation, + orderExplanation, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCounterfeitMerchandise{counterfeitExplanation=$counterfeitExplanation, dispositionExplanation=$dispositionExplanation, orderExplanation=$orderExplanation, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Credit not processed. Required if and only if `category` is + * `consumer_credit_not_processed`. + */ + class ConsumerCreditNotProcessed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledOrReturnedAt: JsonField, + private val creditExpectedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_or_returned_at") + @ExcludeMissing + canceledOrReturnedAt: JsonField = JsonMissing.of(), + @JsonProperty("credit_expected_at") + @ExcludeMissing + creditExpectedAt: JsonField = JsonMissing.of(), + ) : this(canceledOrReturnedAt, creditExpectedAt, mutableMapOf()) + + /** + * Canceled or returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun canceledOrReturnedAt(): Optional = + canceledOrReturnedAt.getOptional("canceled_or_returned_at") + + /** + * Credit expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun creditExpectedAt(): Optional = + creditExpectedAt.getOptional("credit_expected_at") + + /** + * Returns the raw JSON value of [canceledOrReturnedAt]. + * + * Unlike [canceledOrReturnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_or_returned_at") + @ExcludeMissing + fun _canceledOrReturnedAt(): JsonField = canceledOrReturnedAt + + /** + * Returns the raw JSON value of [creditExpectedAt]. + * + * Unlike [creditExpectedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("credit_expected_at") + @ExcludeMissing + fun _creditExpectedAt(): JsonField = creditExpectedAt + + @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 + * [ConsumerCreditNotProcessed]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerCreditNotProcessed]. */ + class Builder internal constructor() { + + private var canceledOrReturnedAt: JsonField = JsonMissing.of() + private var creditExpectedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerCreditNotProcessed: ConsumerCreditNotProcessed) = + apply { + canceledOrReturnedAt = consumerCreditNotProcessed.canceledOrReturnedAt + creditExpectedAt = consumerCreditNotProcessed.creditExpectedAt + additionalProperties = + consumerCreditNotProcessed.additionalProperties.toMutableMap() + } + + /** Canceled or returned at. */ + fun canceledOrReturnedAt(canceledOrReturnedAt: LocalDate) = + canceledOrReturnedAt(JsonField.of(canceledOrReturnedAt)) + + /** + * Sets [Builder.canceledOrReturnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledOrReturnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun canceledOrReturnedAt(canceledOrReturnedAt: JsonField) = apply { + this.canceledOrReturnedAt = canceledOrReturnedAt + } + + /** Credit expected at. */ + fun creditExpectedAt(creditExpectedAt: LocalDate) = + creditExpectedAt(JsonField.of(creditExpectedAt)) + + /** + * Sets [Builder.creditExpectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.creditExpectedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun creditExpectedAt(creditExpectedAt: JsonField) = apply { + this.creditExpectedAt = creditExpectedAt + } + + 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 [ConsumerCreditNotProcessed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ConsumerCreditNotProcessed = + ConsumerCreditNotProcessed( + canceledOrReturnedAt, + creditExpectedAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerCreditNotProcessed = apply { + if (validated) { + return@apply + } + + canceledOrReturnedAt() + creditExpectedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledOrReturnedAt.asKnown().isPresent) 1 else 0) + + (if (creditExpectedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerCreditNotProcessed && + canceledOrReturnedAt == other.canceledOrReturnedAt && + creditExpectedAt == other.creditExpectedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledOrReturnedAt, creditExpectedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerCreditNotProcessed{canceledOrReturnedAt=$canceledOrReturnedAt, creditExpectedAt=$creditExpectedAt, additionalProperties=$additionalProperties}" + } + + /** + * Damaged or defective merchandise. Required if and only if `category` is + * `consumer_damaged_or_defective_merchandise`. + */ + class ConsumerDamagedOrDefectiveMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val orderAndIssueExplanation: JsonField, + private val receivedAt: JsonField, + private val returnOutcome: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("order_and_issue_explanation") + @ExcludeMissing + orderAndIssueExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + orderAndIssueExplanation, + receivedAt, + returnOutcome, + notReturned, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Order and issue explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun orderAndIssueExplanation(): String = + orderAndIssueExplanation.getRequired("order_and_issue_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [orderAndIssueExplanation]. + * + * Unlike [orderAndIssueExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("order_and_issue_explanation") + @ExcludeMissing + fun _orderAndIssueExplanation(): JsonField = orderAndIssueExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerDamagedOrDefectiveMerchandise]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .orderAndIssueExplanation() + * .receivedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerDamagedOrDefectiveMerchandise]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: + JsonField? = + null + private var orderAndIssueExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var notReturned: JsonValue = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerDamagedOrDefectiveMerchandise: ConsumerDamagedOrDefectiveMerchandise + ) = apply { + merchantResolutionAttempted = + consumerDamagedOrDefectiveMerchandise.merchantResolutionAttempted + orderAndIssueExplanation = + consumerDamagedOrDefectiveMerchandise.orderAndIssueExplanation + receivedAt = consumerDamagedOrDefectiveMerchandise.receivedAt + returnOutcome = consumerDamagedOrDefectiveMerchandise.returnOutcome + notReturned = consumerDamagedOrDefectiveMerchandise.notReturned + returnAttempted = consumerDamagedOrDefectiveMerchandise.returnAttempted + returned = consumerDamagedOrDefectiveMerchandise.returned + additionalProperties = + consumerDamagedOrDefectiveMerchandise.additionalProperties + .toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Order and issue explanation. */ + fun orderAndIssueExplanation(orderAndIssueExplanation: String) = + orderAndIssueExplanation(JsonField.of(orderAndIssueExplanation)) + + /** + * Sets [Builder.orderAndIssueExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.orderAndIssueExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun orderAndIssueExplanation(orderAndIssueExplanation: JsonField) = + apply { + this.orderAndIssueExplanation = orderAndIssueExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerDamagedOrDefectiveMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .orderAndIssueExplanation() + * .receivedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerDamagedOrDefectiveMerchandise = + ConsumerDamagedOrDefectiveMerchandise( + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("orderAndIssueExplanation", orderAndIssueExplanation), + checkRequired("receivedAt", receivedAt), + checkRequired("returnOutcome", returnOutcome), + notReturned, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerDamagedOrDefectiveMerchandise = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + orderAndIssueExplanation() + receivedAt() + returnOutcome().validate() + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (orderAndIssueExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = + JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is `other`. + */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerDamagedOrDefectiveMerchandise && + merchantResolutionAttempted == other.merchantResolutionAttempted && + orderAndIssueExplanation == other.orderAndIssueExplanation && + receivedAt == other.receivedAt && + returnOutcome == other.returnOutcome && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + orderAndIssueExplanation, + receivedAt, + returnOutcome, + notReturned, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerDamagedOrDefectiveMerchandise{merchantResolutionAttempted=$merchantResolutionAttempted, orderAndIssueExplanation=$orderAndIssueExplanation, receivedAt=$receivedAt, returnOutcome=$returnOutcome, notReturned=$notReturned, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise misrepresentation. Required if and only if `category` is + * `consumer_merchandise_misrepresentation`. + */ + class ConsumerMerchandiseMisrepresentation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val misrepresentationExplanation: JsonField, + private val purchaseExplanation: JsonField, + private val receivedAt: JsonField, + private val returnOutcome: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + misrepresentationExplanation: JsonField = JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + returnOutcome, + notReturned, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Misrepresentation explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun misrepresentationExplanation(): String = + misrepresentationExplanation.getRequired("misrepresentation_explanation") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [misrepresentationExplanation]. + * + * Unlike [misrepresentationExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + fun _misrepresentationExplanation(): JsonField = + misrepresentationExplanation + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerMerchandiseMisrepresentation]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseMisrepresentation]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: + JsonField? = + null + private var misrepresentationExplanation: JsonField? = null + private var purchaseExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var notReturned: JsonValue = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerMerchandiseMisrepresentation: ConsumerMerchandiseMisrepresentation + ) = apply { + merchantResolutionAttempted = + consumerMerchandiseMisrepresentation.merchantResolutionAttempted + misrepresentationExplanation = + consumerMerchandiseMisrepresentation.misrepresentationExplanation + purchaseExplanation = + consumerMerchandiseMisrepresentation.purchaseExplanation + receivedAt = consumerMerchandiseMisrepresentation.receivedAt + returnOutcome = consumerMerchandiseMisrepresentation.returnOutcome + notReturned = consumerMerchandiseMisrepresentation.notReturned + returnAttempted = consumerMerchandiseMisrepresentation.returnAttempted + returned = consumerMerchandiseMisrepresentation.returned + additionalProperties = + consumerMerchandiseMisrepresentation.additionalProperties.toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Misrepresentation explanation. */ + fun misrepresentationExplanation(misrepresentationExplanation: String) = + misrepresentationExplanation(JsonField.of(misrepresentationExplanation)) + + /** + * Sets [Builder.misrepresentationExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.misrepresentationExplanation] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun misrepresentationExplanation( + misrepresentationExplanation: JsonField + ) = apply { this.misrepresentationExplanation = misrepresentationExplanation } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerMerchandiseMisrepresentation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseMisrepresentation = + ConsumerMerchandiseMisrepresentation( + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired( + "misrepresentationExplanation", + misrepresentationExplanation, + ), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedAt", receivedAt), + checkRequired("returnOutcome", returnOutcome), + notReturned, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseMisrepresentation = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + misrepresentationExplanation() + purchaseExplanation() + receivedAt() + returnOutcome().validate() + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (misrepresentationExplanation.asKnown().isPresent) 1 else 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = + JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is `other`. + */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerMerchandiseMisrepresentation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + misrepresentationExplanation == other.misrepresentationExplanation && + purchaseExplanation == other.purchaseExplanation && + receivedAt == other.receivedAt && + returnOutcome == other.returnOutcome && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + returnOutcome, + notReturned, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseMisrepresentation{merchantResolutionAttempted=$merchantResolutionAttempted, misrepresentationExplanation=$misrepresentationExplanation, purchaseExplanation=$purchaseExplanation, receivedAt=$receivedAt, returnOutcome=$returnOutcome, notReturned=$notReturned, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise not as described. Required if and only if `category` is + * `consumer_merchandise_not_as_described`. + */ + class ConsumerMerchandiseNotAsDescribed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantResolutionAttempted: JsonField, + private val receivedAt: JsonField, + private val returnOutcome: JsonField, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + merchantResolutionAttempted, + receivedAt, + returnOutcome, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerMerchandiseNotAsDescribed]. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .receivedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseNotAsDescribed]. */ + class Builder internal constructor() { + + private var merchantResolutionAttempted: + JsonField? = + null + private var receivedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerMerchandiseNotAsDescribed: ConsumerMerchandiseNotAsDescribed + ) = apply { + merchantResolutionAttempted = + consumerMerchandiseNotAsDescribed.merchantResolutionAttempted + receivedAt = consumerMerchandiseNotAsDescribed.receivedAt + returnOutcome = consumerMerchandiseNotAsDescribed.returnOutcome + returnAttempted = consumerMerchandiseNotAsDescribed.returnAttempted + returned = consumerMerchandiseNotAsDescribed.returned + additionalProperties = + consumerMerchandiseNotAsDescribed.additionalProperties.toMutableMap() + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerMerchandiseNotAsDescribed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .merchantResolutionAttempted() + * .receivedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseNotAsDescribed = + ConsumerMerchandiseNotAsDescribed( + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("receivedAt", receivedAt), + checkRequired("returnOutcome", returnOutcome), + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseNotAsDescribed = apply { + if (validated) { + return@apply + } + + merchantResolutionAttempted().validate() + receivedAt() + returnOutcome().validate() + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = + JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is `other`. + */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerMerchandiseNotAsDescribed && + merchantResolutionAttempted == other.merchantResolutionAttempted && + receivedAt == other.receivedAt && + returnOutcome == other.returnOutcome && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + merchantResolutionAttempted, + receivedAt, + returnOutcome, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseNotAsDescribed{merchantResolutionAttempted=$merchantResolutionAttempted, receivedAt=$receivedAt, returnOutcome=$returnOutcome, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise not received. Required if and only if `category` is + * `consumer_merchandise_not_received`. + */ + class ConsumerMerchandiseNotReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationOutcome: JsonField, + private val deliveryIssue: JsonField, + private val lastExpectedReceiptAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val purchaseInfoAndExplanation: JsonField, + private val cardholderCancellationPriorToExpectedReceipt: + JsonField, + private val delayed: JsonField, + private val deliveredToWrongLocation: JsonField, + private val merchantCancellation: JsonField, + private val noCancellation: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_outcome") + @ExcludeMissing + cancellationOutcome: JsonField = JsonMissing.of(), + @JsonProperty("delivery_issue") + @ExcludeMissing + deliveryIssue: JsonField = JsonMissing.of(), + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + lastExpectedReceiptAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + purchaseInfoAndExplanation: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of(), + @JsonProperty("delayed") + @ExcludeMissing + delayed: JsonField = JsonMissing.of(), + @JsonProperty("delivered_to_wrong_location") + @ExcludeMissing + deliveredToWrongLocation: JsonField = + JsonMissing.of(), + @JsonProperty("merchant_cancellation") + @ExcludeMissing + merchantCancellation: JsonField = JsonMissing.of(), + @JsonProperty("no_cancellation") + @ExcludeMissing + noCancellation: JsonValue = JsonMissing.of(), + ) : this( + cancellationOutcome, + deliveryIssue, + lastExpectedReceiptAt, + merchantResolutionAttempted, + purchaseInfoAndExplanation, + cardholderCancellationPriorToExpectedReceipt, + delayed, + deliveredToWrongLocation, + merchantCancellation, + noCancellation, + mutableMapOf(), + ) + + /** + * Cancellation outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationOutcome(): CancellationOutcome = + cancellationOutcome.getRequired("cancellation_outcome") + + /** + * Delivery issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun deliveryIssue(): DeliveryIssue = deliveryIssue.getRequired("delivery_issue") + + /** + * Last expected receipt at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastExpectedReceiptAt(): LocalDate = + lastExpectedReceiptAt.getRequired("last_expected_receipt_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase information and explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseInfoAndExplanation(): String = + purchaseInfoAndExplanation.getRequired("purchase_info_and_explanation") + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderCancellationPriorToExpectedReceipt(): + Optional = + cardholderCancellationPriorToExpectedReceipt.getOptional( + "cardholder_cancellation_prior_to_expected_receipt" + ) + + /** + * Delayed. Required if and only if `delivery_issue` is `delayed`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun delayed(): Optional = delayed.getOptional("delayed") + + /** + * Delivered to wrong location. Required if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun deliveredToWrongLocation(): Optional = + deliveredToWrongLocation.getOptional("delivered_to_wrong_location") + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantCancellation(): Optional = + merchantCancellation.getOptional("merchant_cancellation") + + /** + * No cancellation. Required if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + @JsonProperty("no_cancellation") + @ExcludeMissing + fun _noCancellation(): JsonValue = noCancellation + + /** + * Returns the raw JSON value of [cancellationOutcome]. + * + * Unlike [cancellationOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cancellation_outcome") + @ExcludeMissing + fun _cancellationOutcome(): JsonField = cancellationOutcome + + /** + * Returns the raw JSON value of [deliveryIssue]. + * + * Unlike [deliveryIssue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("delivery_issue") + @ExcludeMissing + fun _deliveryIssue(): JsonField = deliveryIssue + + /** + * Returns the raw JSON value of [lastExpectedReceiptAt]. + * + * Unlike [lastExpectedReceiptAt], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + fun _lastExpectedReceiptAt(): JsonField = lastExpectedReceiptAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseInfoAndExplanation]. + * + * Unlike [purchaseInfoAndExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + fun _purchaseInfoAndExplanation(): JsonField = purchaseInfoAndExplanation + + /** + * Returns the raw JSON value of [cardholderCancellationPriorToExpectedReceipt]. + * + * Unlike [cardholderCancellationPriorToExpectedReceipt], this method doesn't throw + * if the JSON field has an unexpected type. + */ + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + fun _cardholderCancellationPriorToExpectedReceipt(): + JsonField = + cardholderCancellationPriorToExpectedReceipt + + /** + * Returns the raw JSON value of [delayed]. + * + * Unlike [delayed], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("delayed") + @ExcludeMissing + fun _delayed(): JsonField = delayed + + /** + * Returns the raw JSON value of [deliveredToWrongLocation]. + * + * Unlike [deliveredToWrongLocation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("delivered_to_wrong_location") + @ExcludeMissing + fun _deliveredToWrongLocation(): JsonField = + deliveredToWrongLocation + + /** + * Returns the raw JSON value of [merchantCancellation]. + * + * Unlike [merchantCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_cancellation") + @ExcludeMissing + fun _merchantCancellation(): JsonField = merchantCancellation + + @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 + * [ConsumerMerchandiseNotReceived]. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .deliveryIssue() + * .lastExpectedReceiptAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndExplanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerMerchandiseNotReceived]. */ + class Builder internal constructor() { + + private var cancellationOutcome: JsonField? = null + private var deliveryIssue: JsonField? = null + private var lastExpectedReceiptAt: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var purchaseInfoAndExplanation: JsonField? = null + private var cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of() + private var delayed: JsonField = JsonMissing.of() + private var deliveredToWrongLocation: JsonField = + JsonMissing.of() + private var merchantCancellation: JsonField = + JsonMissing.of() + private var noCancellation: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerMerchandiseNotReceived: ConsumerMerchandiseNotReceived + ) = apply { + cancellationOutcome = consumerMerchandiseNotReceived.cancellationOutcome + deliveryIssue = consumerMerchandiseNotReceived.deliveryIssue + lastExpectedReceiptAt = consumerMerchandiseNotReceived.lastExpectedReceiptAt + merchantResolutionAttempted = + consumerMerchandiseNotReceived.merchantResolutionAttempted + purchaseInfoAndExplanation = + consumerMerchandiseNotReceived.purchaseInfoAndExplanation + cardholderCancellationPriorToExpectedReceipt = + consumerMerchandiseNotReceived + .cardholderCancellationPriorToExpectedReceipt + delayed = consumerMerchandiseNotReceived.delayed + deliveredToWrongLocation = + consumerMerchandiseNotReceived.deliveredToWrongLocation + merchantCancellation = consumerMerchandiseNotReceived.merchantCancellation + noCancellation = consumerMerchandiseNotReceived.noCancellation + additionalProperties = + consumerMerchandiseNotReceived.additionalProperties.toMutableMap() + } + + /** Cancellation outcome. */ + fun cancellationOutcome(cancellationOutcome: CancellationOutcome) = + cancellationOutcome(JsonField.of(cancellationOutcome)) + + /** + * Sets [Builder.cancellationOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationOutcome] with a well-typed + * [CancellationOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cancellationOutcome(cancellationOutcome: JsonField) = + apply { + this.cancellationOutcome = cancellationOutcome + } + + /** Delivery issue. */ + fun deliveryIssue(deliveryIssue: DeliveryIssue) = + deliveryIssue(JsonField.of(deliveryIssue)) + + /** + * Sets [Builder.deliveryIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveryIssue] with a well-typed + * [DeliveryIssue] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun deliveryIssue(deliveryIssue: JsonField) = apply { + this.deliveryIssue = deliveryIssue + } + + /** Last expected receipt at. */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: LocalDate) = + lastExpectedReceiptAt(JsonField.of(lastExpectedReceiptAt)) + + /** + * Sets [Builder.lastExpectedReceiptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastExpectedReceiptAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: JsonField) = apply { + this.lastExpectedReceiptAt = lastExpectedReceiptAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase information and explanation. */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: String) = + purchaseInfoAndExplanation(JsonField.of(purchaseInfoAndExplanation)) + + /** + * Sets [Builder.purchaseInfoAndExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndExplanation] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: JsonField) = + apply { + this.purchaseInfoAndExplanation = purchaseInfoAndExplanation + } + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is + * `cardholder_cancellation_prior_to_expected_receipt`. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = + cardholderCancellationPriorToExpectedReceipt( + JsonField.of(cardholderCancellationPriorToExpectedReceipt) + ) + + /** + * Sets [Builder.cardholderCancellationPriorToExpectedReceipt] to an arbitrary + * JSON value. + * + * You should usually call + * [Builder.cardholderCancellationPriorToExpectedReceipt] with a well-typed + * [CardholderCancellationPriorToExpectedReceipt] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + JsonField + ) = apply { + this.cardholderCancellationPriorToExpectedReceipt = + cardholderCancellationPriorToExpectedReceipt + } + + /** Delayed. Required if and only if `delivery_issue` is `delayed`. */ + fun delayed(delayed: Delayed) = delayed(JsonField.of(delayed)) + + /** + * Sets [Builder.delayed] to an arbitrary JSON value. + * + * You should usually call [Builder.delayed] with a well-typed [Delayed] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun delayed(delayed: JsonField) = apply { this.delayed = delayed } + + /** + * Delivered to wrong location. Required if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + */ + fun deliveredToWrongLocation( + deliveredToWrongLocation: DeliveredToWrongLocation + ) = deliveredToWrongLocation(JsonField.of(deliveredToWrongLocation)) + + /** + * Sets [Builder.deliveredToWrongLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.deliveredToWrongLocation] with a well-typed + * [DeliveredToWrongLocation] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun deliveredToWrongLocation( + deliveredToWrongLocation: JsonField + ) = apply { this.deliveredToWrongLocation = deliveredToWrongLocation } + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + fun merchantCancellation(merchantCancellation: MerchantCancellation) = + merchantCancellation(JsonField.of(merchantCancellation)) + + /** + * Sets [Builder.merchantCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCancellation] with a well-typed + * [MerchantCancellation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantCancellation( + merchantCancellation: JsonField + ) = apply { this.merchantCancellation = merchantCancellation } + + /** + * No cancellation. Required if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + fun noCancellation(noCancellation: JsonValue) = apply { + this.noCancellation = noCancellation + } + + 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 [ConsumerMerchandiseNotReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .deliveryIssue() + * .lastExpectedReceiptAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndExplanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerMerchandiseNotReceived = + ConsumerMerchandiseNotReceived( + checkRequired("cancellationOutcome", cancellationOutcome), + checkRequired("deliveryIssue", deliveryIssue), + checkRequired("lastExpectedReceiptAt", lastExpectedReceiptAt), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("purchaseInfoAndExplanation", purchaseInfoAndExplanation), + cardholderCancellationPriorToExpectedReceipt, + delayed, + deliveredToWrongLocation, + merchantCancellation, + noCancellation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerMerchandiseNotReceived = apply { + if (validated) { + return@apply + } + + cancellationOutcome().validate() + deliveryIssue().validate() + lastExpectedReceiptAt() + merchantResolutionAttempted().validate() + purchaseInfoAndExplanation() + cardholderCancellationPriorToExpectedReceipt().ifPresent { it.validate() } + delayed().ifPresent { it.validate() } + deliveredToWrongLocation().ifPresent { it.validate() } + merchantCancellation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (deliveryIssue.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastExpectedReceiptAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndExplanation.asKnown().isPresent) 1 else 0) + + (cardholderCancellationPriorToExpectedReceipt + .asKnown() + .getOrNull() + ?.validity() ?: 0) + + (delayed.asKnown().getOrNull()?.validity() ?: 0) + + (deliveredToWrongLocation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantCancellation.asKnown().getOrNull()?.validity() ?: 0) + + /** Cancellation outcome. */ + class CancellationOutcome + @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 { + + /** Cardholder cancellation prior to expected receipt. */ + @JvmField + val CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT = + of("cardholder_cancellation_prior_to_expected_receipt") + + /** Merchant cancellation. */ + @JvmField val MERCHANT_CANCELLATION = of("merchant_cancellation") + + /** No cancellation. */ + @JvmField val NO_CANCELLATION = of("no_cancellation") + + @JvmStatic fun of(value: String) = CancellationOutcome(JsonField.of(value)) + } + + /** An enum containing [CancellationOutcome]'s known values. */ + enum class Known { + /** Cardholder cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + } + + /** + * An enum containing [CancellationOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CancellationOutcome] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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 cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + /** + * An enum member indicating that [CancellationOutcome] 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_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Value.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Value.MERCHANT_CANCELLATION + NO_CANCELLATION -> Value.NO_CANCELLATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Known.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Known.MERCHANT_CANCELLATION + NO_CANCELLATION -> Known.NO_CANCELLATION + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Delivery issue. */ + class DeliveryIssue + @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 { + + /** Delayed. */ + @JvmField val DELAYED = of("delayed") + + /** Delivered to wrong location. */ + @JvmField + val DELIVERED_TO_WRONG_LOCATION = of("delivered_to_wrong_location") + + @JvmStatic fun of(value: String) = DeliveryIssue(JsonField.of(value)) + } + + /** An enum containing [DeliveryIssue]'s known values. */ + enum class Known { + /** Delayed. */ + DELAYED, + /** Delivered to wrong location. */ + DELIVERED_TO_WRONG_LOCATION, + } + + /** + * An enum containing [DeliveryIssue]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [DeliveryIssue] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Delayed. */ + DELAYED, + /** Delivered to wrong location. */ + DELIVERED_TO_WRONG_LOCATION, + /** + * An enum member indicating that [DeliveryIssue] 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) { + DELAYED -> Value.DELAYED + DELIVERED_TO_WRONG_LOCATION -> Value.DELIVERED_TO_WRONG_LOCATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DELAYED -> Known.DELAYED + DELIVERED_TO_WRONG_LOCATION -> Known.DELIVERED_TO_WRONG_LOCATION + else -> + throw IncreaseInvalidDataException("Unknown DeliveryIssue: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DeliveryIssue = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeliveryIssue && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + */ + class CardholderCancellationPriorToExpectedReceipt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellationPriorToExpectedReceipt]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = apply { + canceledAt = cardholderCancellationPriorToExpectedReceipt.canceledAt + reason = cardholderCancellationPriorToExpectedReceipt.reason + additionalProperties = + cardholderCancellationPriorToExpectedReceipt.additionalProperties + .toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellationPriorToExpectedReceipt = + CardholderCancellationPriorToExpectedReceipt( + checkRequired("canceledAt", canceledAt), + reason, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellationPriorToExpectedReceipt = apply { + if (validated) { + return@apply + } + + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderCancellationPriorToExpectedReceipt && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellationPriorToExpectedReceipt{canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Delayed. Required if and only if `delivery_issue` is `delayed`. */ + class Delayed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val returnOutcome: JsonField, + private val notReturned: JsonValue, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + explanation, + returnOutcome, + notReturned, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * 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 [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 [Delayed]. + * + * The following fields are required: + * ```java + * .explanation() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Delayed]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var returnOutcome: JsonField? = null + private var notReturned: JsonValue = JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(delayed: Delayed) = apply { + explanation = delayed.explanation + returnOutcome = delayed.returnOutcome + notReturned = delayed.notReturned + returnAttempted = delayed.returnAttempted + returned = delayed.returned + additionalProperties = delayed.additionalProperties.toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: String) = + explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** + * Not returned. Required if and only if `return_outcome` is `not_returned`. + */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun returned(returned: JsonField) = apply { + this.returned = returned + } + + 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 [Delayed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Delayed = + Delayed( + checkRequired("explanation", explanation), + checkRequired("returnOutcome", returnOutcome), + notReturned, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Delayed = apply { + if (validated) { + return@apply + } + + explanation() + returnOutcome().validate() + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of() + ) : this(attemptedAt, mutableMapOf()) + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptedAt = returnAttempted.attemptedAt + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .attemptedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptedAt", attemptedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnAttempted && + attemptedAt == other.attemptedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attemptedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptedAt=$attemptedAt, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val merchantReceivedReturnAt: JsonField, + private val returnedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + ) : this(merchantReceivedReturnAt, returnedAt, mutableMapOf()) + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun merchantReceivedReturnAt(): LocalDate = + merchantReceivedReturnAt.getRequired("merchant_received_return_at") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = + merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + @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 [Returned]. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var merchantReceivedReturnAt: JsonField? = null + private var returnedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + returnedAt = returned.returnedAt + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = + returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .merchantReceivedReturnAt() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired( + "merchantReceivedReturnAt", + merchantReceivedReturnAt, + ), + checkRequired("returnedAt", returnedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + merchantReceivedReturnAt() + returnedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Returned && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + returnedAt == other.returnedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(merchantReceivedReturnAt, returnedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{merchantReceivedReturnAt=$merchantReceivedReturnAt, returnedAt=$returnedAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Delayed && + explanation == other.explanation && + returnOutcome == other.returnOutcome && + notReturned == other.notReturned && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + returnOutcome, + notReturned, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Delayed{explanation=$explanation, returnOutcome=$returnOutcome, notReturned=$notReturned, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Delivered to wrong location. Required if and only if `delivery_issue` is + * `delivered_to_wrong_location`. + */ + class DeliveredToWrongLocation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val agreedLocation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("agreed_location") + @ExcludeMissing + agreedLocation: JsonField = JsonMissing.of() + ) : this(agreedLocation, mutableMapOf()) + + /** + * Agreed location. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun agreedLocation(): String = agreedLocation.getRequired("agreed_location") + + /** + * Returns the raw JSON value of [agreedLocation]. + * + * Unlike [agreedLocation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("agreed_location") + @ExcludeMissing + fun _agreedLocation(): JsonField = agreedLocation + + @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 + * [DeliveredToWrongLocation]. + * + * The following fields are required: + * ```java + * .agreedLocation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DeliveredToWrongLocation]. */ + class Builder internal constructor() { + + private var agreedLocation: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(deliveredToWrongLocation: DeliveredToWrongLocation) = + apply { + agreedLocation = deliveredToWrongLocation.agreedLocation + additionalProperties = + deliveredToWrongLocation.additionalProperties.toMutableMap() + } + + /** Agreed location. */ + fun agreedLocation(agreedLocation: String) = + agreedLocation(JsonField.of(agreedLocation)) + + /** + * Sets [Builder.agreedLocation] to an arbitrary JSON value. + * + * You should usually call [Builder.agreedLocation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun agreedLocation(agreedLocation: JsonField) = apply { + this.agreedLocation = agreedLocation + } + + 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 [DeliveredToWrongLocation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agreedLocation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DeliveredToWrongLocation = + DeliveredToWrongLocation( + checkRequired("agreedLocation", agreedLocation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DeliveredToWrongLocation = apply { + if (validated) { + return@apply + } + + agreedLocation() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (agreedLocation.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeliveredToWrongLocation && + agreedLocation == other.agreedLocation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(agreedLocation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DeliveredToWrongLocation{agreedLocation=$agreedLocation, additionalProperties=$additionalProperties}" + } + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + class MerchantCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of() + ) : this(canceledAt, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + @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 + * [MerchantCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCancellation: MerchantCancellation) = apply { + canceledAt = merchantCancellation.canceledAt + additionalProperties = + merchantCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + 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 [MerchantCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCancellation = + MerchantCancellation( + checkRequired("canceledAt", canceledAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (canceledAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCancellation && + canceledAt == other.canceledAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCancellation{canceledAt=$canceledAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerMerchandiseNotReceived && + cancellationOutcome == other.cancellationOutcome && + deliveryIssue == other.deliveryIssue && + lastExpectedReceiptAt == other.lastExpectedReceiptAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseInfoAndExplanation == other.purchaseInfoAndExplanation && + cardholderCancellationPriorToExpectedReceipt == + other.cardholderCancellationPriorToExpectedReceipt && + delayed == other.delayed && + deliveredToWrongLocation == other.deliveredToWrongLocation && + merchantCancellation == other.merchantCancellation && + noCancellation == other.noCancellation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationOutcome, + deliveryIssue, + lastExpectedReceiptAt, + merchantResolutionAttempted, + purchaseInfoAndExplanation, + cardholderCancellationPriorToExpectedReceipt, + delayed, + deliveredToWrongLocation, + merchantCancellation, + noCancellation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerMerchandiseNotReceived{cancellationOutcome=$cancellationOutcome, deliveryIssue=$deliveryIssue, lastExpectedReceiptAt=$lastExpectedReceiptAt, merchantResolutionAttempted=$merchantResolutionAttempted, purchaseInfoAndExplanation=$purchaseInfoAndExplanation, cardholderCancellationPriorToExpectedReceipt=$cardholderCancellationPriorToExpectedReceipt, delayed=$delayed, deliveredToWrongLocation=$deliveredToWrongLocation, merchantCancellation=$merchantCancellation, noCancellation=$noCancellation, additionalProperties=$additionalProperties}" + } + + /** + * Original Credit Transaction (OCT) not accepted. Required if and only if `category` is + * `consumer_original_credit_transaction_not_accepted`. + */ + class ConsumerOriginalCreditTransactionNotAccepted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(explanation, reason, mutableMapOf()) + + /** + * Explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): Reason = reason.getRequired("reason") + + /** + * 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 [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @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 + * [ConsumerOriginalCreditTransactionNotAccepted]. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerOriginalCreditTransactionNotAccepted]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerOriginalCreditTransactionNotAccepted: + ConsumerOriginalCreditTransactionNotAccepted + ) = apply { + explanation = consumerOriginalCreditTransactionNotAccepted.explanation + reason = consumerOriginalCreditTransactionNotAccepted.reason + additionalProperties = + consumerOriginalCreditTransactionNotAccepted.additionalProperties + .toMutableMap() + } + + /** Explanation. */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Reason. */ + fun reason(reason: Reason) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [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 } + + 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 + * [ConsumerOriginalCreditTransactionNotAccepted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerOriginalCreditTransactionNotAccepted = + ConsumerOriginalCreditTransactionNotAccepted( + checkRequired("explanation", explanation), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerOriginalCreditTransactionNotAccepted = apply { + if (validated) { + return@apply + } + + explanation() + reason().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** Reason. */ + class Reason + @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 { + + /** Prohibited by local laws or regulation. */ + @JvmField + val PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION = + of("prohibited_by_local_laws_or_regulation") + + /** Recipient refused. */ + @JvmField val RECIPIENT_REFUSED = of("recipient_refused") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + /** Prohibited by local laws or regulation. */ + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION, + /** Recipient refused. */ + RECIPIENT_REFUSED, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Prohibited by local laws or regulation. */ + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION, + /** Recipient refused. */ + RECIPIENT_REFUSED, + /** + * An enum member indicating that [Reason] 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) { + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION -> + Value.PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + RECIPIENT_REFUSED -> Value.RECIPIENT_REFUSED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION -> + Known.PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + RECIPIENT_REFUSED -> Known.RECIPIENT_REFUSED + else -> throw IncreaseInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && 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 ConsumerOriginalCreditTransactionNotAccepted && + explanation == other.explanation && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(explanation, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerOriginalCreditTransactionNotAccepted{explanation=$explanation, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Merchandise quality issue. Required if and only if `category` is + * `consumer_quality_merchandise`. + */ + class ConsumerQualityMerchandise + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expectedAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val purchaseInfoAndQualityIssue: JsonField, + private val receivedAt: JsonField, + private val returnOutcome: JsonField, + private val notReturned: JsonValue, + private val ongoingNegotiations: JsonField, + private val returnAttempted: JsonField, + private val returned: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expected_at") + @ExcludeMissing + expectedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + purchaseInfoAndQualityIssue: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + @JsonProperty("return_outcome") + @ExcludeMissing + returnOutcome: JsonField = JsonMissing.of(), + @JsonProperty("not_returned") + @ExcludeMissing + notReturned: JsonValue = JsonMissing.of(), + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + ongoingNegotiations: JsonField = JsonMissing.of(), + @JsonProperty("return_attempted") + @ExcludeMissing + returnAttempted: JsonField = JsonMissing.of(), + @JsonProperty("returned") + @ExcludeMissing + returned: JsonField = JsonMissing.of(), + ) : this( + expectedAt, + merchantResolutionAttempted, + purchaseInfoAndQualityIssue, + receivedAt, + returnOutcome, + notReturned, + ongoingNegotiations, + returnAttempted, + returned, + mutableMapOf(), + ) + + /** + * Expected at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun expectedAt(): LocalDate = expectedAt.getRequired("expected_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase information and quality issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseInfoAndQualityIssue(): String = + purchaseInfoAndQualityIssue.getRequired("purchase_info_and_quality_issue") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Return outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnOutcome(): ReturnOutcome = returnOutcome.getRequired("return_outcome") + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + @JsonProperty("not_returned") + @ExcludeMissing + fun _notReturned(): JsonValue = notReturned + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ongoingNegotiations(): Optional = + ongoingNegotiations.getOptional("ongoing_negotiations") + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returnAttempted(): Optional = + returnAttempted.getOptional("return_attempted") + + /** + * Returned. Required if and only if `return_outcome` is `returned`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun returned(): Optional = returned.getOptional("returned") + + /** + * Returns the raw JSON value of [expectedAt]. + * + * Unlike [expectedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("expected_at") + @ExcludeMissing + fun _expectedAt(): JsonField = expectedAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseInfoAndQualityIssue]. + * + * Unlike [purchaseInfoAndQualityIssue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + fun _purchaseInfoAndQualityIssue(): JsonField = purchaseInfoAndQualityIssue + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + /** + * Returns the raw JSON value of [returnOutcome]. + * + * Unlike [returnOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_outcome") + @ExcludeMissing + fun _returnOutcome(): JsonField = returnOutcome + + /** + * Returns the raw JSON value of [ongoingNegotiations]. + * + * Unlike [ongoingNegotiations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + fun _ongoingNegotiations(): JsonField = ongoingNegotiations + + /** + * Returns the raw JSON value of [returnAttempted]. + * + * Unlike [returnAttempted], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_attempted") + @ExcludeMissing + fun _returnAttempted(): JsonField = returnAttempted + + /** + * Returns the raw JSON value of [returned]. + * + * Unlike [returned], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("returned") + @ExcludeMissing + fun _returned(): JsonField = returned + + @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 + * [ConsumerQualityMerchandise]. + * + * The following fields are required: + * ```java + * .expectedAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndQualityIssue() + * .receivedAt() + * .returnOutcome() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerQualityMerchandise]. */ + class Builder internal constructor() { + + private var expectedAt: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var purchaseInfoAndQualityIssue: JsonField? = null + private var receivedAt: JsonField? = null + private var returnOutcome: JsonField? = null + private var notReturned: JsonValue = JsonMissing.of() + private var ongoingNegotiations: JsonField = + JsonMissing.of() + private var returnAttempted: JsonField = JsonMissing.of() + private var returned: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerQualityMerchandise: ConsumerQualityMerchandise) = + apply { + expectedAt = consumerQualityMerchandise.expectedAt + merchantResolutionAttempted = + consumerQualityMerchandise.merchantResolutionAttempted + purchaseInfoAndQualityIssue = + consumerQualityMerchandise.purchaseInfoAndQualityIssue + receivedAt = consumerQualityMerchandise.receivedAt + returnOutcome = consumerQualityMerchandise.returnOutcome + notReturned = consumerQualityMerchandise.notReturned + ongoingNegotiations = consumerQualityMerchandise.ongoingNegotiations + returnAttempted = consumerQualityMerchandise.returnAttempted + returned = consumerQualityMerchandise.returned + additionalProperties = + consumerQualityMerchandise.additionalProperties.toMutableMap() + } + + /** Expected at. */ + fun expectedAt(expectedAt: LocalDate) = expectedAt(JsonField.of(expectedAt)) + + /** + * Sets [Builder.expectedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun expectedAt(expectedAt: JsonField) = apply { + this.expectedAt = expectedAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase information and quality issue. */ + fun purchaseInfoAndQualityIssue(purchaseInfoAndQualityIssue: String) = + purchaseInfoAndQualityIssue(JsonField.of(purchaseInfoAndQualityIssue)) + + /** + * Sets [Builder.purchaseInfoAndQualityIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndQualityIssue] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun purchaseInfoAndQualityIssue( + purchaseInfoAndQualityIssue: JsonField + ) = apply { this.purchaseInfoAndQualityIssue = purchaseInfoAndQualityIssue } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + /** Return outcome. */ + fun returnOutcome(returnOutcome: ReturnOutcome) = + returnOutcome(JsonField.of(returnOutcome)) + + /** + * Sets [Builder.returnOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.returnOutcome] with a well-typed + * [ReturnOutcome] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnOutcome(returnOutcome: JsonField) = apply { + this.returnOutcome = returnOutcome + } + + /** Not returned. Required if and only if `return_outcome` is `not_returned`. */ + fun notReturned(notReturned: JsonValue) = apply { + this.notReturned = notReturned + } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing + * negotiations. + */ + fun ongoingNegotiations(ongoingNegotiations: OngoingNegotiations) = + ongoingNegotiations(JsonField.of(ongoingNegotiations)) + + /** + * Sets [Builder.ongoingNegotiations] to an arbitrary JSON value. + * + * You should usually call [Builder.ongoingNegotiations] with a well-typed + * [OngoingNegotiations] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun ongoingNegotiations(ongoingNegotiations: JsonField) = + apply { + this.ongoingNegotiations = ongoingNegotiations + } + + /** + * Return attempted. Required if and only if `return_outcome` is + * `return_attempted`. + */ + fun returnAttempted(returnAttempted: ReturnAttempted) = + returnAttempted(JsonField.of(returnAttempted)) + + /** + * Sets [Builder.returnAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.returnAttempted] with a well-typed + * [ReturnAttempted] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnAttempted(returnAttempted: JsonField) = apply { + this.returnAttempted = returnAttempted + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + fun returned(returned: Returned) = returned(JsonField.of(returned)) + + /** + * Sets [Builder.returned] to an arbitrary JSON value. + * + * You should usually call [Builder.returned] with a well-typed [Returned] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun returned(returned: JsonField) = apply { this.returned = returned } + + 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 [ConsumerQualityMerchandise]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expectedAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndQualityIssue() + * .receivedAt() + * .returnOutcome() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerQualityMerchandise = + ConsumerQualityMerchandise( + checkRequired("expectedAt", expectedAt), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired( + "purchaseInfoAndQualityIssue", + purchaseInfoAndQualityIssue, + ), + checkRequired("receivedAt", receivedAt), + checkRequired("returnOutcome", returnOutcome), + notReturned, + ongoingNegotiations, + returnAttempted, + returned, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerQualityMerchandise = apply { + if (validated) { + return@apply + } + + expectedAt() + merchantResolutionAttempted().validate() + purchaseInfoAndQualityIssue() + receivedAt() + returnOutcome().validate() + ongoingNegotiations().ifPresent { it.validate() } + returnAttempted().ifPresent { it.validate() } + returned().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expectedAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndQualityIssue.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + (returnOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (ongoingNegotiations.asKnown().getOrNull()?.validity() ?: 0) + + (returnAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (returned.asKnown().getOrNull()?.validity() ?: 0) + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Return outcome. */ + class ReturnOutcome + @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 { + + /** Not returned. */ + @JvmField val NOT_RETURNED = of("not_returned") + + /** Returned. */ + @JvmField val RETURNED = of("returned") + + /** Return attempted. */ + @JvmField val RETURN_ATTEMPTED = of("return_attempted") + + @JvmStatic fun of(value: String) = ReturnOutcome(JsonField.of(value)) + } + + /** An enum containing [ReturnOutcome]'s known values. */ + enum class Known { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + } + + /** + * An enum containing [ReturnOutcome]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ReturnOutcome] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not returned. */ + NOT_RETURNED, + /** Returned. */ + RETURNED, + /** Return attempted. */ + RETURN_ATTEMPTED, + /** + * An enum member indicating that [ReturnOutcome] 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) { + NOT_RETURNED -> Value.NOT_RETURNED + RETURNED -> Value.RETURNED + RETURN_ATTEMPTED -> Value.RETURN_ATTEMPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_RETURNED -> Known.NOT_RETURNED + RETURNED -> Known.RETURNED + RETURN_ATTEMPTED -> Known.RETURN_ATTEMPTED + else -> + throw IncreaseInvalidDataException("Unknown ReturnOutcome: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. + */ + class OngoingNegotiations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val issuerFirstNotifiedAt: JsonField, + private val startedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + issuerFirstNotifiedAt: JsonField = JsonMissing.of(), + @JsonProperty("started_at") + @ExcludeMissing + startedAt: JsonField = JsonMissing.of(), + ) : this(explanation, issuerFirstNotifiedAt, startedAt, mutableMapOf()) + + /** + * Explanation of the previous ongoing negotiations between the cardholder and + * merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Date the cardholder first notified the issuer of the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun issuerFirstNotifiedAt(): LocalDate = + issuerFirstNotifiedAt.getRequired("issuer_first_notified_at") + + /** + * Started at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startedAt(): LocalDate = startedAt.getRequired("started_at") + + /** + * 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 [issuerFirstNotifiedAt]. + * + * Unlike [issuerFirstNotifiedAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + fun _issuerFirstNotifiedAt(): JsonField = issuerFirstNotifiedAt + + /** + * Returns the raw JSON value of [startedAt]. + * + * Unlike [startedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("started_at") + @ExcludeMissing + fun _startedAt(): JsonField = startedAt + + @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 + * [OngoingNegotiations]. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OngoingNegotiations]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var issuerFirstNotifiedAt: JsonField? = null + private var startedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(ongoingNegotiations: OngoingNegotiations) = apply { + explanation = ongoingNegotiations.explanation + issuerFirstNotifiedAt = ongoingNegotiations.issuerFirstNotifiedAt + startedAt = ongoingNegotiations.startedAt + additionalProperties = + ongoingNegotiations.additionalProperties.toMutableMap() + } + + /** + * Explanation of the previous ongoing negotiations between the cardholder + * and merchant. + */ + fun explanation(explanation: String) = + explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Date the cardholder first notified the issuer of the dispute. */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: LocalDate) = + issuerFirstNotifiedAt(JsonField.of(issuerFirstNotifiedAt)) + + /** + * Sets [Builder.issuerFirstNotifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerFirstNotifiedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: JsonField) = + apply { + this.issuerFirstNotifiedAt = issuerFirstNotifiedAt + } + + /** Started at. */ + fun startedAt(startedAt: LocalDate) = startedAt(JsonField.of(startedAt)) + + /** + * Sets [Builder.startedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun startedAt(startedAt: JsonField) = apply { + this.startedAt = startedAt + } + + 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 [OngoingNegotiations]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OngoingNegotiations = + OngoingNegotiations( + checkRequired("explanation", explanation), + checkRequired("issuerFirstNotifiedAt", issuerFirstNotifiedAt), + checkRequired("startedAt", startedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OngoingNegotiations = apply { + if (validated) { + return@apply + } + + explanation() + issuerFirstNotifiedAt() + startedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (issuerFirstNotifiedAt.asKnown().isPresent) 1 else 0) + + (if (startedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OngoingNegotiations && + explanation == other.explanation && + issuerFirstNotifiedAt == other.issuerFirstNotifiedAt && + startedAt == other.startedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + issuerFirstNotifiedAt, + startedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OngoingNegotiations{explanation=$explanation, issuerFirstNotifiedAt=$issuerFirstNotifiedAt, startedAt=$startedAt, additionalProperties=$additionalProperties}" + } + + /** + * Return attempted. Required if and only if `return_outcome` is `return_attempted`. + */ + class ReturnAttempted + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val attemptExplanation: JsonField, + private val attemptReason: JsonField, + private val attemptedAt: JsonField, + private val merchandiseDisposition: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("attempt_explanation") + @ExcludeMissing + attemptExplanation: JsonField = JsonMissing.of(), + @JsonProperty("attempt_reason") + @ExcludeMissing + attemptReason: JsonField = JsonMissing.of(), + @JsonProperty("attempted_at") + @ExcludeMissing + attemptedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchandise_disposition") + @ExcludeMissing + merchandiseDisposition: JsonField = JsonMissing.of(), + ) : this( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + mutableMapOf(), + ) + + /** + * Attempt explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptExplanation(): String = + attemptExplanation.getRequired("attempt_explanation") + + /** + * Attempt reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptReason(): AttemptReason = attemptReason.getRequired("attempt_reason") + + /** + * Attempted at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun attemptedAt(): LocalDate = attemptedAt.getRequired("attempted_at") + + /** + * Merchandise disposition. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchandiseDisposition(): String = + merchandiseDisposition.getRequired("merchandise_disposition") + + /** + * Returns the raw JSON value of [attemptExplanation]. + * + * Unlike [attemptExplanation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("attempt_explanation") + @ExcludeMissing + fun _attemptExplanation(): JsonField = attemptExplanation + + /** + * Returns the raw JSON value of [attemptReason]. + * + * Unlike [attemptReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempt_reason") + @ExcludeMissing + fun _attemptReason(): JsonField = attemptReason + + /** + * Returns the raw JSON value of [attemptedAt]. + * + * Unlike [attemptedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attempted_at") + @ExcludeMissing + fun _attemptedAt(): JsonField = attemptedAt + + /** + * Returns the raw JSON value of [merchandiseDisposition]. + * + * Unlike [merchandiseDisposition], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchandise_disposition") + @ExcludeMissing + fun _merchandiseDisposition(): JsonField = merchandiseDisposition + + @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 + * [ReturnAttempted]. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ReturnAttempted]. */ + class Builder internal constructor() { + + private var attemptExplanation: JsonField? = null + private var attemptReason: JsonField? = null + private var attemptedAt: JsonField? = null + private var merchandiseDisposition: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returnAttempted: ReturnAttempted) = apply { + attemptExplanation = returnAttempted.attemptExplanation + attemptReason = returnAttempted.attemptReason + attemptedAt = returnAttempted.attemptedAt + merchandiseDisposition = returnAttempted.merchandiseDisposition + additionalProperties = + returnAttempted.additionalProperties.toMutableMap() + } + + /** Attempt explanation. */ + fun attemptExplanation(attemptExplanation: String) = + attemptExplanation(JsonField.of(attemptExplanation)) + + /** + * Sets [Builder.attemptExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun attemptExplanation(attemptExplanation: JsonField) = apply { + this.attemptExplanation = attemptExplanation + } + + /** Attempt reason. */ + fun attemptReason(attemptReason: AttemptReason) = + attemptReason(JsonField.of(attemptReason)) + + /** + * Sets [Builder.attemptReason] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptReason] with a well-typed + * [AttemptReason] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attemptReason(attemptReason: JsonField) = apply { + this.attemptReason = attemptReason + } + + /** Attempted at. */ + fun attemptedAt(attemptedAt: LocalDate) = + attemptedAt(JsonField.of(attemptedAt)) + + /** + * Sets [Builder.attemptedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.attemptedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun attemptedAt(attemptedAt: JsonField) = apply { + this.attemptedAt = attemptedAt + } + + /** Merchandise disposition. */ + fun merchandiseDisposition(merchandiseDisposition: String) = + merchandiseDisposition(JsonField.of(merchandiseDisposition)) + + /** + * Sets [Builder.merchandiseDisposition] to an arbitrary JSON value. + * + * You should usually call [Builder.merchandiseDisposition] with a + * well-typed [String] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchandiseDisposition(merchandiseDisposition: JsonField) = + apply { + this.merchandiseDisposition = merchandiseDisposition + } + + 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 [ReturnAttempted]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attemptExplanation() + * .attemptReason() + * .attemptedAt() + * .merchandiseDisposition() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ReturnAttempted = + ReturnAttempted( + checkRequired("attemptExplanation", attemptExplanation), + checkRequired("attemptReason", attemptReason), + checkRequired("attemptedAt", attemptedAt), + checkRequired("merchandiseDisposition", merchandiseDisposition), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ReturnAttempted = apply { + if (validated) { + return@apply + } + + attemptExplanation() + attemptReason().validate() + attemptedAt() + merchandiseDisposition() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (attemptExplanation.asKnown().isPresent) 1 else 0) + + (attemptReason.asKnown().getOrNull()?.validity() ?: 0) + + (if (attemptedAt.asKnown().isPresent) 1 else 0) + + (if (merchandiseDisposition.asKnown().isPresent) 1 else 0) + + /** Attempt reason. */ + class AttemptReason + @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 { + + /** Merchant not responding. */ + @JvmField val MERCHANT_NOT_RESPONDING = of("merchant_not_responding") + + /** No return authorization provided. */ + @JvmField + val NO_RETURN_AUTHORIZATION_PROVIDED = + of("no_return_authorization_provided") + + /** No return instructions. */ + @JvmField val NO_RETURN_INSTRUCTIONS = of("no_return_instructions") + + /** Requested not to return. */ + @JvmField val REQUESTED_NOT_TO_RETURN = of("requested_not_to_return") + + /** Return not accepted. */ + @JvmField val RETURN_NOT_ACCEPTED = of("return_not_accepted") + + @JvmStatic fun of(value: String) = AttemptReason(JsonField.of(value)) + } + + /** An enum containing [AttemptReason]'s known values. */ + enum class Known { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + } + + /** + * An enum containing [AttemptReason]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AttemptReason] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Merchant not responding. */ + MERCHANT_NOT_RESPONDING, + /** No return authorization provided. */ + NO_RETURN_AUTHORIZATION_PROVIDED, + /** No return instructions. */ + NO_RETURN_INSTRUCTIONS, + /** Requested not to return. */ + REQUESTED_NOT_TO_RETURN, + /** Return not accepted. */ + RETURN_NOT_ACCEPTED, + /** + * An enum member indicating that [AttemptReason] 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) { + MERCHANT_NOT_RESPONDING -> Value.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Value.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Value.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Value.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Value.RETURN_NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + MERCHANT_NOT_RESPONDING -> Known.MERCHANT_NOT_RESPONDING + NO_RETURN_AUTHORIZATION_PROVIDED -> + Known.NO_RETURN_AUTHORIZATION_PROVIDED + NO_RETURN_INSTRUCTIONS -> Known.NO_RETURN_INSTRUCTIONS + REQUESTED_NOT_TO_RETURN -> Known.REQUESTED_NOT_TO_RETURN + RETURN_NOT_ACCEPTED -> Known.RETURN_NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AttemptReason: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AttemptReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AttemptReason && 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 ReturnAttempted && + attemptExplanation == other.attemptExplanation && + attemptReason == other.attemptReason && + attemptedAt == other.attemptedAt && + merchandiseDisposition == other.merchandiseDisposition && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + attemptExplanation, + attemptReason, + attemptedAt, + merchandiseDisposition, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ReturnAttempted{attemptExplanation=$attemptExplanation, attemptReason=$attemptReason, attemptedAt=$attemptedAt, merchandiseDisposition=$merchandiseDisposition, additionalProperties=$additionalProperties}" + } + + /** Returned. Required if and only if `return_outcome` is `returned`. */ + class Returned + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val returnMethod: JsonField, + private val returnedAt: JsonField, + private val merchantReceivedReturnAt: JsonField, + private val otherExplanation: JsonField, + private val trackingNumber: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("return_method") + @ExcludeMissing + returnMethod: JsonField = JsonMissing.of(), + @JsonProperty("returned_at") + @ExcludeMissing + returnedAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + merchantReceivedReturnAt: JsonField = JsonMissing.of(), + @JsonProperty("other_explanation") + @ExcludeMissing + otherExplanation: JsonField = JsonMissing.of(), + @JsonProperty("tracking_number") + @ExcludeMissing + trackingNumber: JsonField = JsonMissing.of(), + ) : this( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + mutableMapOf(), + ) + + /** + * Return method. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnMethod(): ReturnMethod = returnMethod.getRequired("return_method") + + /** + * Returned at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun returnedAt(): LocalDate = returnedAt.getRequired("returned_at") + + /** + * Merchant received return at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantReceivedReturnAt(): Optional = + merchantReceivedReturnAt.getOptional("merchant_received_return_at") + + /** + * Other explanation. Required if and only if the return method is `other`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherExplanation(): Optional = + otherExplanation.getOptional("other_explanation") + + /** + * Tracking number. + * + * @throws IncreaseInvalidDataException 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 [returnMethod]. + * + * Unlike [returnMethod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("return_method") + @ExcludeMissing + fun _returnMethod(): JsonField = returnMethod + + /** + * Returns the raw JSON value of [returnedAt]. + * + * Unlike [returnedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("returned_at") + @ExcludeMissing + fun _returnedAt(): JsonField = returnedAt + + /** + * Returns the raw JSON value of [merchantReceivedReturnAt]. + * + * Unlike [merchantReceivedReturnAt], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("merchant_received_return_at") + @ExcludeMissing + fun _merchantReceivedReturnAt(): JsonField = merchantReceivedReturnAt + + /** + * Returns the raw JSON value of [otherExplanation]. + * + * Unlike [otherExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("other_explanation") + @ExcludeMissing + fun _otherExplanation(): JsonField = otherExplanation + + /** + * 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 [Returned]. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Returned]. */ + class Builder internal constructor() { + + private var returnMethod: JsonField? = null + private var returnedAt: JsonField? = null + private var merchantReceivedReturnAt: JsonField = + JsonMissing.of() + private var otherExplanation: JsonField = JsonMissing.of() + private var trackingNumber: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(returned: Returned) = apply { + returnMethod = returned.returnMethod + returnedAt = returned.returnedAt + merchantReceivedReturnAt = returned.merchantReceivedReturnAt + otherExplanation = returned.otherExplanation + trackingNumber = returned.trackingNumber + additionalProperties = returned.additionalProperties.toMutableMap() + } + + /** Return method. */ + fun returnMethod(returnMethod: ReturnMethod) = + returnMethod(JsonField.of(returnMethod)) + + /** + * Sets [Builder.returnMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.returnMethod] with a well-typed + * [ReturnMethod] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun returnMethod(returnMethod: JsonField) = apply { + this.returnMethod = returnMethod + } + + /** Returned at. */ + fun returnedAt(returnedAt: LocalDate) = returnedAt(JsonField.of(returnedAt)) + + /** + * Sets [Builder.returnedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.returnedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun returnedAt(returnedAt: JsonField) = apply { + this.returnedAt = returnedAt + } + + /** Merchant received return at. */ + fun merchantReceivedReturnAt(merchantReceivedReturnAt: LocalDate) = + merchantReceivedReturnAt(JsonField.of(merchantReceivedReturnAt)) + + /** + * Sets [Builder.merchantReceivedReturnAt] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantReceivedReturnAt] with a + * well-typed [LocalDate] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun merchantReceivedReturnAt( + merchantReceivedReturnAt: JsonField + ) = apply { this.merchantReceivedReturnAt = merchantReceivedReturnAt } + + /** + * Other explanation. Required if and only if the return method is `other`. + */ + fun otherExplanation(otherExplanation: String) = + otherExplanation(JsonField.of(otherExplanation)) + + /** + * Sets [Builder.otherExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.otherExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun otherExplanation(otherExplanation: JsonField) = apply { + this.otherExplanation = otherExplanation + } + + /** Tracking number. */ + fun trackingNumber(trackingNumber: String) = + trackingNumber(JsonField.of(trackingNumber)) + + /** + * 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 [Returned]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .returnMethod() + * .returnedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Returned = + Returned( + checkRequired("returnMethod", returnMethod), + checkRequired("returnedAt", returnedAt), + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Returned = apply { + if (validated) { + return@apply + } + + returnMethod().validate() + returnedAt() + merchantReceivedReturnAt() + otherExplanation() + trackingNumber() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (returnMethod.asKnown().getOrNull()?.validity() ?: 0) + + (if (returnedAt.asKnown().isPresent) 1 else 0) + + (if (merchantReceivedReturnAt.asKnown().isPresent) 1 else 0) + + (if (otherExplanation.asKnown().isPresent) 1 else 0) + + (if (trackingNumber.asKnown().isPresent) 1 else 0) + + /** Return method. */ + class ReturnMethod + @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 { + + /** DHL. */ + @JvmField val DHL = of("dhl") + + /** Face-to-face. */ + @JvmField val FACE_TO_FACE = of("face_to_face") + + /** FedEx. */ + @JvmField val FEDEX = of("fedex") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Postal service. */ + @JvmField val POSTAL_SERVICE = of("postal_service") + + /** UPS. */ + @JvmField val UPS = of("ups") + + @JvmStatic fun of(value: String) = ReturnMethod(JsonField.of(value)) + } + + /** An enum containing [ReturnMethod]'s known values. */ + enum class Known { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + } + + /** + * An enum containing [ReturnMethod]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [ReturnMethod] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** DHL. */ + DHL, + /** Face-to-face. */ + FACE_TO_FACE, + /** FedEx. */ + FEDEX, + /** Other. */ + OTHER, + /** Postal service. */ + POSTAL_SERVICE, + /** UPS. */ + UPS, + /** + * An enum member indicating that [ReturnMethod] 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) { + DHL -> Value.DHL + FACE_TO_FACE -> Value.FACE_TO_FACE + FEDEX -> Value.FEDEX + OTHER -> Value.OTHER + POSTAL_SERVICE -> Value.POSTAL_SERVICE + UPS -> Value.UPS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + DHL -> Known.DHL + FACE_TO_FACE -> Known.FACE_TO_FACE + FEDEX -> Known.FEDEX + OTHER -> Known.OTHER + POSTAL_SERVICE -> Known.POSTAL_SERVICE + UPS -> Known.UPS + else -> + throw IncreaseInvalidDataException( + "Unknown ReturnMethod: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReturnMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReturnMethod && 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 Returned && + returnMethod == other.returnMethod && + returnedAt == other.returnedAt && + merchantReceivedReturnAt == other.merchantReceivedReturnAt && + otherExplanation == other.otherExplanation && + trackingNumber == other.trackingNumber && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + returnMethod, + returnedAt, + merchantReceivedReturnAt, + otherExplanation, + trackingNumber, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Returned{returnMethod=$returnMethod, returnedAt=$returnedAt, merchantReceivedReturnAt=$merchantReceivedReturnAt, otherExplanation=$otherExplanation, trackingNumber=$trackingNumber, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerQualityMerchandise && + expectedAt == other.expectedAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseInfoAndQualityIssue == other.purchaseInfoAndQualityIssue && + receivedAt == other.receivedAt && + returnOutcome == other.returnOutcome && + notReturned == other.notReturned && + ongoingNegotiations == other.ongoingNegotiations && + returnAttempted == other.returnAttempted && + returned == other.returned && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + expectedAt, + merchantResolutionAttempted, + purchaseInfoAndQualityIssue, + receivedAt, + returnOutcome, + notReturned, + ongoingNegotiations, + returnAttempted, + returned, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerQualityMerchandise{expectedAt=$expectedAt, merchantResolutionAttempted=$merchantResolutionAttempted, purchaseInfoAndQualityIssue=$purchaseInfoAndQualityIssue, receivedAt=$receivedAt, returnOutcome=$returnOutcome, notReturned=$notReturned, ongoingNegotiations=$ongoingNegotiations, returnAttempted=$returnAttempted, returned=$returned, additionalProperties=$additionalProperties}" + } + + /** + * Services quality issue. Required if and only if `category` is + * `consumer_quality_services`. + */ + class ConsumerQualityServices + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField, + private val purchaseInfoAndQualityIssue: JsonField, + private val servicesReceivedAt: JsonField, + private val cardholderPaidToHaveWorkRedone: + JsonField, + private val ongoingNegotiations: JsonField, + private val restaurantFoodRelated: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + @ExcludeMissing + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField< + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + > = + JsonMissing.of(), + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + purchaseInfoAndQualityIssue: JsonField = JsonMissing.of(), + @JsonProperty("services_received_at") + @ExcludeMissing + servicesReceivedAt: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_paid_to_have_work_redone") + @ExcludeMissing + cardholderPaidToHaveWorkRedone: JsonField = + JsonMissing.of(), + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + ongoingNegotiations: JsonField = JsonMissing.of(), + @JsonProperty("restaurant_food_related") + @ExcludeMissing + restaurantFoodRelated: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + purchaseInfoAndQualityIssue, + servicesReceivedAt, + cardholderPaidToHaveWorkRedone, + ongoingNegotiations, + restaurantFoodRelated, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Non-fiat currency or non-fungible token related and not matching description. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription(): + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription.getRequired( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + + /** + * Purchase information and quality issue. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseInfoAndQualityIssue(): String = + purchaseInfoAndQualityIssue.getRequired("purchase_info_and_quality_issue") + + /** + * Services received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun servicesReceivedAt(): LocalDate = + servicesReceivedAt.getRequired("services_received_at") + + /** + * Cardholder paid to have work redone. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderPaidToHaveWorkRedone(): Optional = + cardholderPaidToHaveWorkRedone.getOptional( + "cardholder_paid_to_have_work_redone" + ) + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ongoingNegotiations(): Optional = + ongoingNegotiations.getOptional("ongoing_negotiations") + + /** + * Whether the dispute is related to the quality of food from an eating place or + * restaurant. Must be provided when Merchant Category Code (MCC) is 5812, 5813 + * or 5814. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun restaurantFoodRelated(): Optional = + restaurantFoodRelated.getOptional("restaurant_food_related") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of + * [nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]. + * + * Unlike [nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription], this + * method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty( + "non_fiat_currency_or_non_fungible_token_related_and_not_matching_description" + ) + @ExcludeMissing + fun _nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription(): + JsonField = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + + /** + * Returns the raw JSON value of [purchaseInfoAndQualityIssue]. + * + * Unlike [purchaseInfoAndQualityIssue], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("purchase_info_and_quality_issue") + @ExcludeMissing + fun _purchaseInfoAndQualityIssue(): JsonField = purchaseInfoAndQualityIssue + + /** + * Returns the raw JSON value of [servicesReceivedAt]. + * + * Unlike [servicesReceivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("services_received_at") + @ExcludeMissing + fun _servicesReceivedAt(): JsonField = servicesReceivedAt + + /** + * Returns the raw JSON value of [cardholderPaidToHaveWorkRedone]. + * + * Unlike [cardholderPaidToHaveWorkRedone], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("cardholder_paid_to_have_work_redone") + @ExcludeMissing + fun _cardholderPaidToHaveWorkRedone(): JsonField = + cardholderPaidToHaveWorkRedone + + /** + * Returns the raw JSON value of [ongoingNegotiations]. + * + * Unlike [ongoingNegotiations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("ongoing_negotiations") + @ExcludeMissing + fun _ongoingNegotiations(): JsonField = ongoingNegotiations + + /** + * Returns the raw JSON value of [restaurantFoodRelated]. + * + * Unlike [restaurantFoodRelated], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("restaurant_food_related") + @ExcludeMissing + fun _restaurantFoodRelated(): JsonField = + restaurantFoodRelated + + @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 + * [ConsumerQualityServices]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription() + * .purchaseInfoAndQualityIssue() + * .servicesReceivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerQualityServices]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = null + private var nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField< + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + >? = + null + private var purchaseInfoAndQualityIssue: JsonField? = null + private var servicesReceivedAt: JsonField? = null + private var cardholderPaidToHaveWorkRedone: + JsonField = + JsonMissing.of() + private var ongoingNegotiations: JsonField = + JsonMissing.of() + private var restaurantFoodRelated: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerQualityServices: ConsumerQualityServices) = apply { + cardholderCancellation = consumerQualityServices.cardholderCancellation + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + consumerQualityServices + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + purchaseInfoAndQualityIssue = + consumerQualityServices.purchaseInfoAndQualityIssue + servicesReceivedAt = consumerQualityServices.servicesReceivedAt + cardholderPaidToHaveWorkRedone = + consumerQualityServices.cardholderPaidToHaveWorkRedone + ongoingNegotiations = consumerQualityServices.ongoingNegotiations + restaurantFoodRelated = consumerQualityServices.restaurantFoodRelated + additionalProperties = + consumerQualityServices.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** + * Non-fiat currency or non-fungible token related and not matching description. + */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + ) = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + JsonField.of( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + ) + ) + + /** + * Sets + * [Builder.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] + * to an arbitrary JSON value. + * + * You should usually call + * [Builder.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] + * with a well-typed + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: + JsonField< + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + > + ) = apply { + this.nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + } + + /** Purchase information and quality issue. */ + fun purchaseInfoAndQualityIssue(purchaseInfoAndQualityIssue: String) = + purchaseInfoAndQualityIssue(JsonField.of(purchaseInfoAndQualityIssue)) + + /** + * Sets [Builder.purchaseInfoAndQualityIssue] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndQualityIssue] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun purchaseInfoAndQualityIssue( + purchaseInfoAndQualityIssue: JsonField + ) = apply { this.purchaseInfoAndQualityIssue = purchaseInfoAndQualityIssue } + + /** Services received at. */ + fun servicesReceivedAt(servicesReceivedAt: LocalDate) = + servicesReceivedAt(JsonField.of(servicesReceivedAt)) + + /** + * Sets [Builder.servicesReceivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.servicesReceivedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun servicesReceivedAt(servicesReceivedAt: JsonField) = apply { + this.servicesReceivedAt = servicesReceivedAt + } + + /** Cardholder paid to have work redone. */ + fun cardholderPaidToHaveWorkRedone( + cardholderPaidToHaveWorkRedone: CardholderPaidToHaveWorkRedone + ) = cardholderPaidToHaveWorkRedone(JsonField.of(cardholderPaidToHaveWorkRedone)) + + /** + * Sets [Builder.cardholderPaidToHaveWorkRedone] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderPaidToHaveWorkRedone] with a + * well-typed [CardholderPaidToHaveWorkRedone] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderPaidToHaveWorkRedone( + cardholderPaidToHaveWorkRedone: JsonField + ) = apply { + this.cardholderPaidToHaveWorkRedone = cardholderPaidToHaveWorkRedone + } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing + * negotiations. + */ + fun ongoingNegotiations(ongoingNegotiations: OngoingNegotiations) = + ongoingNegotiations(JsonField.of(ongoingNegotiations)) + + /** + * Sets [Builder.ongoingNegotiations] to an arbitrary JSON value. + * + * You should usually call [Builder.ongoingNegotiations] with a well-typed + * [OngoingNegotiations] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun ongoingNegotiations(ongoingNegotiations: JsonField) = + apply { + this.ongoingNegotiations = ongoingNegotiations + } + + /** + * Whether the dispute is related to the quality of food from an eating place or + * restaurant. Must be provided when Merchant Category Code (MCC) is 5812, 5813 + * or 5814. + */ + fun restaurantFoodRelated(restaurantFoodRelated: RestaurantFoodRelated) = + restaurantFoodRelated(JsonField.of(restaurantFoodRelated)) + + /** + * Sets [Builder.restaurantFoodRelated] to an arbitrary JSON value. + * + * You should usually call [Builder.restaurantFoodRelated] with a well-typed + * [RestaurantFoodRelated] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun restaurantFoodRelated( + restaurantFoodRelated: JsonField + ) = apply { this.restaurantFoodRelated = restaurantFoodRelated } + + 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 [ConsumerQualityServices]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription() + * .purchaseInfoAndQualityIssue() + * .servicesReceivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerQualityServices = + ConsumerQualityServices( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired( + "nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription", + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + ), + checkRequired( + "purchaseInfoAndQualityIssue", + purchaseInfoAndQualityIssue, + ), + checkRequired("servicesReceivedAt", servicesReceivedAt), + cardholderPaidToHaveWorkRedone, + ongoingNegotiations, + restaurantFoodRelated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerQualityServices = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription().validate() + purchaseInfoAndQualityIssue() + servicesReceivedAt() + cardholderPaidToHaveWorkRedone().ifPresent { it.validate() } + ongoingNegotiations().ifPresent { it.validate() } + restaurantFoodRelated().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .asKnown() + .getOrNull() + ?.validity() ?: 0) + + (if (purchaseInfoAndQualityIssue.asKnown().isPresent) 1 else 0) + + (if (servicesReceivedAt.asKnown().isPresent) 1 else 0) + + (cardholderPaidToHaveWorkRedone.asKnown().getOrNull()?.validity() ?: 0) + + (ongoingNegotiations.asKnown().getOrNull()?.validity() ?: 0) + + (restaurantFoodRelated.asKnown().getOrNull()?.validity() ?: 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a well-typed + * [AcceptedByMerchant] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun acceptedByMerchant(acceptedByMerchant: JsonField) = + apply { + this.acceptedByMerchant = acceptedByMerchant + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic + fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(acceptedByMerchant, canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Non-fiat currency or non-fungible token related and not matching description. */ + class NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + @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 { + + /** Not related. */ + @JvmField val NOT_RELATED = of("not_related") + + /** Related. */ + @JvmField val RELATED = of("related") + + @JvmStatic + fun of(value: String) = + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + JsonField.of(value) + ) + } + + /** + * An enum containing + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]'s known + * values. + */ + enum class Known { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + } + + /** + * An enum containing + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription]'s known + * values, as well as an [_UNKNOWN] member. + * + * An instance of + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] can + * contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + /** + * An enum member indicating that + * [NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription] 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) { + NOT_RELATED -> Value.NOT_RELATED + RELATED -> Value.RELATED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_RELATED -> Known.NOT_RELATED + RELATED -> Known.RELATED + else -> + throw IncreaseInvalidDataException( + "Unknown NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is + NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription && + value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Cardholder paid to have work redone. */ + class CardholderPaidToHaveWorkRedone + @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 { + + /** Cardholder did not pay to have work redone. */ + @JvmField + val DID_NOT_PAY_TO_HAVE_WORK_REDONE = of("did_not_pay_to_have_work_redone") + + /** Cardholder paid to have work redone. */ + @JvmField val PAID_TO_HAVE_WORK_REDONE = of("paid_to_have_work_redone") + + @JvmStatic + fun of(value: String) = CardholderPaidToHaveWorkRedone(JsonField.of(value)) + } + + /** An enum containing [CardholderPaidToHaveWorkRedone]'s known values. */ + enum class Known { + /** Cardholder did not pay to have work redone. */ + DID_NOT_PAY_TO_HAVE_WORK_REDONE, + /** Cardholder paid to have work redone. */ + PAID_TO_HAVE_WORK_REDONE, + } + + /** + * An enum containing [CardholderPaidToHaveWorkRedone]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [CardholderPaidToHaveWorkRedone] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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 did not pay to have work redone. */ + DID_NOT_PAY_TO_HAVE_WORK_REDONE, + /** Cardholder paid to have work redone. */ + PAID_TO_HAVE_WORK_REDONE, + /** + * An enum member indicating that [CardholderPaidToHaveWorkRedone] 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) { + DID_NOT_PAY_TO_HAVE_WORK_REDONE -> Value.DID_NOT_PAY_TO_HAVE_WORK_REDONE + PAID_TO_HAVE_WORK_REDONE -> Value.PAID_TO_HAVE_WORK_REDONE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DID_NOT_PAY_TO_HAVE_WORK_REDONE -> Known.DID_NOT_PAY_TO_HAVE_WORK_REDONE + PAID_TO_HAVE_WORK_REDONE -> Known.PAID_TO_HAVE_WORK_REDONE + else -> + throw IncreaseInvalidDataException( + "Unknown CardholderPaidToHaveWorkRedone: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CardholderPaidToHaveWorkRedone = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderPaidToHaveWorkRedone && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Ongoing negotiations. Exclude if there is no evidence of ongoing negotiations. + */ + class OngoingNegotiations + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val explanation: JsonField, + private val issuerFirstNotifiedAt: JsonField, + private val startedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + issuerFirstNotifiedAt: JsonField = JsonMissing.of(), + @JsonProperty("started_at") + @ExcludeMissing + startedAt: JsonField = JsonMissing.of(), + ) : this(explanation, issuerFirstNotifiedAt, startedAt, mutableMapOf()) + + /** + * Explanation of the previous ongoing negotiations between the cardholder and + * merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun explanation(): String = explanation.getRequired("explanation") + + /** + * Date the cardholder first notified the issuer of the dispute. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun issuerFirstNotifiedAt(): LocalDate = + issuerFirstNotifiedAt.getRequired("issuer_first_notified_at") + + /** + * Started at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun startedAt(): LocalDate = startedAt.getRequired("started_at") + + /** + * 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 [issuerFirstNotifiedAt]. + * + * Unlike [issuerFirstNotifiedAt], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("issuer_first_notified_at") + @ExcludeMissing + fun _issuerFirstNotifiedAt(): JsonField = issuerFirstNotifiedAt + + /** + * Returns the raw JSON value of [startedAt]. + * + * Unlike [startedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("started_at") + @ExcludeMissing + fun _startedAt(): JsonField = startedAt + + @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 + * [OngoingNegotiations]. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OngoingNegotiations]. */ + class Builder internal constructor() { + + private var explanation: JsonField? = null + private var issuerFirstNotifiedAt: JsonField? = null + private var startedAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(ongoingNegotiations: OngoingNegotiations) = apply { + explanation = ongoingNegotiations.explanation + issuerFirstNotifiedAt = ongoingNegotiations.issuerFirstNotifiedAt + startedAt = ongoingNegotiations.startedAt + additionalProperties = + ongoingNegotiations.additionalProperties.toMutableMap() + } + + /** + * Explanation of the previous ongoing negotiations between the cardholder + * and merchant. + */ + fun explanation(explanation: String) = + explanation(JsonField.of(explanation)) + + /** + * 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 + } + + /** Date the cardholder first notified the issuer of the dispute. */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: LocalDate) = + issuerFirstNotifiedAt(JsonField.of(issuerFirstNotifiedAt)) + + /** + * Sets [Builder.issuerFirstNotifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.issuerFirstNotifiedAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun issuerFirstNotifiedAt(issuerFirstNotifiedAt: JsonField) = + apply { + this.issuerFirstNotifiedAt = issuerFirstNotifiedAt + } + + /** Started at. */ + fun startedAt(startedAt: LocalDate) = startedAt(JsonField.of(startedAt)) + + /** + * Sets [Builder.startedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.startedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun startedAt(startedAt: JsonField) = apply { + this.startedAt = startedAt + } + + 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 [OngoingNegotiations]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .explanation() + * .issuerFirstNotifiedAt() + * .startedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OngoingNegotiations = + OngoingNegotiations( + checkRequired("explanation", explanation), + checkRequired("issuerFirstNotifiedAt", issuerFirstNotifiedAt), + checkRequired("startedAt", startedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OngoingNegotiations = apply { + if (validated) { + return@apply + } + + explanation() + issuerFirstNotifiedAt() + startedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (explanation.asKnown().isPresent) 1 else 0) + + (if (issuerFirstNotifiedAt.asKnown().isPresent) 1 else 0) + + (if (startedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OngoingNegotiations && + explanation == other.explanation && + issuerFirstNotifiedAt == other.issuerFirstNotifiedAt && + startedAt == other.startedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + explanation, + issuerFirstNotifiedAt, + startedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OngoingNegotiations{explanation=$explanation, issuerFirstNotifiedAt=$issuerFirstNotifiedAt, startedAt=$startedAt, additionalProperties=$additionalProperties}" + } + + /** + * Whether the dispute is related to the quality of food from an eating place or + * restaurant. Must be provided when Merchant Category Code (MCC) is 5812, 5813 + * or 5814. + */ + class RestaurantFoodRelated + @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 { + + /** Not related. */ + @JvmField val NOT_RELATED = of("not_related") + + /** Related. */ + @JvmField val RELATED = of("related") + + @JvmStatic + fun of(value: String) = RestaurantFoodRelated(JsonField.of(value)) + } + + /** An enum containing [RestaurantFoodRelated]'s known values. */ + enum class Known { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + } + + /** + * An enum containing [RestaurantFoodRelated]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [RestaurantFoodRelated] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Not related. */ + NOT_RELATED, + /** Related. */ + RELATED, + /** + * An enum member indicating that [RestaurantFoodRelated] 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) { + NOT_RELATED -> Value.NOT_RELATED + RELATED -> Value.RELATED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + NOT_RELATED -> Known.NOT_RELATED + RELATED -> Known.RELATED + else -> + throw IncreaseInvalidDataException( + "Unknown RestaurantFoodRelated: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): RestaurantFoodRelated = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RestaurantFoodRelated && 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 ConsumerQualityServices && + cardholderCancellation == other.cardholderCancellation && + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription == + other + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription && + purchaseInfoAndQualityIssue == other.purchaseInfoAndQualityIssue && + servicesReceivedAt == other.servicesReceivedAt && + cardholderPaidToHaveWorkRedone == other.cardholderPaidToHaveWorkRedone && + ongoingNegotiations == other.ongoingNegotiations && + restaurantFoodRelated == other.restaurantFoodRelated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, + purchaseInfoAndQualityIssue, + servicesReceivedAt, + cardholderPaidToHaveWorkRedone, + ongoingNegotiations, + restaurantFoodRelated, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerQualityServices{cardholderCancellation=$cardholderCancellation, nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription=$nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription, purchaseInfoAndQualityIssue=$purchaseInfoAndQualityIssue, servicesReceivedAt=$servicesReceivedAt, cardholderPaidToHaveWorkRedone=$cardholderPaidToHaveWorkRedone, ongoingNegotiations=$ongoingNegotiations, restaurantFoodRelated=$restaurantFoodRelated, additionalProperties=$additionalProperties}" + } + + /** + * Services misrepresentation. Required if and only if `category` is + * `consumer_services_misrepresentation`. + */ + class ConsumerServicesMisrepresentation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val misrepresentationExplanation: JsonField, + private val purchaseExplanation: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + misrepresentationExplanation: JsonField = JsonMissing.of(), + @JsonProperty("purchase_explanation") + @ExcludeMissing + purchaseExplanation: JsonField = JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Misrepresentation explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun misrepresentationExplanation(): String = + misrepresentationExplanation.getRequired("misrepresentation_explanation") + + /** + * Purchase explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseExplanation(): String = + purchaseExplanation.getRequired("purchase_explanation") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [misrepresentationExplanation]. + * + * Unlike [misrepresentationExplanation], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("misrepresentation_explanation") + @ExcludeMissing + fun _misrepresentationExplanation(): JsonField = + misrepresentationExplanation + + /** + * Returns the raw JSON value of [purchaseExplanation]. + * + * Unlike [purchaseExplanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("purchase_explanation") + @ExcludeMissing + fun _purchaseExplanation(): JsonField = purchaseExplanation + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerServicesMisrepresentation]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesMisrepresentation]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var misrepresentationExplanation: JsonField? = null + private var purchaseExplanation: JsonField? = null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerServicesMisrepresentation: ConsumerServicesMisrepresentation + ) = apply { + cardholderCancellation = + consumerServicesMisrepresentation.cardholderCancellation + merchantResolutionAttempted = + consumerServicesMisrepresentation.merchantResolutionAttempted + misrepresentationExplanation = + consumerServicesMisrepresentation.misrepresentationExplanation + purchaseExplanation = consumerServicesMisrepresentation.purchaseExplanation + receivedAt = consumerServicesMisrepresentation.receivedAt + additionalProperties = + consumerServicesMisrepresentation.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Misrepresentation explanation. */ + fun misrepresentationExplanation(misrepresentationExplanation: String) = + misrepresentationExplanation(JsonField.of(misrepresentationExplanation)) + + /** + * Sets [Builder.misrepresentationExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.misrepresentationExplanation] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun misrepresentationExplanation( + misrepresentationExplanation: JsonField + ) = apply { this.misrepresentationExplanation = misrepresentationExplanation } + + /** Purchase explanation. */ + fun purchaseExplanation(purchaseExplanation: String) = + purchaseExplanation(JsonField.of(purchaseExplanation)) + + /** + * Sets [Builder.purchaseExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseExplanation] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun purchaseExplanation(purchaseExplanation: JsonField) = apply { + this.purchaseExplanation = purchaseExplanation + } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerServicesMisrepresentation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .misrepresentationExplanation() + * .purchaseExplanation() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesMisrepresentation = + ConsumerServicesMisrepresentation( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired( + "misrepresentationExplanation", + misrepresentationExplanation, + ), + checkRequired("purchaseExplanation", purchaseExplanation), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesMisrepresentation = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + merchantResolutionAttempted().validate() + misrepresentationExplanation() + purchaseExplanation() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (misrepresentationExplanation.asKnown().isPresent) 1 else 0) + + (if (purchaseExplanation.asKnown().isPresent) 1 else 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a well-typed + * [AcceptedByMerchant] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun acceptedByMerchant(acceptedByMerchant: JsonField) = + apply { + this.acceptedByMerchant = acceptedByMerchant + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic + fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(acceptedByMerchant, canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && 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 ConsumerServicesMisrepresentation && + cardholderCancellation == other.cardholderCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + misrepresentationExplanation == other.misrepresentationExplanation && + purchaseExplanation == other.purchaseExplanation && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + merchantResolutionAttempted, + misrepresentationExplanation, + purchaseExplanation, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesMisrepresentation{cardholderCancellation=$cardholderCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, misrepresentationExplanation=$misrepresentationExplanation, purchaseExplanation=$purchaseExplanation, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Services not as described. Required if and only if `category` is + * `consumer_services_not_as_described`. + */ + class ConsumerServicesNotAsDescribed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardholderCancellation: JsonField, + private val merchantResolutionAttempted: JsonField, + private val receivedAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + cardholderCancellation: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("received_at") + @ExcludeMissing + receivedAt: JsonField = JsonMissing.of(), + ) : this( + cardholderCancellation, + merchantResolutionAttempted, + receivedAt, + mutableMapOf(), + ) + + /** + * Cardholder cancellation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cardholderCancellation(): CardholderCancellation = + cardholderCancellation.getRequired("cardholder_cancellation") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Received at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun receivedAt(): LocalDate = receivedAt.getRequired("received_at") + + /** + * Returns the raw JSON value of [cardholderCancellation]. + * + * Unlike [cardholderCancellation], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("cardholder_cancellation") + @ExcludeMissing + fun _cardholderCancellation(): JsonField = + cardholderCancellation + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [receivedAt]. + * + * Unlike [receivedAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("received_at") + @ExcludeMissing + fun _receivedAt(): JsonField = receivedAt + + @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 + * [ConsumerServicesNotAsDescribed]. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .receivedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesNotAsDescribed]. */ + class Builder internal constructor() { + + private var cardholderCancellation: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var receivedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + consumerServicesNotAsDescribed: ConsumerServicesNotAsDescribed + ) = apply { + cardholderCancellation = + consumerServicesNotAsDescribed.cardholderCancellation + merchantResolutionAttempted = + consumerServicesNotAsDescribed.merchantResolutionAttempted + receivedAt = consumerServicesNotAsDescribed.receivedAt + additionalProperties = + consumerServicesNotAsDescribed.additionalProperties.toMutableMap() + } + + /** Cardholder cancellation. */ + fun cardholderCancellation(cardholderCancellation: CardholderCancellation) = + cardholderCancellation(JsonField.of(cardholderCancellation)) + + /** + * Sets [Builder.cardholderCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.cardholderCancellation] with a well-typed + * [CardholderCancellation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun cardholderCancellation( + cardholderCancellation: JsonField + ) = apply { this.cardholderCancellation = cardholderCancellation } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Received at. */ + fun receivedAt(receivedAt: LocalDate) = receivedAt(JsonField.of(receivedAt)) + + /** + * Sets [Builder.receivedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.receivedAt] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun receivedAt(receivedAt: JsonField) = apply { + this.receivedAt = receivedAt + } + + 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 [ConsumerServicesNotAsDescribed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardholderCancellation() + * .merchantResolutionAttempted() + * .receivedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesNotAsDescribed = + ConsumerServicesNotAsDescribed( + checkRequired("cardholderCancellation", cardholderCancellation), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("receivedAt", receivedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesNotAsDescribed = apply { + if (validated) { + return@apply + } + + cardholderCancellation().validate() + merchantResolutionAttempted().validate() + receivedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cardholderCancellation.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (receivedAt.asKnown().isPresent) 1 else 0) + + /** Cardholder cancellation. */ + class CardholderCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val acceptedByMerchant: JsonField, + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + acceptedByMerchant: JsonField = JsonMissing.of(), + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(acceptedByMerchant, canceledAt, reason, mutableMapOf()) + + /** + * Accepted by merchant. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun acceptedByMerchant(): AcceptedByMerchant = + acceptedByMerchant.getRequired("accepted_by_merchant") + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [acceptedByMerchant]. + * + * Unlike [acceptedByMerchant], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("accepted_by_merchant") + @ExcludeMissing + fun _acceptedByMerchant(): JsonField = acceptedByMerchant + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellation]. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellation]. */ + class Builder internal constructor() { + + private var acceptedByMerchant: JsonField? = null + private var canceledAt: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(cardholderCancellation: CardholderCancellation) = apply { + acceptedByMerchant = cardholderCancellation.acceptedByMerchant + canceledAt = cardholderCancellation.canceledAt + reason = cardholderCancellation.reason + additionalProperties = + cardholderCancellation.additionalProperties.toMutableMap() + } + + /** Accepted by merchant. */ + fun acceptedByMerchant(acceptedByMerchant: AcceptedByMerchant) = + acceptedByMerchant(JsonField.of(acceptedByMerchant)) + + /** + * Sets [Builder.acceptedByMerchant] to an arbitrary JSON value. + * + * You should usually call [Builder.acceptedByMerchant] with a well-typed + * [AcceptedByMerchant] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun acceptedByMerchant(acceptedByMerchant: JsonField) = + apply { + this.acceptedByMerchant = acceptedByMerchant + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CardholderCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .acceptedByMerchant() + * .canceledAt() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellation = + CardholderCancellation( + checkRequired("acceptedByMerchant", acceptedByMerchant), + checkRequired("canceledAt", canceledAt), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellation = apply { + if (validated) { + return@apply + } + + acceptedByMerchant().validate() + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (acceptedByMerchant.asKnown().getOrNull()?.validity() ?: 0) + + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + /** Accepted by merchant. */ + class AcceptedByMerchant + @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 { + + /** Accepted. */ + @JvmField val ACCEPTED = of("accepted") + + /** Not accepted. */ + @JvmField val NOT_ACCEPTED = of("not_accepted") + + @JvmStatic + fun of(value: String) = AcceptedByMerchant(JsonField.of(value)) + } + + /** An enum containing [AcceptedByMerchant]'s known values. */ + enum class Known { + /** Accepted. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + } + + /** + * An enum containing [AcceptedByMerchant]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [AcceptedByMerchant] can contain an unknown value in a + * couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may 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. */ + ACCEPTED, + /** Not accepted. */ + NOT_ACCEPTED, + /** + * An enum member indicating that [AcceptedByMerchant] 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 + NOT_ACCEPTED -> Value.NOT_ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + NOT_ACCEPTED -> Known.NOT_ACCEPTED + else -> + throw IncreaseInvalidDataException( + "Unknown AcceptedByMerchant: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): AcceptedByMerchant = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AcceptedByMerchant && 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 CardholderCancellation && + acceptedByMerchant == other.acceptedByMerchant && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(acceptedByMerchant, canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellation{acceptedByMerchant=$acceptedByMerchant, canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && 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 ConsumerServicesNotAsDescribed && + cardholderCancellation == other.cardholderCancellation && + merchantResolutionAttempted == other.merchantResolutionAttempted && + receivedAt == other.receivedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardholderCancellation, + merchantResolutionAttempted, + receivedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesNotAsDescribed{cardholderCancellation=$cardholderCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, receivedAt=$receivedAt, additionalProperties=$additionalProperties}" + } + + /** + * Services not received. Required if and only if `category` is + * `consumer_services_not_received`. + */ + class ConsumerServicesNotReceived + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cancellationOutcome: JsonField, + private val lastExpectedReceiptAt: JsonField, + private val merchantResolutionAttempted: JsonField, + private val purchaseInfoAndExplanation: JsonField, + private val cardholderCancellationPriorToExpectedReceipt: + JsonField, + private val merchantCancellation: JsonField, + private val noCancellation: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cancellation_outcome") + @ExcludeMissing + cancellationOutcome: JsonField = JsonMissing.of(), + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + lastExpectedReceiptAt: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + purchaseInfoAndExplanation: JsonField = JsonMissing.of(), + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of(), + @JsonProperty("merchant_cancellation") + @ExcludeMissing + merchantCancellation: JsonField = JsonMissing.of(), + @JsonProperty("no_cancellation") + @ExcludeMissing + noCancellation: JsonValue = JsonMissing.of(), + ) : this( + cancellationOutcome, + lastExpectedReceiptAt, + merchantResolutionAttempted, + purchaseInfoAndExplanation, + cardholderCancellationPriorToExpectedReceipt, + merchantCancellation, + noCancellation, + mutableMapOf(), + ) + + /** + * Cancellation outcome. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun cancellationOutcome(): CancellationOutcome = + cancellationOutcome.getRequired("cancellation_outcome") + + /** + * Last expected receipt at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun lastExpectedReceiptAt(): LocalDate = + lastExpectedReceiptAt.getRequired("last_expected_receipt_at") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Purchase information and explanation. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun purchaseInfoAndExplanation(): String = + purchaseInfoAndExplanation.getRequired("purchase_info_and_explanation") + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cardholderCancellationPriorToExpectedReceipt(): + Optional = + cardholderCancellationPriorToExpectedReceipt.getOptional( + "cardholder_cancellation_prior_to_expected_receipt" + ) + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun merchantCancellation(): Optional = + merchantCancellation.getOptional("merchant_cancellation") + + /** + * No cancellation. Required if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + @JsonProperty("no_cancellation") + @ExcludeMissing + fun _noCancellation(): JsonValue = noCancellation + + /** + * Returns the raw JSON value of [cancellationOutcome]. + * + * Unlike [cancellationOutcome], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cancellation_outcome") + @ExcludeMissing + fun _cancellationOutcome(): JsonField = cancellationOutcome + + /** + * Returns the raw JSON value of [lastExpectedReceiptAt]. + * + * Unlike [lastExpectedReceiptAt], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("last_expected_receipt_at") + @ExcludeMissing + fun _lastExpectedReceiptAt(): JsonField = lastExpectedReceiptAt + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [purchaseInfoAndExplanation]. + * + * Unlike [purchaseInfoAndExplanation], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("purchase_info_and_explanation") + @ExcludeMissing + fun _purchaseInfoAndExplanation(): JsonField = purchaseInfoAndExplanation + + /** + * Returns the raw JSON value of [cardholderCancellationPriorToExpectedReceipt]. + * + * Unlike [cardholderCancellationPriorToExpectedReceipt], this method doesn't throw + * if the JSON field has an unexpected type. + */ + @JsonProperty("cardholder_cancellation_prior_to_expected_receipt") + @ExcludeMissing + fun _cardholderCancellationPriorToExpectedReceipt(): + JsonField = + cardholderCancellationPriorToExpectedReceipt + + /** + * Returns the raw JSON value of [merchantCancellation]. + * + * Unlike [merchantCancellation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_cancellation") + @ExcludeMissing + fun _merchantCancellation(): JsonField = merchantCancellation + + @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 + * [ConsumerServicesNotReceived]. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .lastExpectedReceiptAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndExplanation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerServicesNotReceived]. */ + class Builder internal constructor() { + + private var cancellationOutcome: JsonField? = null + private var lastExpectedReceiptAt: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var purchaseInfoAndExplanation: JsonField? = null + private var cardholderCancellationPriorToExpectedReceipt: + JsonField = + JsonMissing.of() + private var merchantCancellation: JsonField = + JsonMissing.of() + private var noCancellation: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(consumerServicesNotReceived: ConsumerServicesNotReceived) = + apply { + cancellationOutcome = consumerServicesNotReceived.cancellationOutcome + lastExpectedReceiptAt = + consumerServicesNotReceived.lastExpectedReceiptAt + merchantResolutionAttempted = + consumerServicesNotReceived.merchantResolutionAttempted + purchaseInfoAndExplanation = + consumerServicesNotReceived.purchaseInfoAndExplanation + cardholderCancellationPriorToExpectedReceipt = + consumerServicesNotReceived + .cardholderCancellationPriorToExpectedReceipt + merchantCancellation = consumerServicesNotReceived.merchantCancellation + noCancellation = consumerServicesNotReceived.noCancellation + additionalProperties = + consumerServicesNotReceived.additionalProperties.toMutableMap() + } + + /** Cancellation outcome. */ + fun cancellationOutcome(cancellationOutcome: CancellationOutcome) = + cancellationOutcome(JsonField.of(cancellationOutcome)) + + /** + * Sets [Builder.cancellationOutcome] to an arbitrary JSON value. + * + * You should usually call [Builder.cancellationOutcome] with a well-typed + * [CancellationOutcome] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun cancellationOutcome(cancellationOutcome: JsonField) = + apply { + this.cancellationOutcome = cancellationOutcome + } + + /** Last expected receipt at. */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: LocalDate) = + lastExpectedReceiptAt(JsonField.of(lastExpectedReceiptAt)) + + /** + * Sets [Builder.lastExpectedReceiptAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastExpectedReceiptAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun lastExpectedReceiptAt(lastExpectedReceiptAt: JsonField) = apply { + this.lastExpectedReceiptAt = lastExpectedReceiptAt + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** Purchase information and explanation. */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: String) = + purchaseInfoAndExplanation(JsonField.of(purchaseInfoAndExplanation)) + + /** + * Sets [Builder.purchaseInfoAndExplanation] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseInfoAndExplanation] with a + * well-typed [String] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun purchaseInfoAndExplanation(purchaseInfoAndExplanation: JsonField) = + apply { + this.purchaseInfoAndExplanation = purchaseInfoAndExplanation + } + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is + * `cardholder_cancellation_prior_to_expected_receipt`. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = + cardholderCancellationPriorToExpectedReceipt( + JsonField.of(cardholderCancellationPriorToExpectedReceipt) + ) + + /** + * Sets [Builder.cardholderCancellationPriorToExpectedReceipt] to an arbitrary + * JSON value. + * + * You should usually call + * [Builder.cardholderCancellationPriorToExpectedReceipt] with a well-typed + * [CardholderCancellationPriorToExpectedReceipt] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun cardholderCancellationPriorToExpectedReceipt( + cardholderCancellationPriorToExpectedReceipt: + JsonField + ) = apply { + this.cardholderCancellationPriorToExpectedReceipt = + cardholderCancellationPriorToExpectedReceipt + } + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + fun merchantCancellation(merchantCancellation: MerchantCancellation) = + merchantCancellation(JsonField.of(merchantCancellation)) + + /** + * Sets [Builder.merchantCancellation] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCancellation] with a well-typed + * [MerchantCancellation] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun merchantCancellation( + merchantCancellation: JsonField + ) = apply { this.merchantCancellation = merchantCancellation } + + /** + * No cancellation. Required if and only if `cancellation_outcome` is + * `no_cancellation`. + */ + fun noCancellation(noCancellation: JsonValue) = apply { + this.noCancellation = noCancellation + } + + 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 [ConsumerServicesNotReceived]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cancellationOutcome() + * .lastExpectedReceiptAt() + * .merchantResolutionAttempted() + * .purchaseInfoAndExplanation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ConsumerServicesNotReceived = + ConsumerServicesNotReceived( + checkRequired("cancellationOutcome", cancellationOutcome), + checkRequired("lastExpectedReceiptAt", lastExpectedReceiptAt), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + checkRequired("purchaseInfoAndExplanation", purchaseInfoAndExplanation), + cardholderCancellationPriorToExpectedReceipt, + merchantCancellation, + noCancellation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ConsumerServicesNotReceived = apply { + if (validated) { + return@apply + } + + cancellationOutcome().validate() + lastExpectedReceiptAt() + merchantResolutionAttempted().validate() + purchaseInfoAndExplanation() + cardholderCancellationPriorToExpectedReceipt().ifPresent { it.validate() } + merchantCancellation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (cancellationOutcome.asKnown().getOrNull()?.validity() ?: 0) + + (if (lastExpectedReceiptAt.asKnown().isPresent) 1 else 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (if (purchaseInfoAndExplanation.asKnown().isPresent) 1 else 0) + + (cardholderCancellationPriorToExpectedReceipt + .asKnown() + .getOrNull() + ?.validity() ?: 0) + + (merchantCancellation.asKnown().getOrNull()?.validity() ?: 0) + + /** Cancellation outcome. */ + class CancellationOutcome + @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 { + + /** Cardholder cancellation prior to expected receipt. */ + @JvmField + val CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT = + of("cardholder_cancellation_prior_to_expected_receipt") + + /** Merchant cancellation. */ + @JvmField val MERCHANT_CANCELLATION = of("merchant_cancellation") + + /** No cancellation. */ + @JvmField val NO_CANCELLATION = of("no_cancellation") + + @JvmStatic fun of(value: String) = CancellationOutcome(JsonField.of(value)) + } + + /** An enum containing [CancellationOutcome]'s known values. */ + enum class Known { + /** Cardholder cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + } + + /** + * An enum containing [CancellationOutcome]'s known values, as well as an + * [_UNKNOWN] member. + * + * An instance of [CancellationOutcome] can contain an unknown value in a couple + * of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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 cancellation prior to expected receipt. */ + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT, + /** Merchant cancellation. */ + MERCHANT_CANCELLATION, + /** No cancellation. */ + NO_CANCELLATION, + /** + * An enum member indicating that [CancellationOutcome] 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_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Value.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Value.MERCHANT_CANCELLATION + NO_CANCELLATION -> Value.NO_CANCELLATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT -> + Known.CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + MERCHANT_CANCELLATION -> Known.MERCHANT_CANCELLATION + NO_CANCELLATION -> Known.NO_CANCELLATION + else -> + throw IncreaseInvalidDataException( + "Unknown CancellationOutcome: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CancellationOutcome = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CancellationOutcome && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Cardholder cancellation prior to expected receipt. Required if and only if + * `cancellation_outcome` is `cardholder_cancellation_prior_to_expected_receipt`. + */ + class CardholderCancellationPriorToExpectedReceipt + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(canceledAt, reason, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + /** + * 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 + + @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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardholderCancellationPriorToExpectedReceipt]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + cardholderCancellationPriorToExpectedReceipt: + CardholderCancellationPriorToExpectedReceipt + ) = apply { + canceledAt = cardholderCancellationPriorToExpectedReceipt.canceledAt + reason = cardholderCancellationPriorToExpectedReceipt.reason + additionalProperties = + cardholderCancellationPriorToExpectedReceipt.additionalProperties + .toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + /** Reason. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 + * [CardholderCancellationPriorToExpectedReceipt]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardholderCancellationPriorToExpectedReceipt = + CardholderCancellationPriorToExpectedReceipt( + checkRequired("canceledAt", canceledAt), + reason, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CardholderCancellationPriorToExpectedReceipt = apply { + if (validated) { + return@apply + } + + canceledAt() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (canceledAt.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardholderCancellationPriorToExpectedReceipt && + canceledAt == other.canceledAt && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardholderCancellationPriorToExpectedReceipt{canceledAt=$canceledAt, reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * Merchant cancellation. Required if and only if `cancellation_outcome` is + * `merchant_cancellation`. + */ + class MerchantCancellation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val canceledAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("canceled_at") + @ExcludeMissing + canceledAt: JsonField = JsonMissing.of() + ) : this(canceledAt, mutableMapOf()) + + /** + * Canceled at. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun canceledAt(): LocalDate = canceledAt.getRequired("canceled_at") + + /** + * Returns the raw JSON value of [canceledAt]. + * + * Unlike [canceledAt], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("canceled_at") + @ExcludeMissing + fun _canceledAt(): JsonField = canceledAt + + @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 + * [MerchantCancellation]. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantCancellation]. */ + class Builder internal constructor() { + + private var canceledAt: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(merchantCancellation: MerchantCancellation) = apply { + canceledAt = merchantCancellation.canceledAt + additionalProperties = + merchantCancellation.additionalProperties.toMutableMap() + } + + /** Canceled at. */ + fun canceledAt(canceledAt: LocalDate) = canceledAt(JsonField.of(canceledAt)) + + /** + * Sets [Builder.canceledAt] to an arbitrary JSON value. + * + * You should usually call [Builder.canceledAt] with a well-typed + * [LocalDate] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun canceledAt(canceledAt: JsonField) = apply { + this.canceledAt = canceledAt + } + + 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 [MerchantCancellation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .canceledAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantCancellation = + MerchantCancellation( + checkRequired("canceledAt", canceledAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantCancellation = apply { + if (validated) { + return@apply + } + + canceledAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (canceledAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantCancellation && + canceledAt == other.canceledAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(canceledAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantCancellation{canceledAt=$canceledAt, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerServicesNotReceived && + cancellationOutcome == other.cancellationOutcome && + lastExpectedReceiptAt == other.lastExpectedReceiptAt && + merchantResolutionAttempted == other.merchantResolutionAttempted && + purchaseInfoAndExplanation == other.purchaseInfoAndExplanation && + cardholderCancellationPriorToExpectedReceipt == + other.cardholderCancellationPriorToExpectedReceipt && + merchantCancellation == other.merchantCancellation && + noCancellation == other.noCancellation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cancellationOutcome, + lastExpectedReceiptAt, + merchantResolutionAttempted, + purchaseInfoAndExplanation, + cardholderCancellationPriorToExpectedReceipt, + merchantCancellation, + noCancellation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerServicesNotReceived{cancellationOutcome=$cancellationOutcome, lastExpectedReceiptAt=$lastExpectedReceiptAt, merchantResolutionAttempted=$merchantResolutionAttempted, purchaseInfoAndExplanation=$purchaseInfoAndExplanation, cardholderCancellationPriorToExpectedReceipt=$cardholderCancellationPriorToExpectedReceipt, merchantCancellation=$merchantCancellation, noCancellation=$noCancellation, additionalProperties=$additionalProperties}" + } + + /** Fraud. Required if and only if `category` is `fraud`. */ + class Fraud + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fraudType: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("fraud_type") + @ExcludeMissing + fraudType: JsonField = JsonMissing.of() + ) : this(fraudType, mutableMapOf()) + + /** + * Fraud type. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun fraudType(): FraudType = fraudType.getRequired("fraud_type") + + /** + * Returns the raw JSON value of [fraudType]. + * + * Unlike [fraudType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("fraud_type") + @ExcludeMissing + fun _fraudType(): JsonField = fraudType + + @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 [Fraud]. + * + * The following fields are required: + * ```java + * .fraudType() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Fraud]. */ + class Builder internal constructor() { + + private var fraudType: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fraud: Fraud) = apply { + fraudType = fraud.fraudType + additionalProperties = fraud.additionalProperties.toMutableMap() + } + + /** Fraud type. */ + fun fraudType(fraudType: FraudType) = fraudType(JsonField.of(fraudType)) + + /** + * Sets [Builder.fraudType] to an arbitrary JSON value. + * + * You should usually call [Builder.fraudType] with a well-typed [FraudType] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun fraudType(fraudType: JsonField) = apply { + this.fraudType = fraudType + } + + 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 [Fraud]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fraudType() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Fraud = + Fraud( + checkRequired("fraudType", fraudType), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Fraud = apply { + if (validated) { + return@apply + } + + fraudType().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (fraudType.asKnown().getOrNull()?.validity() ?: 0) + + /** Fraud type. */ + class FraudType + @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 { + + /** Account or credentials takeover. */ + @JvmField + val ACCOUNT_OR_CREDENTIALS_TAKEOVER = of("account_or_credentials_takeover") + + /** Card not received as issued. */ + @JvmField + val CARD_NOT_RECEIVED_AS_ISSUED = of("card_not_received_as_issued") + + /** Fraudulent application. */ + @JvmField val FRAUDULENT_APPLICATION = of("fraudulent_application") + + /** Fraudulent use of account number. */ + @JvmField + val FRAUDULENT_USE_OF_ACCOUNT_NUMBER = + of("fraudulent_use_of_account_number") + + /** Incorrect processing. */ + @JvmField val INCORRECT_PROCESSING = of("incorrect_processing") + + /** Issuer reported counterfeit. */ + @JvmField + val ISSUER_REPORTED_COUNTERFEIT = of("issuer_reported_counterfeit") + + /** Lost. */ + @JvmField val LOST = of("lost") + + /** Manipulation of account holder. */ + @JvmField + val MANIPULATION_OF_ACCOUNT_HOLDER = of("manipulation_of_account_holder") + + /** Merchant misrepresentation. */ + @JvmField val MERCHANT_MISREPRESENTATION = of("merchant_misrepresentation") + + /** Miscellaneous. */ + @JvmField val MISCELLANEOUS = of("miscellaneous") + + /** Stolen. */ + @JvmField val STOLEN = of("stolen") + + @JvmStatic fun of(value: String) = FraudType(JsonField.of(value)) + } + + /** An enum containing [FraudType]'s known values. */ + enum class Known { + /** Account or credentials takeover. */ + ACCOUNT_OR_CREDENTIALS_TAKEOVER, + /** Card not received as issued. */ + CARD_NOT_RECEIVED_AS_ISSUED, + /** Fraudulent application. */ + FRAUDULENT_APPLICATION, + /** Fraudulent use of account number. */ + FRAUDULENT_USE_OF_ACCOUNT_NUMBER, + /** Incorrect processing. */ + INCORRECT_PROCESSING, + /** Issuer reported counterfeit. */ + ISSUER_REPORTED_COUNTERFEIT, + /** Lost. */ + LOST, + /** Manipulation of account holder. */ + MANIPULATION_OF_ACCOUNT_HOLDER, + /** Merchant misrepresentation. */ + MERCHANT_MISREPRESENTATION, + /** Miscellaneous. */ + MISCELLANEOUS, + /** Stolen. */ + STOLEN, + } + + /** + * An enum containing [FraudType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [FraudType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * 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 or credentials takeover. */ + ACCOUNT_OR_CREDENTIALS_TAKEOVER, + /** Card not received as issued. */ + CARD_NOT_RECEIVED_AS_ISSUED, + /** Fraudulent application. */ + FRAUDULENT_APPLICATION, + /** Fraudulent use of account number. */ + FRAUDULENT_USE_OF_ACCOUNT_NUMBER, + /** Incorrect processing. */ + INCORRECT_PROCESSING, + /** Issuer reported counterfeit. */ + ISSUER_REPORTED_COUNTERFEIT, + /** Lost. */ + LOST, + /** Manipulation of account holder. */ + MANIPULATION_OF_ACCOUNT_HOLDER, + /** Merchant misrepresentation. */ + MERCHANT_MISREPRESENTATION, + /** Miscellaneous. */ + MISCELLANEOUS, + /** Stolen. */ + STOLEN, + /** + * An enum member indicating that [FraudType] 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_OR_CREDENTIALS_TAKEOVER -> Value.ACCOUNT_OR_CREDENTIALS_TAKEOVER + CARD_NOT_RECEIVED_AS_ISSUED -> Value.CARD_NOT_RECEIVED_AS_ISSUED + FRAUDULENT_APPLICATION -> Value.FRAUDULENT_APPLICATION + FRAUDULENT_USE_OF_ACCOUNT_NUMBER -> + Value.FRAUDULENT_USE_OF_ACCOUNT_NUMBER + INCORRECT_PROCESSING -> Value.INCORRECT_PROCESSING + ISSUER_REPORTED_COUNTERFEIT -> Value.ISSUER_REPORTED_COUNTERFEIT + LOST -> Value.LOST + MANIPULATION_OF_ACCOUNT_HOLDER -> Value.MANIPULATION_OF_ACCOUNT_HOLDER + MERCHANT_MISREPRESENTATION -> Value.MERCHANT_MISREPRESENTATION + MISCELLANEOUS -> Value.MISCELLANEOUS + STOLEN -> Value.STOLEN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_OR_CREDENTIALS_TAKEOVER -> Known.ACCOUNT_OR_CREDENTIALS_TAKEOVER + CARD_NOT_RECEIVED_AS_ISSUED -> Known.CARD_NOT_RECEIVED_AS_ISSUED + FRAUDULENT_APPLICATION -> Known.FRAUDULENT_APPLICATION + FRAUDULENT_USE_OF_ACCOUNT_NUMBER -> + Known.FRAUDULENT_USE_OF_ACCOUNT_NUMBER + INCORRECT_PROCESSING -> Known.INCORRECT_PROCESSING + ISSUER_REPORTED_COUNTERFEIT -> Known.ISSUER_REPORTED_COUNTERFEIT + LOST -> Known.LOST + MANIPULATION_OF_ACCOUNT_HOLDER -> Known.MANIPULATION_OF_ACCOUNT_HOLDER + MERCHANT_MISREPRESENTATION -> Known.MERCHANT_MISREPRESENTATION + MISCELLANEOUS -> Known.MISCELLANEOUS + STOLEN -> Known.STOLEN + else -> throw IncreaseInvalidDataException("Unknown FraudType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): FraudType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FraudType && 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 Fraud && + fraudType == other.fraudType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(fraudType, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Fraud{fraudType=$fraudType, additionalProperties=$additionalProperties}" + } + + /** Processing error. Required if and only if `category` is `processing_error`. */ + class ProcessingError + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val errorReason: JsonField, + private val merchantResolutionAttempted: JsonField, + private val duplicateTransaction: JsonField, + private val incorrectAmount: JsonField, + private val paidByOtherMeans: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("error_reason") + @ExcludeMissing + errorReason: JsonField = JsonMissing.of(), + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + merchantResolutionAttempted: JsonField = + JsonMissing.of(), + @JsonProperty("duplicate_transaction") + @ExcludeMissing + duplicateTransaction: JsonField = JsonMissing.of(), + @JsonProperty("incorrect_amount") + @ExcludeMissing + incorrectAmount: JsonField = JsonMissing.of(), + @JsonProperty("paid_by_other_means") + @ExcludeMissing + paidByOtherMeans: JsonField = JsonMissing.of(), + ) : this( + errorReason, + merchantResolutionAttempted, + duplicateTransaction, + incorrectAmount, + paidByOtherMeans, + mutableMapOf(), + ) + + /** + * Error reason. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun errorReason(): ErrorReason = errorReason.getRequired("error_reason") + + /** + * Merchant resolution attempted. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merchantResolutionAttempted(): MerchantResolutionAttempted = + merchantResolutionAttempted.getRequired("merchant_resolution_attempted") + + /** + * Duplicate transaction. Required if and only if `error_reason` is + * `duplicate_transaction`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun duplicateTransaction(): Optional = + duplicateTransaction.getOptional("duplicate_transaction") + + /** + * Incorrect amount. Required if and only if `error_reason` is `incorrect_amount`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun incorrectAmount(): Optional = + incorrectAmount.getOptional("incorrect_amount") + + /** + * Paid by other means. Required if and only if `error_reason` is + * `paid_by_other_means`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun paidByOtherMeans(): Optional = + paidByOtherMeans.getOptional("paid_by_other_means") + + /** + * Returns the raw JSON value of [errorReason]. + * + * Unlike [errorReason], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("error_reason") + @ExcludeMissing + fun _errorReason(): JsonField = errorReason + + /** + * Returns the raw JSON value of [merchantResolutionAttempted]. + * + * Unlike [merchantResolutionAttempted], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("merchant_resolution_attempted") + @ExcludeMissing + fun _merchantResolutionAttempted(): JsonField = + merchantResolutionAttempted + + /** + * Returns the raw JSON value of [duplicateTransaction]. + * + * Unlike [duplicateTransaction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("duplicate_transaction") + @ExcludeMissing + fun _duplicateTransaction(): JsonField = duplicateTransaction + + /** + * Returns the raw JSON value of [incorrectAmount]. + * + * Unlike [incorrectAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("incorrect_amount") + @ExcludeMissing + fun _incorrectAmount(): JsonField = incorrectAmount + + /** + * Returns the raw JSON value of [paidByOtherMeans]. + * + * Unlike [paidByOtherMeans], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("paid_by_other_means") + @ExcludeMissing + fun _paidByOtherMeans(): JsonField = paidByOtherMeans + + @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 [ProcessingError]. + * + * The following fields are required: + * ```java + * .errorReason() + * .merchantResolutionAttempted() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProcessingError]. */ + class Builder internal constructor() { + + private var errorReason: JsonField? = null + private var merchantResolutionAttempted: + JsonField? = + null + private var duplicateTransaction: JsonField = + JsonMissing.of() + private var incorrectAmount: JsonField = JsonMissing.of() + private var paidByOtherMeans: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(processingError: ProcessingError) = apply { + errorReason = processingError.errorReason + merchantResolutionAttempted = processingError.merchantResolutionAttempted + duplicateTransaction = processingError.duplicateTransaction + incorrectAmount = processingError.incorrectAmount + paidByOtherMeans = processingError.paidByOtherMeans + additionalProperties = processingError.additionalProperties.toMutableMap() + } + + /** Error reason. */ + fun errorReason(errorReason: ErrorReason) = + errorReason(JsonField.of(errorReason)) + + /** + * Sets [Builder.errorReason] to an arbitrary JSON value. + * + * You should usually call [Builder.errorReason] with a well-typed [ErrorReason] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun errorReason(errorReason: JsonField) = apply { + this.errorReason = errorReason + } + + /** Merchant resolution attempted. */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: MerchantResolutionAttempted + ) = merchantResolutionAttempted(JsonField.of(merchantResolutionAttempted)) + + /** + * Sets [Builder.merchantResolutionAttempted] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantResolutionAttempted] with a + * well-typed [MerchantResolutionAttempted] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantResolutionAttempted( + merchantResolutionAttempted: JsonField + ) = apply { this.merchantResolutionAttempted = merchantResolutionAttempted } + + /** + * Duplicate transaction. Required if and only if `error_reason` is + * `duplicate_transaction`. + */ + fun duplicateTransaction(duplicateTransaction: DuplicateTransaction) = + duplicateTransaction(JsonField.of(duplicateTransaction)) + + /** + * Sets [Builder.duplicateTransaction] to an arbitrary JSON value. + * + * You should usually call [Builder.duplicateTransaction] with a well-typed + * [DuplicateTransaction] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun duplicateTransaction( + duplicateTransaction: JsonField + ) = apply { this.duplicateTransaction = duplicateTransaction } + + /** + * Incorrect amount. Required if and only if `error_reason` is + * `incorrect_amount`. + */ + fun incorrectAmount(incorrectAmount: IncorrectAmount) = + incorrectAmount(JsonField.of(incorrectAmount)) + + /** + * Sets [Builder.incorrectAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.incorrectAmount] with a well-typed + * [IncorrectAmount] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun incorrectAmount(incorrectAmount: JsonField) = apply { + this.incorrectAmount = incorrectAmount + } + + /** + * Paid by other means. Required if and only if `error_reason` is + * `paid_by_other_means`. + */ + fun paidByOtherMeans(paidByOtherMeans: PaidByOtherMeans) = + paidByOtherMeans(JsonField.of(paidByOtherMeans)) + + /** + * Sets [Builder.paidByOtherMeans] to an arbitrary JSON value. + * + * You should usually call [Builder.paidByOtherMeans] with a well-typed + * [PaidByOtherMeans] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun paidByOtherMeans(paidByOtherMeans: JsonField) = apply { + this.paidByOtherMeans = paidByOtherMeans + } + + 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 [ProcessingError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .errorReason() + * .merchantResolutionAttempted() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProcessingError = + ProcessingError( + checkRequired("errorReason", errorReason), + checkRequired( + "merchantResolutionAttempted", + merchantResolutionAttempted, + ), + duplicateTransaction, + incorrectAmount, + paidByOtherMeans, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProcessingError = apply { + if (validated) { + return@apply + } + + errorReason().validate() + merchantResolutionAttempted().validate() + duplicateTransaction().ifPresent { it.validate() } + incorrectAmount().ifPresent { it.validate() } + paidByOtherMeans().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (errorReason.asKnown().getOrNull()?.validity() ?: 0) + + (merchantResolutionAttempted.asKnown().getOrNull()?.validity() ?: 0) + + (duplicateTransaction.asKnown().getOrNull()?.validity() ?: 0) + + (incorrectAmount.asKnown().getOrNull()?.validity() ?: 0) + + (paidByOtherMeans.asKnown().getOrNull()?.validity() ?: 0) + + /** Error reason. */ + class ErrorReason + @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 { + + /** Duplicate transaction. */ + @JvmField val DUPLICATE_TRANSACTION = of("duplicate_transaction") + + /** Incorrect amount. */ + @JvmField val INCORRECT_AMOUNT = of("incorrect_amount") + + /** Paid by other means. */ + @JvmField val PAID_BY_OTHER_MEANS = of("paid_by_other_means") + + @JvmStatic fun of(value: String) = ErrorReason(JsonField.of(value)) + } + + /** An enum containing [ErrorReason]'s known values. */ + enum class Known { + /** Duplicate transaction. */ + DUPLICATE_TRANSACTION, + /** Incorrect amount. */ + INCORRECT_AMOUNT, + /** Paid by other means. */ + PAID_BY_OTHER_MEANS, + } + + /** + * An enum containing [ErrorReason]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [ErrorReason] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Duplicate transaction. */ + DUPLICATE_TRANSACTION, + /** Incorrect amount. */ + INCORRECT_AMOUNT, + /** Paid by other means. */ + PAID_BY_OTHER_MEANS, + /** + * An enum member indicating that [ErrorReason] 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) { + DUPLICATE_TRANSACTION -> Value.DUPLICATE_TRANSACTION + INCORRECT_AMOUNT -> Value.INCORRECT_AMOUNT + PAID_BY_OTHER_MEANS -> Value.PAID_BY_OTHER_MEANS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + DUPLICATE_TRANSACTION -> Known.DUPLICATE_TRANSACTION + INCORRECT_AMOUNT -> Known.INCORRECT_AMOUNT + PAID_BY_OTHER_MEANS -> Known.PAID_BY_OTHER_MEANS + else -> + throw IncreaseInvalidDataException("Unknown ErrorReason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ErrorReason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ErrorReason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Merchant resolution attempted. */ + class MerchantResolutionAttempted + @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 { + + /** Attempted. */ + @JvmField val ATTEMPTED = of("attempted") + + /** Prohibited by local law. */ + @JvmField val PROHIBITED_BY_LOCAL_LAW = of("prohibited_by_local_law") + + @JvmStatic + fun of(value: String) = MerchantResolutionAttempted(JsonField.of(value)) + } + + /** An enum containing [MerchantResolutionAttempted]'s known values. */ + enum class Known { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + } + + /** + * An enum containing [MerchantResolutionAttempted]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [MerchantResolutionAttempted] can contain an unknown value in + * a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Attempted. */ + ATTEMPTED, + /** Prohibited by local law. */ + PROHIBITED_BY_LOCAL_LAW, + /** + * An enum member indicating that [MerchantResolutionAttempted] 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) { + ATTEMPTED -> Value.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Value.PROHIBITED_BY_LOCAL_LAW + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + ATTEMPTED -> Known.ATTEMPTED + PROHIBITED_BY_LOCAL_LAW -> Known.PROHIBITED_BY_LOCAL_LAW + else -> + throw IncreaseInvalidDataException( + "Unknown MerchantResolutionAttempted: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): MerchantResolutionAttempted = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantResolutionAttempted && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Duplicate transaction. Required if and only if `error_reason` is + * `duplicate_transaction`. + */ + class DuplicateTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val otherTransactionId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("other_transaction_id") + @ExcludeMissing + otherTransactionId: JsonField = JsonMissing.of() + ) : this(otherTransactionId, mutableMapOf()) + + /** + * Other transaction ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun otherTransactionId(): String = + otherTransactionId.getRequired("other_transaction_id") + + /** + * Returns the raw JSON value of [otherTransactionId]. + * + * Unlike [otherTransactionId], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("other_transaction_id") + @ExcludeMissing + fun _otherTransactionId(): JsonField = otherTransactionId + + @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 + * [DuplicateTransaction]. + * + * The following fields are required: + * ```java + * .otherTransactionId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DuplicateTransaction]. */ + class Builder internal constructor() { + + private var otherTransactionId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(duplicateTransaction: DuplicateTransaction) = apply { + otherTransactionId = duplicateTransaction.otherTransactionId + additionalProperties = + duplicateTransaction.additionalProperties.toMutableMap() + } + + /** Other transaction ID. */ + fun otherTransactionId(otherTransactionId: String) = + otherTransactionId(JsonField.of(otherTransactionId)) + + /** + * Sets [Builder.otherTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.otherTransactionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun otherTransactionId(otherTransactionId: JsonField) = apply { + this.otherTransactionId = otherTransactionId + } + + 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 [DuplicateTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .otherTransactionId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DuplicateTransaction = + DuplicateTransaction( + checkRequired("otherTransactionId", otherTransactionId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DuplicateTransaction = apply { + if (validated) { + return@apply + } + + otherTransactionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (otherTransactionId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DuplicateTransaction && + otherTransactionId == other.otherTransactionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(otherTransactionId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DuplicateTransaction{otherTransactionId=$otherTransactionId, additionalProperties=$additionalProperties}" + } + + /** + * Incorrect amount. Required if and only if `error_reason` is `incorrect_amount`. + */ + class IncorrectAmount + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expectedAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expected_amount") + @ExcludeMissing + expectedAmount: JsonField = JsonMissing.of() + ) : this(expectedAmount, mutableMapOf()) + + /** + * Expected amount. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun expectedAmount(): Long = expectedAmount.getRequired("expected_amount") + + /** + * Returns the raw JSON value of [expectedAmount]. + * + * Unlike [expectedAmount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("expected_amount") + @ExcludeMissing + fun _expectedAmount(): JsonField = expectedAmount + + @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 + * [IncorrectAmount]. + * + * The following fields are required: + * ```java + * .expectedAmount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IncorrectAmount]. */ + class Builder internal constructor() { + + private var expectedAmount: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(incorrectAmount: IncorrectAmount) = apply { + expectedAmount = incorrectAmount.expectedAmount + additionalProperties = + incorrectAmount.additionalProperties.toMutableMap() + } + + /** Expected amount. */ + fun expectedAmount(expectedAmount: Long) = + expectedAmount(JsonField.of(expectedAmount)) + + /** + * Sets [Builder.expectedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.expectedAmount] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun expectedAmount(expectedAmount: JsonField) = apply { + this.expectedAmount = expectedAmount + } + + 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 [IncorrectAmount]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expectedAmount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): IncorrectAmount = + IncorrectAmount( + checkRequired("expectedAmount", expectedAmount), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): IncorrectAmount = apply { + if (validated) { + return@apply + } + + expectedAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expectedAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is IncorrectAmount && + expectedAmount == other.expectedAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expectedAmount, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "IncorrectAmount{expectedAmount=$expectedAmount, additionalProperties=$additionalProperties}" + } + + /** + * Paid by other means. Required if and only if `error_reason` is + * `paid_by_other_means`. + */ + class PaidByOtherMeans + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val otherFormOfPaymentEvidence: JsonField, + private val otherTransactionId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("other_form_of_payment_evidence") + @ExcludeMissing + otherFormOfPaymentEvidence: JsonField = + JsonMissing.of(), + @JsonProperty("other_transaction_id") + @ExcludeMissing + otherTransactionId: JsonField = JsonMissing.of(), + ) : this(otherFormOfPaymentEvidence, otherTransactionId, mutableMapOf()) + + /** + * Other form of payment evidence. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun otherFormOfPaymentEvidence(): OtherFormOfPaymentEvidence = + otherFormOfPaymentEvidence.getRequired("other_form_of_payment_evidence") + + /** + * Other transaction ID. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun otherTransactionId(): Optional = + otherTransactionId.getOptional("other_transaction_id") + + /** + * Returns the raw JSON value of [otherFormOfPaymentEvidence]. + * + * Unlike [otherFormOfPaymentEvidence], this method doesn't throw if the JSON + * field has an unexpected type. + */ + @JsonProperty("other_form_of_payment_evidence") + @ExcludeMissing + fun _otherFormOfPaymentEvidence(): JsonField = + otherFormOfPaymentEvidence + + /** + * Returns the raw JSON value of [otherTransactionId]. + * + * Unlike [otherTransactionId], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("other_transaction_id") + @ExcludeMissing + fun _otherTransactionId(): JsonField = otherTransactionId + + @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 + * [PaidByOtherMeans]. + * + * The following fields are required: + * ```java + * .otherFormOfPaymentEvidence() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PaidByOtherMeans]. */ + class Builder internal constructor() { + + private var otherFormOfPaymentEvidence: + JsonField? = + null + private var otherTransactionId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(paidByOtherMeans: PaidByOtherMeans) = apply { + otherFormOfPaymentEvidence = paidByOtherMeans.otherFormOfPaymentEvidence + otherTransactionId = paidByOtherMeans.otherTransactionId + additionalProperties = + paidByOtherMeans.additionalProperties.toMutableMap() + } + + /** Other form of payment evidence. */ + fun otherFormOfPaymentEvidence( + otherFormOfPaymentEvidence: OtherFormOfPaymentEvidence + ) = otherFormOfPaymentEvidence(JsonField.of(otherFormOfPaymentEvidence)) + + /** + * Sets [Builder.otherFormOfPaymentEvidence] to an arbitrary JSON value. + * + * You should usually call [Builder.otherFormOfPaymentEvidence] with a + * well-typed [OtherFormOfPaymentEvidence] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun otherFormOfPaymentEvidence( + otherFormOfPaymentEvidence: JsonField + ) = apply { this.otherFormOfPaymentEvidence = otherFormOfPaymentEvidence } + + /** Other transaction ID. */ + fun otherTransactionId(otherTransactionId: String) = + otherTransactionId(JsonField.of(otherTransactionId)) + + /** + * Sets [Builder.otherTransactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.otherTransactionId] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun otherTransactionId(otherTransactionId: JsonField) = apply { + this.otherTransactionId = otherTransactionId + } + + 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 [PaidByOtherMeans]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .otherFormOfPaymentEvidence() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PaidByOtherMeans = + PaidByOtherMeans( + checkRequired( + "otherFormOfPaymentEvidence", + otherFormOfPaymentEvidence, + ), + otherTransactionId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PaidByOtherMeans = apply { + if (validated) { + return@apply + } + + otherFormOfPaymentEvidence().validate() + otherTransactionId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (otherFormOfPaymentEvidence.asKnown().getOrNull()?.validity() ?: 0) + + (if (otherTransactionId.asKnown().isPresent) 1 else 0) + + /** Other form of payment evidence. */ + class OtherFormOfPaymentEvidence + @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 { + + /** Canceled check. */ + @JvmField val CANCELED_CHECK = of("canceled_check") + + /** Card transaction. */ + @JvmField val CARD_TRANSACTION = of("card_transaction") + + /** Cash receipt. */ + @JvmField val CASH_RECEIPT = of("cash_receipt") + + /** Other. */ + @JvmField val OTHER = of("other") + + /** Statement. */ + @JvmField val STATEMENT = of("statement") + + /** Voucher. */ + @JvmField val VOUCHER = of("voucher") + + @JvmStatic + fun of(value: String) = OtherFormOfPaymentEvidence(JsonField.of(value)) + } + + /** An enum containing [OtherFormOfPaymentEvidence]'s known values. */ + enum class Known { + /** Canceled check. */ + CANCELED_CHECK, + /** Card transaction. */ + CARD_TRANSACTION, + /** Cash receipt. */ + CASH_RECEIPT, + /** Other. */ + OTHER, + /** Statement. */ + STATEMENT, + /** Voucher. */ + VOUCHER, + } + + /** + * An enum containing [OtherFormOfPaymentEvidence]'s known values, as well + * as an [_UNKNOWN] member. + * + * An instance of [OtherFormOfPaymentEvidence] can contain an unknown value + * in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** Canceled check. */ + CANCELED_CHECK, + /** Card transaction. */ + CARD_TRANSACTION, + /** Cash receipt. */ + CASH_RECEIPT, + /** Other. */ + OTHER, + /** Statement. */ + STATEMENT, + /** Voucher. */ + VOUCHER, + /** + * An enum member indicating that [OtherFormOfPaymentEvidence] 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) { + CANCELED_CHECK -> Value.CANCELED_CHECK + CARD_TRANSACTION -> Value.CARD_TRANSACTION + CASH_RECEIPT -> Value.CASH_RECEIPT + OTHER -> Value.OTHER + STATEMENT -> Value.STATEMENT + VOUCHER -> Value.VOUCHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + CANCELED_CHECK -> Known.CANCELED_CHECK + CARD_TRANSACTION -> Known.CARD_TRANSACTION + CASH_RECEIPT -> Known.CASH_RECEIPT + OTHER -> Known.OTHER + STATEMENT -> Known.STATEMENT + VOUCHER -> Known.VOUCHER + else -> + throw IncreaseInvalidDataException( + "Unknown OtherFormOfPaymentEvidence: $value" + ) + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): OtherFormOfPaymentEvidence = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OtherFormOfPaymentEvidence && 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 PaidByOtherMeans && + otherFormOfPaymentEvidence == other.otherFormOfPaymentEvidence && + otherTransactionId == other.otherTransactionId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + otherFormOfPaymentEvidence, + otherTransactionId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PaidByOtherMeans{otherFormOfPaymentEvidence=$otherFormOfPaymentEvidence, otherTransactionId=$otherTransactionId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProcessingError && + errorReason == other.errorReason && + merchantResolutionAttempted == other.merchantResolutionAttempted && + duplicateTransaction == other.duplicateTransaction && + incorrectAmount == other.incorrectAmount && + paidByOtherMeans == other.paidByOtherMeans && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + errorReason, + merchantResolutionAttempted, + duplicateTransaction, + incorrectAmount, + paidByOtherMeans, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProcessingError{errorReason=$errorReason, merchantResolutionAttempted=$merchantResolutionAttempted, duplicateTransaction=$duplicateTransaction, incorrectAmount=$incorrectAmount, paidByOtherMeans=$paidByOtherMeans, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Chargeback && + category == other.category && + authorization == other.authorization && + consumerCanceledMerchandise == other.consumerCanceledMerchandise && + consumerCanceledRecurringTransaction == + other.consumerCanceledRecurringTransaction && + consumerCanceledServices == other.consumerCanceledServices && + consumerCounterfeitMerchandise == other.consumerCounterfeitMerchandise && + consumerCreditNotProcessed == other.consumerCreditNotProcessed && + consumerDamagedOrDefectiveMerchandise == + other.consumerDamagedOrDefectiveMerchandise && + consumerMerchandiseMisrepresentation == + other.consumerMerchandiseMisrepresentation && + consumerMerchandiseNotAsDescribed == other.consumerMerchandiseNotAsDescribed && + consumerMerchandiseNotReceived == other.consumerMerchandiseNotReceived && + consumerNonReceiptOfCash == other.consumerNonReceiptOfCash && + consumerOriginalCreditTransactionNotAccepted == + other.consumerOriginalCreditTransactionNotAccepted && + consumerQualityMerchandise == other.consumerQualityMerchandise && + consumerQualityServices == other.consumerQualityServices && + consumerServicesMisrepresentation == other.consumerServicesMisrepresentation && + consumerServicesNotAsDescribed == other.consumerServicesNotAsDescribed && + consumerServicesNotReceived == other.consumerServicesNotReceived && + fraud == other.fraud && + processingError == other.processingError && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + category, + authorization, + consumerCanceledMerchandise, + consumerCanceledRecurringTransaction, + consumerCanceledServices, + consumerCounterfeitMerchandise, + consumerCreditNotProcessed, + consumerDamagedOrDefectiveMerchandise, + consumerMerchandiseMisrepresentation, + consumerMerchandiseNotAsDescribed, + consumerMerchandiseNotReceived, + consumerNonReceiptOfCash, + consumerOriginalCreditTransactionNotAccepted, + consumerQualityMerchandise, + consumerQualityServices, + consumerServicesMisrepresentation, + consumerServicesNotAsDescribed, + consumerServicesNotReceived, + fraud, + processingError, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Chargeback{category=$category, authorization=$authorization, consumerCanceledMerchandise=$consumerCanceledMerchandise, consumerCanceledRecurringTransaction=$consumerCanceledRecurringTransaction, consumerCanceledServices=$consumerCanceledServices, consumerCounterfeitMerchandise=$consumerCounterfeitMerchandise, consumerCreditNotProcessed=$consumerCreditNotProcessed, consumerDamagedOrDefectiveMerchandise=$consumerDamagedOrDefectiveMerchandise, consumerMerchandiseMisrepresentation=$consumerMerchandiseMisrepresentation, consumerMerchandiseNotAsDescribed=$consumerMerchandiseNotAsDescribed, consumerMerchandiseNotReceived=$consumerMerchandiseNotReceived, consumerNonReceiptOfCash=$consumerNonReceiptOfCash, consumerOriginalCreditTransactionNotAccepted=$consumerOriginalCreditTransactionNotAccepted, consumerQualityMerchandise=$consumerQualityMerchandise, consumerQualityServices=$consumerQualityServices, consumerServicesMisrepresentation=$consumerServicesMisrepresentation, consumerServicesNotAsDescribed=$consumerServicesNotAsDescribed, consumerServicesNotReceived=$consumerServicesNotReceived, fraud=$fraud, processingError=$processingError, additionalProperties=$additionalProperties}" + } + + /** + * The merchant pre-arbitration decline details for the user submission. Required if and + * only if `category` is `merchant_prearbitration_decline`. + */ + class MerchantPrearbitrationDecline + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of() + ) : this(reason, mutableMapOf()) + + /** + * The reason for declining the merchant's pre-arbitration request. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * 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 + + @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 + * [MerchantPrearbitrationDecline]. + * + * The following fields are required: + * ```java + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MerchantPrearbitrationDecline]. */ + class Builder internal constructor() { + + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(merchantPrearbitrationDecline: MerchantPrearbitrationDecline) = + apply { + reason = merchantPrearbitrationDecline.reason + additionalProperties = + merchantPrearbitrationDecline.additionalProperties.toMutableMap() + } + + /** The reason for declining the merchant's pre-arbitration request. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [MerchantPrearbitrationDecline]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MerchantPrearbitrationDecline = + MerchantPrearbitrationDecline( + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MerchantPrearbitrationDecline = apply { + if (validated) { + return@apply + } + + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MerchantPrearbitrationDecline && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(reason, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MerchantPrearbitrationDecline{reason=$reason, additionalProperties=$additionalProperties}" + } + + /** + * The user pre-arbitration details for the user submission. Required if and only if + * `category` is `user_prearbitration`. + */ + class UserPrearbitration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val reason: JsonField, + private val categoryChange: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("category_change") + @ExcludeMissing + categoryChange: JsonField = JsonMissing.of(), + ) : this(reason, categoryChange, mutableMapOf()) + + /** + * The reason for the pre-arbitration request. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Category change details for the pre-arbitration request. Should only be populated if + * the category of the dispute is being changed as part of the pre-arbitration request. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun categoryChange(): Optional = + categoryChange.getOptional("category_change") + + /** + * 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 [categoryChange]. + * + * Unlike [categoryChange], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("category_change") + @ExcludeMissing + fun _categoryChange(): JsonField = categoryChange + + @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 [UserPrearbitration]. + * + * The following fields are required: + * ```java + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserPrearbitration]. */ + class Builder internal constructor() { + + private var reason: JsonField? = null + private var categoryChange: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userPrearbitration: UserPrearbitration) = apply { + reason = userPrearbitration.reason + categoryChange = userPrearbitration.categoryChange + additionalProperties = userPrearbitration.additionalProperties.toMutableMap() + } + + /** The reason for the pre-arbitration request. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + /** + * Category change details for the pre-arbitration request. Should only be populated + * if the category of the dispute is being changed as part of the pre-arbitration + * request. + */ + fun categoryChange(categoryChange: CategoryChange) = + categoryChange(JsonField.of(categoryChange)) + + /** + * Sets [Builder.categoryChange] to an arbitrary JSON value. + * + * You should usually call [Builder.categoryChange] with a well-typed + * [CategoryChange] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun categoryChange(categoryChange: JsonField) = apply { + this.categoryChange = categoryChange + } + + 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 [UserPrearbitration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserPrearbitration = + UserPrearbitration( + checkRequired("reason", reason), + categoryChange, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserPrearbitration = apply { + if (validated) { + return@apply + } + + reason() + categoryChange().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (reason.asKnown().isPresent) 1 else 0) + + (categoryChange.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Category change details for the pre-arbitration request. Should only be populated if + * the category of the dispute is being changed as part of the pre-arbitration request. + */ + class CategoryChange + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val category: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + ) : this(category, reason, mutableMapOf()) + + /** + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun category(): Category = category.getRequired("category") + + /** + * The reason for the category change. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * 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 [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @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 [CategoryChange]. + * + * The following fields are required: + * ```java + * .category() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CategoryChange]. */ + class Builder internal constructor() { + + private var category: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(categoryChange: CategoryChange) = apply { + category = categoryChange.category + reason = categoryChange.reason + additionalProperties = categoryChange.additionalProperties.toMutableMap() + } + + 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 } + + /** The reason for the category change. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [CategoryChange]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .category() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CategoryChange = + CategoryChange( + checkRequired("category", category), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CategoryChange = apply { + if (validated) { + return@apply + } + + category().validate() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (category.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.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 { + + /** Authorization. */ + @JvmField val AUTHORIZATION = of("authorization") + + /** Consumer: canceled merchandise. */ + @JvmField + val CONSUMER_CANCELED_MERCHANDISE = of("consumer_canceled_merchandise") + + /** Consumer: canceled recurring transaction. */ + @JvmField + val CONSUMER_CANCELED_RECURRING_TRANSACTION = + of("consumer_canceled_recurring_transaction") + + /** Consumer: canceled services. */ + @JvmField val CONSUMER_CANCELED_SERVICES = of("consumer_canceled_services") + + /** Consumer: counterfeit merchandise. */ + @JvmField + val CONSUMER_COUNTERFEIT_MERCHANDISE = + of("consumer_counterfeit_merchandise") + + /** Consumer: credit not processed. */ + @JvmField + val CONSUMER_CREDIT_NOT_PROCESSED = of("consumer_credit_not_processed") + + /** Consumer: damaged or defective merchandise. */ + @JvmField + val CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE = + of("consumer_damaged_or_defective_merchandise") + + /** Consumer: merchandise misrepresentation. */ + @JvmField + val CONSUMER_MERCHANDISE_MISREPRESENTATION = + of("consumer_merchandise_misrepresentation") + + /** Consumer: merchandise not as described. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED = + of("consumer_merchandise_not_as_described") + + /** Consumer: merchandise not received. */ + @JvmField + val CONSUMER_MERCHANDISE_NOT_RECEIVED = + of("consumer_merchandise_not_received") + + /** Consumer: non-receipt of cash. */ + @JvmField + val CONSUMER_NON_RECEIPT_OF_CASH = of("consumer_non_receipt_of_cash") + + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + @JvmField + val CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED = + of("consumer_original_credit_transaction_not_accepted") + + /** Consumer: merchandise quality issue. */ + @JvmField + val CONSUMER_QUALITY_MERCHANDISE = of("consumer_quality_merchandise") + + /** Consumer: services quality issue. */ + @JvmField val CONSUMER_QUALITY_SERVICES = of("consumer_quality_services") + + /** Consumer: services misrepresentation. */ + @JvmField + val CONSUMER_SERVICES_MISREPRESENTATION = + of("consumer_services_misrepresentation") + + /** Consumer: services not as described. */ + @JvmField + val CONSUMER_SERVICES_NOT_AS_DESCRIBED = + of("consumer_services_not_as_described") + + /** Consumer: services not received. */ + @JvmField + val CONSUMER_SERVICES_NOT_RECEIVED = of("consumer_services_not_received") + + /** Fraud. */ + @JvmField val FRAUD = of("fraud") + + /** Processing error. */ + @JvmField val PROCESSING_ERROR = of("processing_error") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + } + + /** + * 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 { + /** Authorization. */ + AUTHORIZATION, + /** Consumer: canceled merchandise. */ + CONSUMER_CANCELED_MERCHANDISE, + /** Consumer: canceled recurring transaction. */ + CONSUMER_CANCELED_RECURRING_TRANSACTION, + /** Consumer: canceled services. */ + CONSUMER_CANCELED_SERVICES, + /** Consumer: counterfeit merchandise. */ + CONSUMER_COUNTERFEIT_MERCHANDISE, + /** Consumer: credit not processed. */ + CONSUMER_CREDIT_NOT_PROCESSED, + /** Consumer: damaged or defective merchandise. */ + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE, + /** Consumer: merchandise misrepresentation. */ + CONSUMER_MERCHANDISE_MISREPRESENTATION, + /** Consumer: merchandise not as described. */ + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED, + /** Consumer: merchandise not received. */ + CONSUMER_MERCHANDISE_NOT_RECEIVED, + /** Consumer: non-receipt of cash. */ + CONSUMER_NON_RECEIPT_OF_CASH, + /** Consumer: Original Credit Transaction (OCT) not accepted. */ + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED, + /** Consumer: merchandise quality issue. */ + CONSUMER_QUALITY_MERCHANDISE, + /** Consumer: services quality issue. */ + CONSUMER_QUALITY_SERVICES, + /** Consumer: services misrepresentation. */ + CONSUMER_SERVICES_MISREPRESENTATION, + /** Consumer: services not as described. */ + CONSUMER_SERVICES_NOT_AS_DESCRIBED, + /** Consumer: services not received. */ + CONSUMER_SERVICES_NOT_RECEIVED, + /** Fraud. */ + FRAUD, + /** Processing error. */ + PROCESSING_ERROR, + /** + * 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) { + AUTHORIZATION -> Value.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Value.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Value.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Value.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> + Value.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Value.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Value.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Value.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Value.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> + Value.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Value.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Value.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Value.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Value.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> + Value.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> + Value.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> Value.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Value.FRAUD + PROCESSING_ERROR -> Value.PROCESSING_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 IncreaseInvalidDataException if this class instance's value is a not + * a known member. + */ + fun known(): Known = + when (this) { + AUTHORIZATION -> Known.AUTHORIZATION + CONSUMER_CANCELED_MERCHANDISE -> Known.CONSUMER_CANCELED_MERCHANDISE + CONSUMER_CANCELED_RECURRING_TRANSACTION -> + Known.CONSUMER_CANCELED_RECURRING_TRANSACTION + CONSUMER_CANCELED_SERVICES -> Known.CONSUMER_CANCELED_SERVICES + CONSUMER_COUNTERFEIT_MERCHANDISE -> + Known.CONSUMER_COUNTERFEIT_MERCHANDISE + CONSUMER_CREDIT_NOT_PROCESSED -> Known.CONSUMER_CREDIT_NOT_PROCESSED + CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE -> + Known.CONSUMER_DAMAGED_OR_DEFECTIVE_MERCHANDISE + CONSUMER_MERCHANDISE_MISREPRESENTATION -> + Known.CONSUMER_MERCHANDISE_MISREPRESENTATION + CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED -> + Known.CONSUMER_MERCHANDISE_NOT_AS_DESCRIBED + CONSUMER_MERCHANDISE_NOT_RECEIVED -> + Known.CONSUMER_MERCHANDISE_NOT_RECEIVED + CONSUMER_NON_RECEIPT_OF_CASH -> Known.CONSUMER_NON_RECEIPT_OF_CASH + CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED -> + Known.CONSUMER_ORIGINAL_CREDIT_TRANSACTION_NOT_ACCEPTED + CONSUMER_QUALITY_MERCHANDISE -> Known.CONSUMER_QUALITY_MERCHANDISE + CONSUMER_QUALITY_SERVICES -> Known.CONSUMER_QUALITY_SERVICES + CONSUMER_SERVICES_MISREPRESENTATION -> + Known.CONSUMER_SERVICES_MISREPRESENTATION + CONSUMER_SERVICES_NOT_AS_DESCRIBED -> + Known.CONSUMER_SERVICES_NOT_AS_DESCRIBED + CONSUMER_SERVICES_NOT_RECEIVED -> Known.CONSUMER_SERVICES_NOT_RECEIVED + FRAUD -> Known.FRAUD + PROCESSING_ERROR -> Known.PROCESSING_ERROR + else -> throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CategoryChange && + category == other.category && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(category, reason, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CategoryChange{category=$category, reason=$reason, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserPrearbitration && + reason == other.reason && + categoryChange == other.categoryChange && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(reason, categoryChange, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserPrearbitration{reason=$reason, categoryChange=$categoryChange, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Visa && + category == other.category && + chargeback == other.chargeback && + merchantPrearbitrationDecline == other.merchantPrearbitrationDecline && + userPrearbitration == other.userPrearbitration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + category, + chargeback, + merchantPrearbitrationDecline, + userPrearbitration, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Visa{category=$category, chargeback=$chargeback, merchantPrearbitrationDecline=$merchantPrearbitrationDecline, userPrearbitration=$userPrearbitration, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardDisputeSubmitUserSubmissionParams && + cardDisputeId == other.cardDisputeId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cardDisputeId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardDisputeSubmitUserSubmissionParams{cardDisputeId=$cardDisputeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeWithdrawParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeWithdrawParams.kt new file mode 100644 index 000000000..1f32200a3 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDisputeWithdrawParams.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Withdraw a Card Dispute */ +class CardDisputeWithdrawParams +private constructor( + private val cardDisputeId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** The identifier of the Card Dispute to withdraw. */ + fun cardDisputeId(): Optional = Optional.ofNullable(cardDisputeId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardDisputeWithdrawParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [CardDisputeWithdrawParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeWithdrawParams]. */ + class Builder internal constructor() { + + private var cardDisputeId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardDisputeWithdrawParams: CardDisputeWithdrawParams) = apply { + cardDisputeId = cardDisputeWithdrawParams.cardDisputeId + additionalHeaders = cardDisputeWithdrawParams.additionalHeaders.toBuilder() + additionalQueryParams = cardDisputeWithdrawParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + cardDisputeWithdrawParams.additionalBodyProperties.toMutableMap() + } + + /** The identifier of the Card Dispute to withdraw. */ + fun cardDisputeId(cardDisputeId: String?) = apply { this.cardDisputeId = cardDisputeId } + + /** Alias for calling [Builder.cardDisputeId] with `cardDisputeId.orElse(null)`. */ + fun cardDisputeId(cardDisputeId: Optional) = + cardDisputeId(cardDisputeId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CardDisputeWithdrawParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardDisputeWithdrawParams = + CardDisputeWithdrawParams( + cardDisputeId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardDisputeId ?: "" + 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 CardDisputeWithdrawParams && + cardDisputeId == other.cardDisputeId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + cardDisputeId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "CardDisputeWithdrawParams{cardDisputeId=$cardDisputeId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/carddisputes/CardDisputeActionParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/carddisputes/CardDisputeActionParams.kt new file mode 100644 index 000000000..e603dd75d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/carddisputes/CardDisputeActionParams.kt @@ -0,0 +1,1580 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.carddisputes + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.increase.api.core.Enum +import com.increase.api.core.ExcludeMissing +import com.increase.api.core.JsonField +import com.increase.api.core.JsonMissing +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.checkRequired +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.errors.IncreaseInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * After a [Card Dispute](#card-disputes) is created in production, the dispute will initially be in + * a `pending_user_submission_reviewing` state. Since no review or further action happens in + * sandbox, this endpoint simulates moving a Card Dispute through its various states. + */ +class CardDisputeActionParams +private constructor( + private val cardDisputeId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The dispute you would like to action. */ + fun cardDisputeId(): Optional = Optional.ofNullable(cardDisputeId) + + /** + * The network of the Card Dispute. Details specific to the network are required under the + * sub-object with the same identifier as the network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): Network = body.network() + + /** + * The Visa-specific parameters for the taking action on the dispute. Required if and only if + * `network` is `visa`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun visa(): Optional = body.visa() + + /** + * Returns the raw JSON value of [network]. + * + * Unlike [network], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _network(): JsonField = body._network() + + /** + * Returns the raw JSON value of [visa]. + * + * Unlike [visa], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _visa(): JsonField = body._visa() + + 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 [CardDisputeActionParams]. + * + * The following fields are required: + * ```java + * .network() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardDisputeActionParams]. */ + class Builder internal constructor() { + + private var cardDisputeId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardDisputeActionParams: CardDisputeActionParams) = apply { + cardDisputeId = cardDisputeActionParams.cardDisputeId + body = cardDisputeActionParams.body.toBuilder() + additionalHeaders = cardDisputeActionParams.additionalHeaders.toBuilder() + additionalQueryParams = cardDisputeActionParams.additionalQueryParams.toBuilder() + } + + /** The dispute you would like to action. */ + fun cardDisputeId(cardDisputeId: String?) = apply { this.cardDisputeId = cardDisputeId } + + /** Alias for calling [Builder.cardDisputeId] with `cardDisputeId.orElse(null)`. */ + fun cardDisputeId(cardDisputeId: Optional) = + cardDisputeId(cardDisputeId.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: + * - [network] + * - [visa] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The network of the Card Dispute. Details specific to the network are required under the + * sub-object with the same identifier as the network. + */ + fun network(network: Network) = apply { body.network(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 { body.network(network) } + + /** + * The Visa-specific parameters for the taking action on the dispute. Required if and only + * if `network` is `visa`. + */ + fun visa(visa: Visa) = apply { body.visa(visa) } + + /** + * Sets [Builder.visa] to an arbitrary JSON value. + * + * You should usually call [Builder.visa] with a well-typed [Visa] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun visa(visa: JsonField) = apply { body.visa(visa) } + + 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 [CardDisputeActionParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .network() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardDisputeActionParams = + CardDisputeActionParams( + cardDisputeId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardDisputeId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val network: JsonField, + private val visa: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("network") @ExcludeMissing network: JsonField = JsonMissing.of(), + @JsonProperty("visa") @ExcludeMissing visa: JsonField = JsonMissing.of(), + ) : this(network, visa, mutableMapOf()) + + /** + * The network of the Card Dispute. Details specific to the network are required under the + * sub-object with the same identifier as the network. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun network(): Network = network.getRequired("network") + + /** + * The Visa-specific parameters for the taking action on the dispute. Required if and only + * if `network` is `visa`. + * + * @throws IncreaseInvalidDataException 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 [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 [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 [Body]. + * + * The following fields are required: + * ```java + * .network() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var network: JsonField? = null + private var visa: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + network = body.network + visa = body.visa + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The network of the Card Dispute. Details specific to the network are required under + * the sub-object with the same identifier as the network. + */ + 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 } + + /** + * The Visa-specific parameters for the taking action on the dispute. Required if and + * only if `network` is `visa`. + */ + fun visa(visa: Visa) = visa(JsonField.of(visa)) + + /** + * Sets [Builder.visa] to an arbitrary JSON value. + * + * You should usually call [Builder.visa] with a well-typed [Visa] 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 [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .network() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("network", network), visa, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + network().validate() + visa().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (network.asKnown().getOrNull()?.validity() ?: 0) + + (visa.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + network == other.network && + visa == other.visa && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(network, visa, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{network=$network, visa=$visa, additionalProperties=$additionalProperties}" + } + + /** + * The network of the Card Dispute. Details specific to the network are required under the + * sub-object with the same identifier as the network. + */ + 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 { + + /** Visa */ + @JvmField val VISA = of("visa") + + @JvmStatic fun of(value: String) = Network(JsonField.of(value)) + } + + /** An enum containing [Network]'s known values. */ + enum class Known { + /** Visa */ + 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 { + /** Visa */ + 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) { + 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 IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VISA -> Known.VISA + else -> throw IncreaseInvalidDataException("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 IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Network = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Network && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The Visa-specific parameters for the taking action on the dispute. Required if and only if + * `network` is `visa`. + */ + class Visa + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val action: JsonField, + private val acceptChargeback: JsonValue, + private val acceptUserSubmission: JsonValue, + private val declineUserPrearbitration: JsonValue, + private val receiveMerchantPrearbitration: JsonValue, + private val represent: JsonValue, + private val requestFurtherInformation: JsonField, + private val timeOutChargeback: JsonValue, + private val timeOutMerchantPrearbitration: JsonValue, + private val timeOutRepresentment: JsonValue, + private val timeOutUserPrearbitration: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("action") @ExcludeMissing action: JsonField = JsonMissing.of(), + @JsonProperty("accept_chargeback") + @ExcludeMissing + acceptChargeback: JsonValue = JsonMissing.of(), + @JsonProperty("accept_user_submission") + @ExcludeMissing + acceptUserSubmission: JsonValue = JsonMissing.of(), + @JsonProperty("decline_user_prearbitration") + @ExcludeMissing + declineUserPrearbitration: JsonValue = JsonMissing.of(), + @JsonProperty("receive_merchant_prearbitration") + @ExcludeMissing + receiveMerchantPrearbitration: JsonValue = JsonMissing.of(), + @JsonProperty("represent") @ExcludeMissing represent: JsonValue = JsonMissing.of(), + @JsonProperty("request_further_information") + @ExcludeMissing + requestFurtherInformation: JsonField = JsonMissing.of(), + @JsonProperty("time_out_chargeback") + @ExcludeMissing + timeOutChargeback: JsonValue = JsonMissing.of(), + @JsonProperty("time_out_merchant_prearbitration") + @ExcludeMissing + timeOutMerchantPrearbitration: JsonValue = JsonMissing.of(), + @JsonProperty("time_out_representment") + @ExcludeMissing + timeOutRepresentment: JsonValue = JsonMissing.of(), + @JsonProperty("time_out_user_prearbitration") + @ExcludeMissing + timeOutUserPrearbitration: JsonValue = JsonMissing.of(), + ) : this( + action, + acceptChargeback, + acceptUserSubmission, + declineUserPrearbitration, + receiveMerchantPrearbitration, + represent, + requestFurtherInformation, + timeOutChargeback, + timeOutMerchantPrearbitration, + timeOutRepresentment, + timeOutUserPrearbitration, + mutableMapOf(), + ) + + /** + * The action to take. Details specific to the action are required under the sub-object with + * the same identifier as the action. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * The parameters for accepting the chargeback. Required if and only if `action` is + * `accept_chargeback`. + */ + @JsonProperty("accept_chargeback") + @ExcludeMissing + fun _acceptChargeback(): JsonValue = acceptChargeback + + /** + * The parameters for accepting the user submission. Required if and only if `action` is + * `accept_user_submission`. + */ + @JsonProperty("accept_user_submission") + @ExcludeMissing + fun _acceptUserSubmission(): JsonValue = acceptUserSubmission + + /** + * The parameters for declining the prearbitration. Required if and only if `action` is + * `decline_user_prearbitration`. + */ + @JsonProperty("decline_user_prearbitration") + @ExcludeMissing + fun _declineUserPrearbitration(): JsonValue = declineUserPrearbitration + + /** + * The parameters for receiving the prearbitration. Required if and only if `action` is + * `receive_merchant_prearbitration`. + */ + @JsonProperty("receive_merchant_prearbitration") + @ExcludeMissing + fun _receiveMerchantPrearbitration(): JsonValue = receiveMerchantPrearbitration + + /** + * The parameters for re-presenting the dispute. Required if and only if `action` is + * `represent`. + */ + @JsonProperty("represent") @ExcludeMissing fun _represent(): JsonValue = represent + + /** + * The parameters for requesting further information from the user. Required if and only if + * `action` is `request_further_information`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requestFurtherInformation(): Optional = + requestFurtherInformation.getOptional("request_further_information") + + /** + * The parameters for timing out the chargeback. Required if and only if `action` is + * `time_out_chargeback`. + */ + @JsonProperty("time_out_chargeback") + @ExcludeMissing + fun _timeOutChargeback(): JsonValue = timeOutChargeback + + /** + * The parameters for timing out the merchant prearbitration. Required if and only if + * `action` is `time_out_merchant_prearbitration`. + */ + @JsonProperty("time_out_merchant_prearbitration") + @ExcludeMissing + fun _timeOutMerchantPrearbitration(): JsonValue = timeOutMerchantPrearbitration + + /** + * The parameters for timing out the re-presentment. Required if and only if `action` is + * `time_out_representment`. + */ + @JsonProperty("time_out_representment") + @ExcludeMissing + fun _timeOutRepresentment(): JsonValue = timeOutRepresentment + + /** + * The parameters for timing out the user prearbitration. Required if and only if `action` + * is `time_out_user_prearbitration`. + */ + @JsonProperty("time_out_user_prearbitration") + @ExcludeMissing + fun _timeOutUserPrearbitration(): JsonValue = timeOutUserPrearbitration + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [requestFurtherInformation]. + * + * Unlike [requestFurtherInformation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("request_further_information") + @ExcludeMissing + fun _requestFurtherInformation(): JsonField = + requestFurtherInformation + + @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 [Visa]. + * + * The following fields are required: + * ```java + * .action() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Visa]. */ + class Builder internal constructor() { + + private var action: JsonField? = null + private var acceptChargeback: JsonValue = JsonMissing.of() + private var acceptUserSubmission: JsonValue = JsonMissing.of() + private var declineUserPrearbitration: JsonValue = JsonMissing.of() + private var receiveMerchantPrearbitration: JsonValue = JsonMissing.of() + private var represent: JsonValue = JsonMissing.of() + private var requestFurtherInformation: JsonField = + JsonMissing.of() + private var timeOutChargeback: JsonValue = JsonMissing.of() + private var timeOutMerchantPrearbitration: JsonValue = JsonMissing.of() + private var timeOutRepresentment: JsonValue = JsonMissing.of() + private var timeOutUserPrearbitration: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(visa: Visa) = apply { + action = visa.action + acceptChargeback = visa.acceptChargeback + acceptUserSubmission = visa.acceptUserSubmission + declineUserPrearbitration = visa.declineUserPrearbitration + receiveMerchantPrearbitration = visa.receiveMerchantPrearbitration + represent = visa.represent + requestFurtherInformation = visa.requestFurtherInformation + timeOutChargeback = visa.timeOutChargeback + timeOutMerchantPrearbitration = visa.timeOutMerchantPrearbitration + timeOutRepresentment = visa.timeOutRepresentment + timeOutUserPrearbitration = visa.timeOutUserPrearbitration + additionalProperties = visa.additionalProperties.toMutableMap() + } + + /** + * The action to take. Details specific to the action are required under the sub-object + * with the same identifier as the action. + */ + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** + * The parameters for accepting the chargeback. Required if and only if `action` is + * `accept_chargeback`. + */ + fun acceptChargeback(acceptChargeback: JsonValue) = apply { + this.acceptChargeback = acceptChargeback + } + + /** + * The parameters for accepting the user submission. Required if and only if `action` is + * `accept_user_submission`. + */ + fun acceptUserSubmission(acceptUserSubmission: JsonValue) = apply { + this.acceptUserSubmission = acceptUserSubmission + } + + /** + * The parameters for declining the prearbitration. Required if and only if `action` is + * `decline_user_prearbitration`. + */ + fun declineUserPrearbitration(declineUserPrearbitration: JsonValue) = apply { + this.declineUserPrearbitration = declineUserPrearbitration + } + + /** + * The parameters for receiving the prearbitration. Required if and only if `action` is + * `receive_merchant_prearbitration`. + */ + fun receiveMerchantPrearbitration(receiveMerchantPrearbitration: JsonValue) = apply { + this.receiveMerchantPrearbitration = receiveMerchantPrearbitration + } + + /** + * The parameters for re-presenting the dispute. Required if and only if `action` is + * `represent`. + */ + fun represent(represent: JsonValue) = apply { this.represent = represent } + + /** + * The parameters for requesting further information from the user. Required if and only + * if `action` is `request_further_information`. + */ + fun requestFurtherInformation(requestFurtherInformation: RequestFurtherInformation) = + requestFurtherInformation(JsonField.of(requestFurtherInformation)) + + /** + * Sets [Builder.requestFurtherInformation] to an arbitrary JSON value. + * + * You should usually call [Builder.requestFurtherInformation] with a well-typed + * [RequestFurtherInformation] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun requestFurtherInformation( + requestFurtherInformation: JsonField + ) = apply { this.requestFurtherInformation = requestFurtherInformation } + + /** + * The parameters for timing out the chargeback. Required if and only if `action` is + * `time_out_chargeback`. + */ + fun timeOutChargeback(timeOutChargeback: JsonValue) = apply { + this.timeOutChargeback = timeOutChargeback + } + + /** + * The parameters for timing out the merchant prearbitration. Required if and only if + * `action` is `time_out_merchant_prearbitration`. + */ + fun timeOutMerchantPrearbitration(timeOutMerchantPrearbitration: JsonValue) = apply { + this.timeOutMerchantPrearbitration = timeOutMerchantPrearbitration + } + + /** + * The parameters for timing out the re-presentment. Required if and only if `action` is + * `time_out_representment`. + */ + fun timeOutRepresentment(timeOutRepresentment: JsonValue) = apply { + this.timeOutRepresentment = timeOutRepresentment + } + + /** + * The parameters for timing out the user prearbitration. Required if and only if + * `action` is `time_out_user_prearbitration`. + */ + fun timeOutUserPrearbitration(timeOutUserPrearbitration: JsonValue) = apply { + this.timeOutUserPrearbitration = timeOutUserPrearbitration + } + + 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 [Visa]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Visa = + Visa( + checkRequired("action", action), + acceptChargeback, + acceptUserSubmission, + declineUserPrearbitration, + receiveMerchantPrearbitration, + represent, + requestFurtherInformation, + timeOutChargeback, + timeOutMerchantPrearbitration, + timeOutRepresentment, + timeOutUserPrearbitration, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Visa = apply { + if (validated) { + return@apply + } + + action().validate() + requestFurtherInformation().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (action.asKnown().getOrNull()?.validity() ?: 0) + + (requestFurtherInformation.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The action to take. Details specific to the action are required under the sub-object with + * the same identifier as the action. + */ + class Action @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 { + + /** + * Simulate the merchant accepting the chargeback. This will move the dispute to a + * `won` state. + */ + @JvmField val ACCEPT_CHARGEBACK = of("accept_chargeback") + + /** + * Accept the user's submission and transmit it to the network. This will move the + * dispute to a `pending_response` state. + */ + @JvmField val ACCEPT_USER_SUBMISSION = of("accept_user_submission") + + /** + * Simulate the merchant declining the user's pre-arbitration. This will move the + * dispute to a `lost` state. + */ + @JvmField val DECLINE_USER_PREARBITRATION = of("decline_user_prearbitration") + + /** + * Simulate the merchant issuing pre-arbitration. This will move the dispute to a + * `user_submission_required` state. + */ + @JvmField + val RECEIVE_MERCHANT_PREARBITRATION = of("receive_merchant_prearbitration") + + /** + * Simulate the merchant re-presenting the dispute. This will move the dispute to a + * `user_submission_required` state. + */ + @JvmField val REPRESENT = of("represent") + + /** + * Simulate further information being requested from the user. This will move the + * dispute to a `user_submission_required` state. + */ + @JvmField val REQUEST_FURTHER_INFORMATION = of("request_further_information") + + /** + * Simulate the merchant timing out responding to the chargeback. This will move the + * dispute to a `won` state. + */ + @JvmField val TIME_OUT_CHARGEBACK = of("time_out_chargeback") + + /** + * Simulate the user timing out responding to a merchant pre-arbitration. This will + * move the dispute to a `lost` state. + */ + @JvmField + val TIME_OUT_MERCHANT_PREARBITRATION = of("time_out_merchant_prearbitration") + + /** + * Simulate the user timing out responding to a merchant re-presentment. This will + * move the dispute to a `lost` state. + */ + @JvmField val TIME_OUT_REPRESENTMENT = of("time_out_representment") + + /** + * Simulate the merchant timing out responding to a user pre-arbitration. This will + * move the dispute to a `win` state. + */ + @JvmField val TIME_OUT_USER_PREARBITRATION = of("time_out_user_prearbitration") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + /** + * Simulate the merchant accepting the chargeback. This will move the dispute to a + * `won` state. + */ + ACCEPT_CHARGEBACK, + /** + * Accept the user's submission and transmit it to the network. This will move the + * dispute to a `pending_response` state. + */ + ACCEPT_USER_SUBMISSION, + /** + * Simulate the merchant declining the user's pre-arbitration. This will move the + * dispute to a `lost` state. + */ + DECLINE_USER_PREARBITRATION, + /** + * Simulate the merchant issuing pre-arbitration. This will move the dispute to a + * `user_submission_required` state. + */ + RECEIVE_MERCHANT_PREARBITRATION, + /** + * Simulate the merchant re-presenting the dispute. This will move the dispute to a + * `user_submission_required` state. + */ + REPRESENT, + /** + * Simulate further information being requested from the user. This will move the + * dispute to a `user_submission_required` state. + */ + REQUEST_FURTHER_INFORMATION, + /** + * Simulate the merchant timing out responding to the chargeback. This will move the + * dispute to a `won` state. + */ + TIME_OUT_CHARGEBACK, + /** + * Simulate the user timing out responding to a merchant pre-arbitration. This will + * move the dispute to a `lost` state. + */ + TIME_OUT_MERCHANT_PREARBITRATION, + /** + * Simulate the user timing out responding to a merchant re-presentment. This will + * move the dispute to a `lost` state. + */ + TIME_OUT_REPRESENTMENT, + /** + * Simulate the merchant timing out responding to a user pre-arbitration. This will + * move the dispute to a `win` state. + */ + TIME_OUT_USER_PREARBITRATION, + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** + * Simulate the merchant accepting the chargeback. This will move the dispute to a + * `won` state. + */ + ACCEPT_CHARGEBACK, + /** + * Accept the user's submission and transmit it to the network. This will move the + * dispute to a `pending_response` state. + */ + ACCEPT_USER_SUBMISSION, + /** + * Simulate the merchant declining the user's pre-arbitration. This will move the + * dispute to a `lost` state. + */ + DECLINE_USER_PREARBITRATION, + /** + * Simulate the merchant issuing pre-arbitration. This will move the dispute to a + * `user_submission_required` state. + */ + RECEIVE_MERCHANT_PREARBITRATION, + /** + * Simulate the merchant re-presenting the dispute. This will move the dispute to a + * `user_submission_required` state. + */ + REPRESENT, + /** + * Simulate further information being requested from the user. This will move the + * dispute to a `user_submission_required` state. + */ + REQUEST_FURTHER_INFORMATION, + /** + * Simulate the merchant timing out responding to the chargeback. This will move the + * dispute to a `won` state. + */ + TIME_OUT_CHARGEBACK, + /** + * Simulate the user timing out responding to a merchant pre-arbitration. This will + * move the dispute to a `lost` state. + */ + TIME_OUT_MERCHANT_PREARBITRATION, + /** + * Simulate the user timing out responding to a merchant re-presentment. This will + * move the dispute to a `lost` state. + */ + TIME_OUT_REPRESENTMENT, + /** + * Simulate the merchant timing out responding to a user pre-arbitration. This will + * move the dispute to a `win` state. + */ + TIME_OUT_USER_PREARBITRATION, + /** + * An enum member indicating that [Action] 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) { + ACCEPT_CHARGEBACK -> Value.ACCEPT_CHARGEBACK + ACCEPT_USER_SUBMISSION -> Value.ACCEPT_USER_SUBMISSION + DECLINE_USER_PREARBITRATION -> Value.DECLINE_USER_PREARBITRATION + RECEIVE_MERCHANT_PREARBITRATION -> Value.RECEIVE_MERCHANT_PREARBITRATION + REPRESENT -> Value.REPRESENT + REQUEST_FURTHER_INFORMATION -> Value.REQUEST_FURTHER_INFORMATION + TIME_OUT_CHARGEBACK -> Value.TIME_OUT_CHARGEBACK + TIME_OUT_MERCHANT_PREARBITRATION -> Value.TIME_OUT_MERCHANT_PREARBITRATION + TIME_OUT_REPRESENTMENT -> Value.TIME_OUT_REPRESENTMENT + TIME_OUT_USER_PREARBITRATION -> Value.TIME_OUT_USER_PREARBITRATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACCEPT_CHARGEBACK -> Known.ACCEPT_CHARGEBACK + ACCEPT_USER_SUBMISSION -> Known.ACCEPT_USER_SUBMISSION + DECLINE_USER_PREARBITRATION -> Known.DECLINE_USER_PREARBITRATION + RECEIVE_MERCHANT_PREARBITRATION -> Known.RECEIVE_MERCHANT_PREARBITRATION + REPRESENT -> Known.REPRESENT + REQUEST_FURTHER_INFORMATION -> Known.REQUEST_FURTHER_INFORMATION + TIME_OUT_CHARGEBACK -> Known.TIME_OUT_CHARGEBACK + TIME_OUT_MERCHANT_PREARBITRATION -> Known.TIME_OUT_MERCHANT_PREARBITRATION + TIME_OUT_REPRESENTMENT -> Known.TIME_OUT_REPRESENTMENT + TIME_OUT_USER_PREARBITRATION -> Known.TIME_OUT_USER_PREARBITRATION + else -> throw IncreaseInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The parameters for requesting further information from the user. Required if and only if + * `action` is `request_further_information`. + */ + class RequestFurtherInformation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of() + ) : this(reason, mutableMapOf()) + + /** + * The reason for requesting further information from the user. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * 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 + + @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 + * [RequestFurtherInformation]. + * + * The following fields are required: + * ```java + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RequestFurtherInformation]. */ + class Builder internal constructor() { + + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(requestFurtherInformation: RequestFurtherInformation) = apply { + reason = requestFurtherInformation.reason + additionalProperties = + requestFurtherInformation.additionalProperties.toMutableMap() + } + + /** The reason for requesting further information from the user. */ + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] 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 } + + 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 [RequestFurtherInformation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RequestFurtherInformation = + RequestFurtherInformation( + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RequestFurtherInformation = apply { + if (validated) { + return@apply + } + + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RequestFurtherInformation && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(reason, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RequestFurtherInformation{reason=$reason, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Visa && + action == other.action && + acceptChargeback == other.acceptChargeback && + acceptUserSubmission == other.acceptUserSubmission && + declineUserPrearbitration == other.declineUserPrearbitration && + receiveMerchantPrearbitration == other.receiveMerchantPrearbitration && + represent == other.represent && + requestFurtherInformation == other.requestFurtherInformation && + timeOutChargeback == other.timeOutChargeback && + timeOutMerchantPrearbitration == other.timeOutMerchantPrearbitration && + timeOutRepresentment == other.timeOutRepresentment && + timeOutUserPrearbitration == other.timeOutUserPrearbitration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + action, + acceptChargeback, + acceptUserSubmission, + declineUserPrearbitration, + receiveMerchantPrearbitration, + represent, + requestFurtherInformation, + timeOutChargeback, + timeOutMerchantPrearbitration, + timeOutRepresentment, + timeOutUserPrearbitration, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Visa{action=$action, acceptChargeback=$acceptChargeback, acceptUserSubmission=$acceptUserSubmission, declineUserPrearbitration=$declineUserPrearbitration, receiveMerchantPrearbitration=$receiveMerchantPrearbitration, represent=$represent, requestFurtherInformation=$requestFurtherInformation, timeOutChargeback=$timeOutChargeback, timeOutMerchantPrearbitration=$timeOutMerchantPrearbitration, timeOutRepresentment=$timeOutRepresentment, timeOutUserPrearbitration=$timeOutUserPrearbitration, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardDisputeActionParams && + cardDisputeId == other.cardDisputeId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cardDisputeId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardDisputeActionParams{cardDisputeId=$cardDisputeId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardDisputeServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardDisputeServiceAsync.kt new file mode 100644 index 000000000..da5b6fddc --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardDisputeServiceAsync.kt @@ -0,0 +1,327 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.carddisputes.CardDispute +import com.increase.api.models.carddisputes.CardDisputeCreateParams +import com.increase.api.models.carddisputes.CardDisputeListPageAsync +import com.increase.api.models.carddisputes.CardDisputeListParams +import com.increase.api.models.carddisputes.CardDisputeRetrieveParams +import com.increase.api.models.carddisputes.CardDisputeSubmitUserSubmissionParams +import com.increase.api.models.carddisputes.CardDisputeWithdrawParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardDisputeServiceAsync { + + /** + * 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): CardDisputeServiceAsync + + /** Create a Card Dispute */ + fun create(params: CardDisputeCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardDisputeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Retrieve a Card Dispute */ + fun retrieve(cardDisputeId: String): CompletableFuture = + retrieve(cardDisputeId, CardDisputeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardDisputeId: String, + params: CardDisputeRetrieveParams = CardDisputeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardDisputeId: String, + params: CardDisputeRetrieveParams = CardDisputeRetrieveParams.none(), + ): CompletableFuture = retrieve(cardDisputeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardDisputeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: CardDisputeRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + cardDisputeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(cardDisputeId, CardDisputeRetrieveParams.none(), requestOptions) + + /** List Card Disputes */ + fun list(): CompletableFuture = list(CardDisputeListParams.none()) + + /** @see list */ + fun list( + params: CardDisputeListParams = CardDisputeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: CardDisputeListParams = CardDisputeListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(CardDisputeListParams.none(), requestOptions) + + /** Submit a User Submission for a Card Dispute */ + fun submitUserSubmission( + cardDisputeId: String, + params: CardDisputeSubmitUserSubmissionParams, + ): CompletableFuture = + submitUserSubmission(cardDisputeId, params, RequestOptions.none()) + + /** @see submitUserSubmission */ + fun submitUserSubmission( + cardDisputeId: String, + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + submitUserSubmission( + params.toBuilder().cardDisputeId(cardDisputeId).build(), + requestOptions, + ) + + /** @see submitUserSubmission */ + fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams + ): CompletableFuture = submitUserSubmission(params, RequestOptions.none()) + + /** @see submitUserSubmission */ + fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Withdraw a Card Dispute */ + fun withdraw(cardDisputeId: String): CompletableFuture = + withdraw(cardDisputeId, CardDisputeWithdrawParams.none()) + + /** @see withdraw */ + fun withdraw( + cardDisputeId: String, + params: CardDisputeWithdrawParams = CardDisputeWithdrawParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + withdraw(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see withdraw */ + fun withdraw( + cardDisputeId: String, + params: CardDisputeWithdrawParams = CardDisputeWithdrawParams.none(), + ): CompletableFuture = withdraw(cardDisputeId, params, RequestOptions.none()) + + /** @see withdraw */ + fun withdraw( + params: CardDisputeWithdrawParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see withdraw */ + fun withdraw(params: CardDisputeWithdrawParams): CompletableFuture = + withdraw(params, RequestOptions.none()) + + /** @see withdraw */ + fun withdraw( + cardDisputeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + withdraw(cardDisputeId, CardDisputeWithdrawParams.none(), requestOptions) + + /** + * A view of [CardDisputeServiceAsync] 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 + ): CardDisputeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /card_disputes`, but is otherwise the same as + * [CardDisputeServiceAsync.create]. + */ + fun create( + params: CardDisputeCreateParams + ): CompletableFuture> = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardDisputeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /card_disputes/{card_dispute_id}`, but is otherwise + * the same as [CardDisputeServiceAsync.retrieve]. + */ + fun retrieve(cardDisputeId: String): CompletableFuture> = + retrieve(cardDisputeId, CardDisputeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardDisputeId: String, + params: CardDisputeRetrieveParams = CardDisputeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardDisputeId: String, + params: CardDisputeRetrieveParams = CardDisputeRetrieveParams.none(), + ): CompletableFuture> = + retrieve(cardDisputeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardDisputeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: CardDisputeRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + cardDisputeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(cardDisputeId, CardDisputeRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_disputes`, but is otherwise the same as + * [CardDisputeServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(CardDisputeListParams.none()) + + /** @see list */ + fun list( + params: CardDisputeListParams = CardDisputeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: CardDisputeListParams = CardDisputeListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(CardDisputeListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /card_disputes/{card_dispute_id}/submit_user_submission`, but is otherwise the same as + * [CardDisputeServiceAsync.submitUserSubmission]. + */ + fun submitUserSubmission( + cardDisputeId: String, + params: CardDisputeSubmitUserSubmissionParams, + ): CompletableFuture> = + submitUserSubmission(cardDisputeId, params, RequestOptions.none()) + + /** @see submitUserSubmission */ + fun submitUserSubmission( + cardDisputeId: String, + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + submitUserSubmission( + params.toBuilder().cardDisputeId(cardDisputeId).build(), + requestOptions, + ) + + /** @see submitUserSubmission */ + fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams + ): CompletableFuture> = + submitUserSubmission(params, RequestOptions.none()) + + /** @see submitUserSubmission */ + fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /card_disputes/{card_dispute_id}/withdraw`, but is + * otherwise the same as [CardDisputeServiceAsync.withdraw]. + */ + fun withdraw(cardDisputeId: String): CompletableFuture> = + withdraw(cardDisputeId, CardDisputeWithdrawParams.none()) + + /** @see withdraw */ + fun withdraw( + cardDisputeId: String, + params: CardDisputeWithdrawParams = CardDisputeWithdrawParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + withdraw(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see withdraw */ + fun withdraw( + cardDisputeId: String, + params: CardDisputeWithdrawParams = CardDisputeWithdrawParams.none(), + ): CompletableFuture> = + withdraw(cardDisputeId, params, RequestOptions.none()) + + /** @see withdraw */ + fun withdraw( + params: CardDisputeWithdrawParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see withdraw */ + fun withdraw( + params: CardDisputeWithdrawParams + ): CompletableFuture> = withdraw(params, RequestOptions.none()) + + /** @see withdraw */ + fun withdraw( + cardDisputeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + withdraw(cardDisputeId, CardDisputeWithdrawParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardDisputeServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardDisputeServiceAsyncImpl.kt new file mode 100644 index 000000000..8714063fe --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/CardDisputeServiceAsyncImpl.kt @@ -0,0 +1,265 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepareAsync +import com.increase.api.models.carddisputes.CardDispute +import com.increase.api.models.carddisputes.CardDisputeCreateParams +import com.increase.api.models.carddisputes.CardDisputeListPageAsync +import com.increase.api.models.carddisputes.CardDisputeListPageResponse +import com.increase.api.models.carddisputes.CardDisputeListParams +import com.increase.api.models.carddisputes.CardDisputeRetrieveParams +import com.increase.api.models.carddisputes.CardDisputeSubmitUserSubmissionParams +import com.increase.api.models.carddisputes.CardDisputeWithdrawParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardDisputeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CardDisputeServiceAsync { + + private val withRawResponse: CardDisputeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardDisputeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardDisputeServiceAsync = + CardDisputeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardDisputeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /card_disputes + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: CardDisputeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_disputes/{card_dispute_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: CardDisputeListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /card_disputes + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /card_disputes/{card_dispute_id}/submit_user_submission + withRawResponse().submitUserSubmission(params, requestOptions).thenApply { it.parse() } + + override fun withdraw( + params: CardDisputeWithdrawParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /card_disputes/{card_dispute_id}/withdraw + withRawResponse().withdraw(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardDisputeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardDisputeServiceAsync.WithRawResponse = + CardDisputeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardDisputeCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_disputes") + .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: CardDisputeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardDisputeId", params.cardDisputeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_disputes", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardDisputeListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_disputes") + .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 { + CardDisputeListPageAsync.builder() + .service(CardDisputeServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val submitUserSubmissionHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardDisputeId", params.cardDisputeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "card_disputes", + params._pathParam(0), + "submit_user_submission", + ) + .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 { submitUserSubmissionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val withdrawHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun withdraw( + params: CardDisputeWithdrawParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardDisputeId", params.cardDisputeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_disputes", params._pathParam(0), "withdraw") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { withdrawHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt index 55ddca977..1ea163761 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt @@ -8,6 +8,7 @@ import com.increase.api.services.async.simulations.AccountTransferServiceAsync import com.increase.api.services.async.simulations.AchTransferServiceAsync import com.increase.api.services.async.simulations.CardAuthorizationExpirationServiceAsync import com.increase.api.services.async.simulations.CardAuthorizationServiceAsync +import com.increase.api.services.async.simulations.CardDisputeServiceAsync import com.increase.api.services.async.simulations.CardFuelConfirmationServiceAsync import com.increase.api.services.async.simulations.CardIncrementServiceAsync import com.increase.api.services.async.simulations.CardRefundServiceAsync @@ -65,6 +66,8 @@ interface SimulationServiceAsync { fun cardRefunds(): CardRefundServiceAsync + fun cardDisputes(): CardDisputeServiceAsync + fun physicalCards(): PhysicalCardServiceAsync fun digitalWalletTokenRequests(): DigitalWalletTokenRequestServiceAsync @@ -136,6 +139,8 @@ interface SimulationServiceAsync { fun cardRefunds(): CardRefundServiceAsync.WithRawResponse + fun cardDisputes(): CardDisputeServiceAsync.WithRawResponse + fun physicalCards(): PhysicalCardServiceAsync.WithRawResponse fun digitalWalletTokenRequests(): DigitalWalletTokenRequestServiceAsync.WithRawResponse diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt index b16929383..8aa019ed2 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt @@ -13,6 +13,8 @@ import com.increase.api.services.async.simulations.CardAuthorizationExpirationSe import com.increase.api.services.async.simulations.CardAuthorizationExpirationServiceAsyncImpl import com.increase.api.services.async.simulations.CardAuthorizationServiceAsync import com.increase.api.services.async.simulations.CardAuthorizationServiceAsyncImpl +import com.increase.api.services.async.simulations.CardDisputeServiceAsync +import com.increase.api.services.async.simulations.CardDisputeServiceAsyncImpl import com.increase.api.services.async.simulations.CardFuelConfirmationServiceAsync import com.increase.api.services.async.simulations.CardFuelConfirmationServiceAsyncImpl import com.increase.api.services.async.simulations.CardIncrementServiceAsync @@ -104,6 +106,10 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: CardRefundServiceAsyncImpl(clientOptions) } + private val cardDisputes: CardDisputeServiceAsync by lazy { + CardDisputeServiceAsyncImpl(clientOptions) + } + private val physicalCards: PhysicalCardServiceAsync by lazy { PhysicalCardServiceAsyncImpl(clientOptions) } @@ -201,6 +207,8 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: override fun cardRefunds(): CardRefundServiceAsync = cardRefunds + override fun cardDisputes(): CardDisputeServiceAsync = cardDisputes + override fun physicalCards(): PhysicalCardServiceAsync = physicalCards override fun digitalWalletTokenRequests(): DigitalWalletTokenRequestServiceAsync = @@ -284,6 +292,10 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: CardRefundServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val cardDisputes: CardDisputeServiceAsync.WithRawResponse by lazy { + CardDisputeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val physicalCards: PhysicalCardServiceAsync.WithRawResponse by lazy { PhysicalCardServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -394,6 +406,8 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: override fun cardRefunds(): CardRefundServiceAsync.WithRawResponse = cardRefunds + override fun cardDisputes(): CardDisputeServiceAsync.WithRawResponse = cardDisputes + override fun physicalCards(): PhysicalCardServiceAsync.WithRawResponse = physicalCards override fun digitalWalletTokenRequests(): diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsync.kt new file mode 100644 index 000000000..2ac63db2d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsync.kt @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.carddisputes.CardDispute +import com.increase.api.models.simulations.carddisputes.CardDisputeActionParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardDisputeServiceAsync { + + /** + * 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): CardDisputeServiceAsync + + /** + * After a [Card Dispute](#card-disputes) is created in production, the dispute will initially + * be in a `pending_user_submission_reviewing` state. Since no review or further action happens + * in sandbox, this endpoint simulates moving a Card Dispute through its various states. + */ + fun action( + cardDisputeId: String, + params: CardDisputeActionParams, + ): CompletableFuture = action(cardDisputeId, params, RequestOptions.none()) + + /** @see action */ + fun action( + cardDisputeId: String, + params: CardDisputeActionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + action(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see action */ + fun action(params: CardDisputeActionParams): CompletableFuture = + action(params, RequestOptions.none()) + + /** @see action */ + fun action( + params: CardDisputeActionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [CardDisputeServiceAsync] 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 + ): CardDisputeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /simulations/card_disputes/{card_dispute_id}/action`, but is otherwise the same as + * [CardDisputeServiceAsync.action]. + */ + fun action( + cardDisputeId: String, + params: CardDisputeActionParams, + ): CompletableFuture> = + action(cardDisputeId, params, RequestOptions.none()) + + /** @see action */ + fun action( + cardDisputeId: String, + params: CardDisputeActionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + action(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see action */ + fun action( + params: CardDisputeActionParams + ): CompletableFuture> = action(params, RequestOptions.none()) + + /** @see action */ + fun action( + params: CardDisputeActionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsyncImpl.kt new file mode 100644 index 000000000..5e89a745e --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsyncImpl.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepareAsync +import com.increase.api.models.carddisputes.CardDispute +import com.increase.api.models.simulations.carddisputes.CardDisputeActionParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardDisputeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CardDisputeServiceAsync { + + private val withRawResponse: CardDisputeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardDisputeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardDisputeServiceAsync = + CardDisputeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun action( + params: CardDisputeActionParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /simulations/card_disputes/{card_dispute_id}/action + withRawResponse().action(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardDisputeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardDisputeServiceAsync.WithRawResponse = + CardDisputeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val actionHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun action( + params: CardDisputeActionParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardDisputeId", params.cardDisputeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("simulations", "card_disputes", params._pathParam(0), "action") + .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 { actionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardDisputeService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardDisputeService.kt new file mode 100644 index 000000000..335bce7f8 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardDisputeService.kt @@ -0,0 +1,328 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.google.errorprone.annotations.MustBeClosed +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.carddisputes.CardDispute +import com.increase.api.models.carddisputes.CardDisputeCreateParams +import com.increase.api.models.carddisputes.CardDisputeListPage +import com.increase.api.models.carddisputes.CardDisputeListParams +import com.increase.api.models.carddisputes.CardDisputeRetrieveParams +import com.increase.api.models.carddisputes.CardDisputeSubmitUserSubmissionParams +import com.increase.api.models.carddisputes.CardDisputeWithdrawParams +import java.util.function.Consumer + +interface CardDisputeService { + + /** + * 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): CardDisputeService + + /** Create a Card Dispute */ + fun create(params: CardDisputeCreateParams): CardDispute = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardDisputeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute + + /** Retrieve a Card Dispute */ + fun retrieve(cardDisputeId: String): CardDispute = + retrieve(cardDisputeId, CardDisputeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + cardDisputeId: String, + params: CardDisputeRetrieveParams = CardDisputeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute = + retrieve(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + cardDisputeId: String, + params: CardDisputeRetrieveParams = CardDisputeRetrieveParams.none(), + ): CardDispute = retrieve(cardDisputeId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: CardDisputeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute + + /** @see retrieve */ + fun retrieve(params: CardDisputeRetrieveParams): CardDispute = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(cardDisputeId: String, requestOptions: RequestOptions): CardDispute = + retrieve(cardDisputeId, CardDisputeRetrieveParams.none(), requestOptions) + + /** List Card Disputes */ + fun list(): CardDisputeListPage = list(CardDisputeListParams.none()) + + /** @see list */ + fun list( + params: CardDisputeListParams = CardDisputeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDisputeListPage + + /** @see list */ + fun list(params: CardDisputeListParams = CardDisputeListParams.none()): CardDisputeListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CardDisputeListPage = + list(CardDisputeListParams.none(), requestOptions) + + /** Submit a User Submission for a Card Dispute */ + fun submitUserSubmission( + cardDisputeId: String, + params: CardDisputeSubmitUserSubmissionParams, + ): CardDispute = submitUserSubmission(cardDisputeId, params, RequestOptions.none()) + + /** @see submitUserSubmission */ + fun submitUserSubmission( + cardDisputeId: String, + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute = + submitUserSubmission( + params.toBuilder().cardDisputeId(cardDisputeId).build(), + requestOptions, + ) + + /** @see submitUserSubmission */ + fun submitUserSubmission(params: CardDisputeSubmitUserSubmissionParams): CardDispute = + submitUserSubmission(params, RequestOptions.none()) + + /** @see submitUserSubmission */ + fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute + + /** Withdraw a Card Dispute */ + fun withdraw(cardDisputeId: String): CardDispute = + withdraw(cardDisputeId, CardDisputeWithdrawParams.none()) + + /** @see withdraw */ + fun withdraw( + cardDisputeId: String, + params: CardDisputeWithdrawParams = CardDisputeWithdrawParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute = + withdraw(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see withdraw */ + fun withdraw( + cardDisputeId: String, + params: CardDisputeWithdrawParams = CardDisputeWithdrawParams.none(), + ): CardDispute = withdraw(cardDisputeId, params, RequestOptions.none()) + + /** @see withdraw */ + fun withdraw( + params: CardDisputeWithdrawParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute + + /** @see withdraw */ + fun withdraw(params: CardDisputeWithdrawParams): CardDispute = + withdraw(params, RequestOptions.none()) + + /** @see withdraw */ + fun withdraw(cardDisputeId: String, requestOptions: RequestOptions): CardDispute = + withdraw(cardDisputeId, CardDisputeWithdrawParams.none(), requestOptions) + + /** + * A view of [CardDisputeService] 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 + ): CardDisputeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /card_disputes`, but is otherwise the same as + * [CardDisputeService.create]. + */ + @MustBeClosed + fun create(params: CardDisputeCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: CardDisputeCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /card_disputes/{card_dispute_id}`, but is otherwise + * the same as [CardDisputeService.retrieve]. + */ + @MustBeClosed + fun retrieve(cardDisputeId: String): HttpResponseFor = + retrieve(cardDisputeId, CardDisputeRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardDisputeId: String, + params: CardDisputeRetrieveParams = CardDisputeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardDisputeId: String, + params: CardDisputeRetrieveParams = CardDisputeRetrieveParams.none(), + ): HttpResponseFor = retrieve(cardDisputeId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: CardDisputeRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: CardDisputeRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + cardDisputeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(cardDisputeId, CardDisputeRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /card_disputes`, but is otherwise the same as + * [CardDisputeService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(CardDisputeListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: CardDisputeListParams = CardDisputeListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: CardDisputeListParams = CardDisputeListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(CardDisputeListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post + * /card_disputes/{card_dispute_id}/submit_user_submission`, but is otherwise the same as + * [CardDisputeService.submitUserSubmission]. + */ + @MustBeClosed + fun submitUserSubmission( + cardDisputeId: String, + params: CardDisputeSubmitUserSubmissionParams, + ): HttpResponseFor = + submitUserSubmission(cardDisputeId, params, RequestOptions.none()) + + /** @see submitUserSubmission */ + @MustBeClosed + fun submitUserSubmission( + cardDisputeId: String, + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + submitUserSubmission( + params.toBuilder().cardDisputeId(cardDisputeId).build(), + requestOptions, + ) + + /** @see submitUserSubmission */ + @MustBeClosed + fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams + ): HttpResponseFor = submitUserSubmission(params, RequestOptions.none()) + + /** @see submitUserSubmission */ + @MustBeClosed + fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /card_disputes/{card_dispute_id}/withdraw`, but is + * otherwise the same as [CardDisputeService.withdraw]. + */ + @MustBeClosed + fun withdraw(cardDisputeId: String): HttpResponseFor = + withdraw(cardDisputeId, CardDisputeWithdrawParams.none()) + + /** @see withdraw */ + @MustBeClosed + fun withdraw( + cardDisputeId: String, + params: CardDisputeWithdrawParams = CardDisputeWithdrawParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + withdraw(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see withdraw */ + @MustBeClosed + fun withdraw( + cardDisputeId: String, + params: CardDisputeWithdrawParams = CardDisputeWithdrawParams.none(), + ): HttpResponseFor = withdraw(cardDisputeId, params, RequestOptions.none()) + + /** @see withdraw */ + @MustBeClosed + fun withdraw( + params: CardDisputeWithdrawParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see withdraw */ + @MustBeClosed + fun withdraw(params: CardDisputeWithdrawParams): HttpResponseFor = + withdraw(params, RequestOptions.none()) + + /** @see withdraw */ + @MustBeClosed + fun withdraw( + cardDisputeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + withdraw(cardDisputeId, CardDisputeWithdrawParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardDisputeServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardDisputeServiceImpl.kt new file mode 100644 index 000000000..d40ef689d --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/CardDisputeServiceImpl.kt @@ -0,0 +1,248 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepare +import com.increase.api.models.carddisputes.CardDispute +import com.increase.api.models.carddisputes.CardDisputeCreateParams +import com.increase.api.models.carddisputes.CardDisputeListPage +import com.increase.api.models.carddisputes.CardDisputeListPageResponse +import com.increase.api.models.carddisputes.CardDisputeListParams +import com.increase.api.models.carddisputes.CardDisputeRetrieveParams +import com.increase.api.models.carddisputes.CardDisputeSubmitUserSubmissionParams +import com.increase.api.models.carddisputes.CardDisputeWithdrawParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardDisputeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardDisputeService { + + private val withRawResponse: CardDisputeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardDisputeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardDisputeService = + CardDisputeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardDisputeCreateParams, + requestOptions: RequestOptions, + ): CardDispute = + // post /card_disputes + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: CardDisputeRetrieveParams, + requestOptions: RequestOptions, + ): CardDispute = + // get /card_disputes/{card_dispute_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: CardDisputeListParams, + requestOptions: RequestOptions, + ): CardDisputeListPage = + // get /card_disputes + withRawResponse().list(params, requestOptions).parse() + + override fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions, + ): CardDispute = + // post /card_disputes/{card_dispute_id}/submit_user_submission + withRawResponse().submitUserSubmission(params, requestOptions).parse() + + override fun withdraw( + params: CardDisputeWithdrawParams, + requestOptions: RequestOptions, + ): CardDispute = + // post /card_disputes/{card_dispute_id}/withdraw + withRawResponse().withdraw(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardDisputeService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardDisputeService.WithRawResponse = + CardDisputeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardDisputeCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_disputes") + .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: CardDisputeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardDisputeId", params.cardDisputeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_disputes", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CardDisputeListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_disputes") + .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 { + CardDisputeListPage.builder() + .service(CardDisputeServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val submitUserSubmissionHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun submitUserSubmission( + params: CardDisputeSubmitUserSubmissionParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardDisputeId", params.cardDisputeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "card_disputes", + params._pathParam(0), + "submit_user_submission", + ) + .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 { submitUserSubmissionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val withdrawHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun withdraw( + params: CardDisputeWithdrawParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardDisputeId", params.cardDisputeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("card_disputes", params._pathParam(0), "withdraw") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { withdrawHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt index e61e51215..f124c5978 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt @@ -8,6 +8,7 @@ import com.increase.api.services.blocking.simulations.AccountTransferService import com.increase.api.services.blocking.simulations.AchTransferService import com.increase.api.services.blocking.simulations.CardAuthorizationExpirationService import com.increase.api.services.blocking.simulations.CardAuthorizationService +import com.increase.api.services.blocking.simulations.CardDisputeService import com.increase.api.services.blocking.simulations.CardFuelConfirmationService import com.increase.api.services.blocking.simulations.CardIncrementService import com.increase.api.services.blocking.simulations.CardRefundService @@ -65,6 +66,8 @@ interface SimulationService { fun cardRefunds(): CardRefundService + fun cardDisputes(): CardDisputeService + fun physicalCards(): PhysicalCardService fun digitalWalletTokenRequests(): DigitalWalletTokenRequestService @@ -133,6 +136,8 @@ interface SimulationService { fun cardRefunds(): CardRefundService.WithRawResponse + fun cardDisputes(): CardDisputeService.WithRawResponse + fun physicalCards(): PhysicalCardService.WithRawResponse fun digitalWalletTokenRequests(): DigitalWalletTokenRequestService.WithRawResponse diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt index 739566966..e0b712f98 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt @@ -13,6 +13,8 @@ import com.increase.api.services.blocking.simulations.CardAuthorizationExpiratio import com.increase.api.services.blocking.simulations.CardAuthorizationExpirationServiceImpl import com.increase.api.services.blocking.simulations.CardAuthorizationService import com.increase.api.services.blocking.simulations.CardAuthorizationServiceImpl +import com.increase.api.services.blocking.simulations.CardDisputeService +import com.increase.api.services.blocking.simulations.CardDisputeServiceImpl import com.increase.api.services.blocking.simulations.CardFuelConfirmationService import com.increase.api.services.blocking.simulations.CardFuelConfirmationServiceImpl import com.increase.api.services.blocking.simulations.CardIncrementService @@ -102,6 +104,8 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie private val cardRefunds: CardRefundService by lazy { CardRefundServiceImpl(clientOptions) } + private val cardDisputes: CardDisputeService by lazy { CardDisputeServiceImpl(clientOptions) } + private val physicalCards: PhysicalCardService by lazy { PhysicalCardServiceImpl(clientOptions) } @@ -194,6 +198,8 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie override fun cardRefunds(): CardRefundService = cardRefunds + override fun cardDisputes(): CardDisputeService = cardDisputes + override fun physicalCards(): PhysicalCardService = physicalCards override fun digitalWalletTokenRequests(): DigitalWalletTokenRequestService = @@ -276,6 +282,10 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie CardRefundServiceImpl.WithRawResponseImpl(clientOptions) } + private val cardDisputes: CardDisputeService.WithRawResponse by lazy { + CardDisputeServiceImpl.WithRawResponseImpl(clientOptions) + } + private val physicalCards: PhysicalCardService.WithRawResponse by lazy { PhysicalCardServiceImpl.WithRawResponseImpl(clientOptions) } @@ -384,6 +394,8 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie override fun cardRefunds(): CardRefundService.WithRawResponse = cardRefunds + override fun cardDisputes(): CardDisputeService.WithRawResponse = cardDisputes + override fun physicalCards(): PhysicalCardService.WithRawResponse = physicalCards override fun digitalWalletTokenRequests(): diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardDisputeService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardDisputeService.kt new file mode 100644 index 000000000..7cea28cf5 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardDisputeService.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.google.errorprone.annotations.MustBeClosed +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.carddisputes.CardDispute +import com.increase.api.models.simulations.carddisputes.CardDisputeActionParams +import java.util.function.Consumer + +interface CardDisputeService { + + /** + * 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): CardDisputeService + + /** + * After a [Card Dispute](#card-disputes) is created in production, the dispute will initially + * be in a `pending_user_submission_reviewing` state. Since no review or further action happens + * in sandbox, this endpoint simulates moving a Card Dispute through its various states. + */ + fun action(cardDisputeId: String, params: CardDisputeActionParams): CardDispute = + action(cardDisputeId, params, RequestOptions.none()) + + /** @see action */ + fun action( + cardDisputeId: String, + params: CardDisputeActionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute = action(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see action */ + fun action(params: CardDisputeActionParams): CardDispute = action(params, RequestOptions.none()) + + /** @see action */ + fun action( + params: CardDisputeActionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardDispute + + /** + * A view of [CardDisputeService] 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 + ): CardDisputeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post + * /simulations/card_disputes/{card_dispute_id}/action`, but is otherwise the same as + * [CardDisputeService.action]. + */ + @MustBeClosed + fun action( + cardDisputeId: String, + params: CardDisputeActionParams, + ): HttpResponseFor = action(cardDisputeId, params, RequestOptions.none()) + + /** @see action */ + @MustBeClosed + fun action( + cardDisputeId: String, + params: CardDisputeActionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + action(params.toBuilder().cardDisputeId(cardDisputeId).build(), requestOptions) + + /** @see action */ + @MustBeClosed + fun action(params: CardDisputeActionParams): HttpResponseFor = + action(params, RequestOptions.none()) + + /** @see action */ + @MustBeClosed + fun action( + params: CardDisputeActionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardDisputeServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardDisputeServiceImpl.kt new file mode 100644 index 000000000..a78487adb --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardDisputeServiceImpl.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepare +import com.increase.api.models.carddisputes.CardDispute +import com.increase.api.models.simulations.carddisputes.CardDisputeActionParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardDisputeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardDisputeService { + + private val withRawResponse: CardDisputeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardDisputeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardDisputeService = + CardDisputeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun action( + params: CardDisputeActionParams, + requestOptions: RequestOptions, + ): CardDispute = + // post /simulations/card_disputes/{card_dispute_id}/action + withRawResponse().action(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardDisputeService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardDisputeService.WithRawResponse = + CardDisputeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val actionHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun action( + params: CardDisputeActionParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardDisputeId", params.cardDisputeId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("simulations", "card_disputes", params._pathParam(0), "action") + .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 { actionHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeCreateParamsTest.kt new file mode 100644 index 000000000..ede600b58 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeCreateParamsTest.kt @@ -0,0 +1,1961 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.increase.api.core.JsonValue +import java.time.LocalDate +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardDisputeCreateParamsTest { + + @Test + fun create() { + CardDisputeCreateParams.builder() + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .network(CardDisputeCreateParams.Network.VISA) + .amount(100L) + .addAttachmentFile( + CardDisputeCreateParams.AttachmentFile.builder().fileId("file_id").build() + ) + .visa( + CardDisputeCreateParams.Visa.builder() + .category(CardDisputeCreateParams.Visa.Category.FRAUD) + .authorization( + CardDisputeCreateParams.Visa.Authorization.builder() + .accountStatus( + CardDisputeCreateParams.Visa.Authorization.AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise.Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction.builder() + .cancellationTarget( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt(LocalDate.parse("2019-12-27")) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeCreateParams.Visa.ConsumerCanceledServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeCreateParams.Visa.ConsumerCanceledServices.ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeCreateParams.Visa.ConsumerCounterfeitMerchandise.builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeCreateParams.Visa.ConsumerCreditNotProcessed.builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived.builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived.Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .returnedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeCreateParams.Visa.ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeCreateParams.Visa + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise.builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise.Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeCreateParams.Visa.ConsumerQualityServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived.builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeCreateParams.Visa.Fraud.builder() + .fraudType( + CardDisputeCreateParams.Visa.Fraud.FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeCreateParams.Visa.ProcessingError.builder() + .errorReason( + CardDisputeCreateParams.Visa.ProcessingError.ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeCreateParams.Visa.ProcessingError.DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeCreateParams.Visa.ProcessingError.IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeCreateParams.Visa.ProcessingError.PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeCreateParams.Visa.ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + CardDisputeCreateParams.builder() + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .network(CardDisputeCreateParams.Network.VISA) + .amount(100L) + .addAttachmentFile( + CardDisputeCreateParams.AttachmentFile.builder().fileId("file_id").build() + ) + .visa( + CardDisputeCreateParams.Visa.builder() + .category(CardDisputeCreateParams.Visa.Category.FRAUD) + .authorization( + CardDisputeCreateParams.Visa.Authorization.builder() + .accountStatus( + CardDisputeCreateParams.Visa.Authorization.AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDisputeCreateParams.Visa + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeCreateParams.Visa + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt(LocalDate.parse("2019-12-27")) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeCreateParams.Visa.ConsumerCanceledServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeCreateParams.Visa.ConsumerCounterfeitMerchandise.builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeCreateParams.Visa.ConsumerCreditNotProcessed.builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived.builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeCreateParams.Visa + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeCreateParams.Visa + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise.builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise.Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeCreateParams.Visa.ConsumerQualityServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived.builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeCreateParams.Visa.Fraud.builder() + .fraudType( + CardDisputeCreateParams.Visa.Fraud.FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeCreateParams.Visa.ProcessingError.builder() + .errorReason( + CardDisputeCreateParams.Visa.ProcessingError.ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeCreateParams.Visa.ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeCreateParams.Visa.ProcessingError.IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeCreateParams.Visa.ProcessingError.PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeCreateParams.Visa.ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.disputedTransactionId()).isEqualTo("transaction_uyrp7fld2ium70oa7oi") + assertThat(body.network()).isEqualTo(CardDisputeCreateParams.Network.VISA) + assertThat(body.amount()).contains(100L) + assertThat(body.attachmentFiles().getOrNull()) + .containsExactly( + CardDisputeCreateParams.AttachmentFile.builder().fileId("file_id").build() + ) + assertThat(body.visa()) + .contains( + CardDisputeCreateParams.Visa.builder() + .category(CardDisputeCreateParams.Visa.Category.FRAUD) + .authorization( + CardDisputeCreateParams.Visa.Authorization.builder() + .accountStatus( + CardDisputeCreateParams.Visa.Authorization.AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise.Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction.builder() + .cancellationTarget( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt(LocalDate.parse("2019-12-27")) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeCreateParams.Visa.ConsumerCanceledServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeCreateParams.Visa.ConsumerCanceledServices.ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeCreateParams.Visa.ConsumerCounterfeitMerchandise.builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeCreateParams.Visa.ConsumerCreditNotProcessed.builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived.builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived.Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .returnedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeCreateParams.Visa.ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeCreateParams.Visa + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise.builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise.Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeCreateParams.Visa.ConsumerQualityServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived.builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeCreateParams.Visa.Fraud.builder() + .fraudType( + CardDisputeCreateParams.Visa.Fraud.FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeCreateParams.Visa.ProcessingError.builder() + .errorReason( + CardDisputeCreateParams.Visa.ProcessingError.ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeCreateParams.Visa.ProcessingError.DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeCreateParams.Visa.ProcessingError.IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeCreateParams.Visa.ProcessingError.PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeCreateParams.Visa.ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CardDisputeCreateParams.builder() + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .network(CardDisputeCreateParams.Network.VISA) + .build() + + val body = params._body() + + assertThat(body.disputedTransactionId()).isEqualTo("transaction_uyrp7fld2ium70oa7oi") + assertThat(body.network()).isEqualTo(CardDisputeCreateParams.Network.VISA) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponseTest.kt new file mode 100644 index 000000000..a83b17476 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponseTest.kt @@ -0,0 +1,3826 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.JsonValue +import com.increase.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 CardDisputeListPageResponseTest { + + @Test + fun create() { + val cardDisputeListPageResponse = + CardDisputeListPageResponse.builder() + .addData( + CardDispute.builder() + .id("card_dispute_h9sc95nbl1cgltpp7men") + .amount(1000L) + .cardId("card_oubs0hwk5rn6knuecxg2") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .idempotencyKey(null) + .loss( + CardDispute.Loss.builder() + .lostAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .reason(CardDispute.Loss.Reason.USER_WITHDRAWN) + .build() + ) + .network(CardDispute.Network.VISA) + .status(CardDispute.Status.PENDING_RESPONSE) + .type(CardDispute.Type.CARD_DISPUTE) + .userSubmissionRequiredBy(null) + .visa( + CardDispute.Visa.builder() + .addNetworkEvent( + CardDispute.Visa.NetworkEvent.builder() + .addAttachmentFile( + CardDispute.Visa.NetworkEvent.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category( + CardDispute.Visa.NetworkEvent.Category + .CHARGEBACK_ACCEPTED + ) + .chargebackAccepted(JsonValue.from(mapOf())) + .chargebackSubmitted(JsonValue.from(mapOf())) + .chargebackTimedOut(JsonValue.from(mapOf())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeFinancialTransactionId( + "dispute_financial_transaction_id" + ) + .merchantPrearbitrationDeclineSubmitted( + JsonValue.from(mapOf()) + ) + .merchantPrearbitrationReceived( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .compellingEvidence( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .builder() + .category( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .Category + .MERCHANDISE_USE + ) + .explanation(null) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .delayedChargeTransaction( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .DelayedChargeTransaction + .builder() + .explanation(null) + .build() + ) + .evidenceOfImprint( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .EvidenceOfImprint + .builder() + .explanation(null) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .priorUndisputedNonFraudTransactions( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .PriorUndisputedNonFraudTransactions + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .Reason + .CARDHOLDER_NO_LONGER_DISPUTES + ) + .build() + ) + .merchantPrearbitrationTimedOut( + JsonValue.from(mapOf()) + ) + .represented( + CardDispute.Visa.NetworkEvent.Represented.builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent.Represented + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent.Represented + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent.Represented + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent + .Represented + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .proofOfCashDisbursement( + CardDispute.Visa.NetworkEvent.Represented + .ProofOfCashDisbursement + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented.Reason + .INVALID_DISPUTE + ) + .reversalIssued( + CardDispute.Visa.NetworkEvent.Represented + .ReversalIssued + .builder() + .explanation( + "The merchant has issued a reversal for the transaction prior to the dispute being filed." + ) + .build() + ) + .build() + ) + .representmentTimedOut(JsonValue.from(mapOf())) + .userPrearbitrationAccepted( + JsonValue.from(mapOf()) + ) + .userPrearbitrationDeclined( + JsonValue.from(mapOf()) + ) + .userPrearbitrationSubmitted( + JsonValue.from(mapOf()) + ) + .userPrearbitrationTimedOut( + JsonValue.from(mapOf()) + ) + .userWithdrawalSubmitted( + JsonValue.from(mapOf()) + ) + .build() + ) + .requiredUserSubmissionCategory(null) + .addUserSubmission( + CardDispute.Visa.UserSubmission.builder() + .acceptedAt(null) + .amount(1000L) + .addAttachmentFile( + CardDispute.Visa.UserSubmission.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category( + CardDispute.Visa.UserSubmission.Category.CHARGEBACK + ) + .chargeback( + CardDispute.Visa.UserSubmission.Chargeback.builder() + .authorization( + CardDispute.Visa.UserSubmission.Chargeback + .Authorization + .builder() + .accountStatus( + CardDispute.Visa.UserSubmission + .Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .category( + CardDispute.Visa.UserSubmission.Chargeback + .Category + .FRAUD + ) + .consumerCanceledMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .canceledPriorToShipDate( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .purchaseExplanation("purchase_explanation") + .receivedOrExpectedAt( + LocalDate.parse("2019-12-27") + ) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("application_name") + .callCenterPhoneNumber( + "call_center_phone_number" + ) + .emailAddress("email_address") + .inPersonAddress( + "in_person_address" + ) + .mailingAddress("mailing_address") + .textPhoneNumber( + "text_phone_number" + ) + .build() + ) + .otherFormOfPaymentExplanation( + "other_form_of_payment_explanation" + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerCanceledServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .guaranteedReservation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .other(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .serviceType( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .timeshare( + JsonValue.from(mapOf()) + ) + .build() + ) + .consumerCounterfeitMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation( + "counterfeit_explanation" + ) + .dispositionExplanation( + "disposition_explanation" + ) + .orderExplanation("order_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt( + LocalDate.parse("2019-12-27") + ) + .creditExpectedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .orderAndIssueExplanation( + "order_and_issue_explanation" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .delayed( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("explanation") + .notReturned( + JsonValue.from( + mapOf() + ) + ) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .returnedAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("agreed_location") + .build() + ) + .deliveryIssue( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .consumerNonReceiptOfCash(null) + .consumerOriginalCreditTransactionNotAccepted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("explanation") + .reason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .cardholderPaidToHaveWorkRedone( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .restaurantFoodRelated( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .servicesReceivedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .fraud( + CardDispute.Visa.UserSubmission.Chargeback.Fraud + .builder() + .fraudType( + CardDispute.Visa.UserSubmission + .Chargeback + .Fraud + .FraudType + .LOST + ) + .build() + ) + .processingError( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .builder() + .duplicateTransaction( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId( + "other_transaction_id" + ) + .build() + ) + .errorReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .incorrectAmount( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .paidByOtherMeans( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId( + "other_transaction_id" + ) + .build() + ) + .build() + ) + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .furtherInformationRequestedAt(null) + .furtherInformationRequestedReason(null) + .merchantPrearbitrationDecline( + CardDispute.Visa.UserSubmission + .MerchantPrearbitrationDecline + .builder() + .reason( + "I do not believe the explanation given by the merchant is valid." + ) + .build() + ) + .status( + CardDispute.Visa.UserSubmission.Status.PENDING_REVIEWING + ) + .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .userPrearbitration( + CardDispute.Visa.UserSubmission.UserPrearbitration + .builder() + .categoryChange( + CardDispute.Visa.UserSubmission + .UserPrearbitration + .CategoryChange + .builder() + .category( + CardDispute.Visa.UserSubmission + .UserPrearbitration + .CategoryChange + .Category + .FRAUD + ) + .reason( + "Based on the response from the merchant." + ) + .build() + ) + .reason( + "I disagree with the explanation given by the merchant." + ) + .build() + ) + .build() + ) + .build() + ) + .win( + CardDispute.Win.builder() + .wonAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .build() + ) + .build() + ) + .nextCursor("v57w5d") + .build() + + assertThat(cardDisputeListPageResponse.data()) + .containsExactly( + CardDispute.builder() + .id("card_dispute_h9sc95nbl1cgltpp7men") + .amount(1000L) + .cardId("card_oubs0hwk5rn6knuecxg2") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .idempotencyKey(null) + .loss( + CardDispute.Loss.builder() + .lostAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .reason(CardDispute.Loss.Reason.USER_WITHDRAWN) + .build() + ) + .network(CardDispute.Network.VISA) + .status(CardDispute.Status.PENDING_RESPONSE) + .type(CardDispute.Type.CARD_DISPUTE) + .userSubmissionRequiredBy(null) + .visa( + CardDispute.Visa.builder() + .addNetworkEvent( + CardDispute.Visa.NetworkEvent.builder() + .addAttachmentFile( + CardDispute.Visa.NetworkEvent.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category( + CardDispute.Visa.NetworkEvent.Category.CHARGEBACK_ACCEPTED + ) + .chargebackAccepted(JsonValue.from(mapOf())) + .chargebackSubmitted(JsonValue.from(mapOf())) + .chargebackTimedOut(JsonValue.from(mapOf())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeFinancialTransactionId( + "dispute_financial_transaction_id" + ) + .merchantPrearbitrationDeclineSubmitted( + JsonValue.from(mapOf()) + ) + .merchantPrearbitrationReceived( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .compellingEvidence( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .builder() + .category( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .Category + .MERCHANDISE_USE + ) + .explanation(null) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .delayedChargeTransaction( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .DelayedChargeTransaction + .builder() + .explanation(null) + .build() + ) + .evidenceOfImprint( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .EvidenceOfImprint + .builder() + .explanation(null) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .priorUndisputedNonFraudTransactions( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .PriorUndisputedNonFraudTransactions + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .Reason + .CARDHOLDER_NO_LONGER_DISPUTES + ) + .build() + ) + .merchantPrearbitrationTimedOut( + JsonValue.from(mapOf()) + ) + .represented( + CardDispute.Visa.NetworkEvent.Represented.builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent.Represented + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent.Represented + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent.Represented + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .proofOfCashDisbursement( + CardDispute.Visa.NetworkEvent.Represented + .ProofOfCashDisbursement + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented.Reason + .INVALID_DISPUTE + ) + .reversalIssued( + CardDispute.Visa.NetworkEvent.Represented + .ReversalIssued + .builder() + .explanation( + "The merchant has issued a reversal for the transaction prior to the dispute being filed." + ) + .build() + ) + .build() + ) + .representmentTimedOut(JsonValue.from(mapOf())) + .userPrearbitrationAccepted( + JsonValue.from(mapOf()) + ) + .userPrearbitrationDeclined( + JsonValue.from(mapOf()) + ) + .userPrearbitrationSubmitted( + JsonValue.from(mapOf()) + ) + .userPrearbitrationTimedOut( + JsonValue.from(mapOf()) + ) + .userWithdrawalSubmitted(JsonValue.from(mapOf())) + .build() + ) + .requiredUserSubmissionCategory(null) + .addUserSubmission( + CardDispute.Visa.UserSubmission.builder() + .acceptedAt(null) + .amount(1000L) + .addAttachmentFile( + CardDispute.Visa.UserSubmission.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category(CardDispute.Visa.UserSubmission.Category.CHARGEBACK) + .chargeback( + CardDispute.Visa.UserSubmission.Chargeback.builder() + .authorization( + CardDispute.Visa.UserSubmission.Chargeback + .Authorization + .builder() + .accountStatus( + CardDispute.Visa.UserSubmission.Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .category( + CardDispute.Visa.UserSubmission.Chargeback.Category + .FRAUD + ) + .consumerCanceledMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .canceledPriorToShipDate( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .purchaseExplanation("purchase_explanation") + .receivedOrExpectedAt( + LocalDate.parse("2019-12-27") + ) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("application_name") + .callCenterPhoneNumber( + "call_center_phone_number" + ) + .emailAddress("email_address") + .inPersonAddress("in_person_address") + .mailingAddress("mailing_address") + .textPhoneNumber("text_phone_number") + .build() + ) + .otherFormOfPaymentExplanation( + "other_form_of_payment_explanation" + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerCanceledServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .guaranteedReservation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .other(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .serviceType( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation( + "counterfeit_explanation" + ) + .dispositionExplanation( + "disposition_explanation" + ) + .orderExplanation("order_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt( + LocalDate.parse("2019-12-27") + ) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .orderAndIssueExplanation( + "order_and_issue_explanation" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .delayed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("explanation") + .notReturned( + JsonValue.from(mapOf()) + ) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .returnedAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("agreed_location") + .build() + ) + .deliveryIssue( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .consumerNonReceiptOfCash(null) + .consumerOriginalCreditTransactionNotAccepted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("explanation") + .reason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .cardholderPaidToHaveWorkRedone( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .restaurantFoodRelated( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .servicesReceivedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .fraud( + CardDispute.Visa.UserSubmission.Chargeback.Fraud + .builder() + .fraudType( + CardDispute.Visa.UserSubmission.Chargeback + .Fraud + .FraudType + .LOST + ) + .build() + ) + .processingError( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .builder() + .duplicateTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId( + "other_transaction_id" + ) + .build() + ) + .errorReason( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .incorrectAmount( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .paidByOtherMeans( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId( + "other_transaction_id" + ) + .build() + ) + .build() + ) + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .furtherInformationRequestedAt(null) + .furtherInformationRequestedReason(null) + .merchantPrearbitrationDecline( + CardDispute.Visa.UserSubmission + .MerchantPrearbitrationDecline + .builder() + .reason( + "I do not believe the explanation given by the merchant is valid." + ) + .build() + ) + .status( + CardDispute.Visa.UserSubmission.Status.PENDING_REVIEWING + ) + .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .userPrearbitration( + CardDispute.Visa.UserSubmission.UserPrearbitration.builder() + .categoryChange( + CardDispute.Visa.UserSubmission.UserPrearbitration + .CategoryChange + .builder() + .category( + CardDispute.Visa.UserSubmission + .UserPrearbitration + .CategoryChange + .Category + .FRAUD + ) + .reason( + "Based on the response from the merchant." + ) + .build() + ) + .reason( + "I disagree with the explanation given by the merchant." + ) + .build() + ) + .build() + ) + .build() + ) + .win( + CardDispute.Win.builder() + .wonAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .build() + ) + .build() + ) + assertThat(cardDisputeListPageResponse.nextCursor()).contains("v57w5d") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardDisputeListPageResponse = + CardDisputeListPageResponse.builder() + .addData( + CardDispute.builder() + .id("card_dispute_h9sc95nbl1cgltpp7men") + .amount(1000L) + .cardId("card_oubs0hwk5rn6knuecxg2") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .idempotencyKey(null) + .loss( + CardDispute.Loss.builder() + .lostAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .reason(CardDispute.Loss.Reason.USER_WITHDRAWN) + .build() + ) + .network(CardDispute.Network.VISA) + .status(CardDispute.Status.PENDING_RESPONSE) + .type(CardDispute.Type.CARD_DISPUTE) + .userSubmissionRequiredBy(null) + .visa( + CardDispute.Visa.builder() + .addNetworkEvent( + CardDispute.Visa.NetworkEvent.builder() + .addAttachmentFile( + CardDispute.Visa.NetworkEvent.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category( + CardDispute.Visa.NetworkEvent.Category + .CHARGEBACK_ACCEPTED + ) + .chargebackAccepted(JsonValue.from(mapOf())) + .chargebackSubmitted(JsonValue.from(mapOf())) + .chargebackTimedOut(JsonValue.from(mapOf())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeFinancialTransactionId( + "dispute_financial_transaction_id" + ) + .merchantPrearbitrationDeclineSubmitted( + JsonValue.from(mapOf()) + ) + .merchantPrearbitrationReceived( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .compellingEvidence( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .builder() + .category( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .Category + .MERCHANDISE_USE + ) + .explanation(null) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .delayedChargeTransaction( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .DelayedChargeTransaction + .builder() + .explanation(null) + .build() + ) + .evidenceOfImprint( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .EvidenceOfImprint + .builder() + .explanation(null) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .priorUndisputedNonFraudTransactions( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .PriorUndisputedNonFraudTransactions + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .Reason + .CARDHOLDER_NO_LONGER_DISPUTES + ) + .build() + ) + .merchantPrearbitrationTimedOut( + JsonValue.from(mapOf()) + ) + .represented( + CardDispute.Visa.NetworkEvent.Represented.builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent.Represented + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent.Represented + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent.Represented + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent + .Represented + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .proofOfCashDisbursement( + CardDispute.Visa.NetworkEvent.Represented + .ProofOfCashDisbursement + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented.Reason + .INVALID_DISPUTE + ) + .reversalIssued( + CardDispute.Visa.NetworkEvent.Represented + .ReversalIssued + .builder() + .explanation( + "The merchant has issued a reversal for the transaction prior to the dispute being filed." + ) + .build() + ) + .build() + ) + .representmentTimedOut(JsonValue.from(mapOf())) + .userPrearbitrationAccepted( + JsonValue.from(mapOf()) + ) + .userPrearbitrationDeclined( + JsonValue.from(mapOf()) + ) + .userPrearbitrationSubmitted( + JsonValue.from(mapOf()) + ) + .userPrearbitrationTimedOut( + JsonValue.from(mapOf()) + ) + .userWithdrawalSubmitted( + JsonValue.from(mapOf()) + ) + .build() + ) + .requiredUserSubmissionCategory(null) + .addUserSubmission( + CardDispute.Visa.UserSubmission.builder() + .acceptedAt(null) + .amount(1000L) + .addAttachmentFile( + CardDispute.Visa.UserSubmission.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category( + CardDispute.Visa.UserSubmission.Category.CHARGEBACK + ) + .chargeback( + CardDispute.Visa.UserSubmission.Chargeback.builder() + .authorization( + CardDispute.Visa.UserSubmission.Chargeback + .Authorization + .builder() + .accountStatus( + CardDispute.Visa.UserSubmission + .Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .category( + CardDispute.Visa.UserSubmission.Chargeback + .Category + .FRAUD + ) + .consumerCanceledMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .canceledPriorToShipDate( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .purchaseExplanation("purchase_explanation") + .receivedOrExpectedAt( + LocalDate.parse("2019-12-27") + ) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("application_name") + .callCenterPhoneNumber( + "call_center_phone_number" + ) + .emailAddress("email_address") + .inPersonAddress( + "in_person_address" + ) + .mailingAddress("mailing_address") + .textPhoneNumber( + "text_phone_number" + ) + .build() + ) + .otherFormOfPaymentExplanation( + "other_form_of_payment_explanation" + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerCanceledServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .guaranteedReservation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .other(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .serviceType( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .timeshare( + JsonValue.from(mapOf()) + ) + .build() + ) + .consumerCounterfeitMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation( + "counterfeit_explanation" + ) + .dispositionExplanation( + "disposition_explanation" + ) + .orderExplanation("order_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt( + LocalDate.parse("2019-12-27") + ) + .creditExpectedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .orderAndIssueExplanation( + "order_and_issue_explanation" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .delayed( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("explanation") + .notReturned( + JsonValue.from( + mapOf() + ) + ) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .returnedAt( + LocalDate.parse( + "2019-12-27" + ) + ) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("agreed_location") + .build() + ) + .deliveryIssue( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .consumerNonReceiptOfCash(null) + .consumerOriginalCreditTransactionNotAccepted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("explanation") + .reason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation( + "attempt_explanation" + ) + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation( + "other_explanation" + ) + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .cardholderPaidToHaveWorkRedone( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .restaurantFoodRelated( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .servicesReceivedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .reason("reason") + .build() + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .fraud( + CardDispute.Visa.UserSubmission.Chargeback.Fraud + .builder() + .fraudType( + CardDispute.Visa.UserSubmission + .Chargeback + .Fraud + .FraudType + .LOST + ) + .build() + ) + .processingError( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .builder() + .duplicateTransaction( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId( + "other_transaction_id" + ) + .build() + ) + .errorReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .incorrectAmount( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .paidByOtherMeans( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId( + "other_transaction_id" + ) + .build() + ) + .build() + ) + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .furtherInformationRequestedAt(null) + .furtherInformationRequestedReason(null) + .merchantPrearbitrationDecline( + CardDispute.Visa.UserSubmission + .MerchantPrearbitrationDecline + .builder() + .reason( + "I do not believe the explanation given by the merchant is valid." + ) + .build() + ) + .status( + CardDispute.Visa.UserSubmission.Status.PENDING_REVIEWING + ) + .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .userPrearbitration( + CardDispute.Visa.UserSubmission.UserPrearbitration + .builder() + .categoryChange( + CardDispute.Visa.UserSubmission + .UserPrearbitration + .CategoryChange + .builder() + .category( + CardDispute.Visa.UserSubmission + .UserPrearbitration + .CategoryChange + .Category + .FRAUD + ) + .reason( + "Based on the response from the merchant." + ) + .build() + ) + .reason( + "I disagree with the explanation given by the merchant." + ) + .build() + ) + .build() + ) + .build() + ) + .win( + CardDispute.Win.builder() + .wonAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .build() + ) + .build() + ) + .nextCursor("v57w5d") + .build() + + val roundtrippedCardDisputeListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardDisputeListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardDisputeListPageResponse).isEqualTo(cardDisputeListPageResponse) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListParamsTest.kt new file mode 100644 index 000000000..de09068d3 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListParamsTest.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.increase.api.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardDisputeListParamsTest { + + @Test + fun create() { + CardDisputeListParams.builder() + .createdAt( + CardDisputeListParams.CreatedAt.builder() + .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .cursor("cursor") + .idempotencyKey("x") + .limit(1L) + .status( + CardDisputeListParams.Status.builder() + .addIn(CardDisputeListParams.Status.In.USER_SUBMISSION_REQUIRED) + .build() + ) + .build() + } + + @Test + fun queryParams() { + val params = + CardDisputeListParams.builder() + .createdAt( + CardDisputeListParams.CreatedAt.builder() + .after(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .before(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .onOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .cursor("cursor") + .idempotencyKey("x") + .limit(1L) + .status( + CardDisputeListParams.Status.builder() + .addIn(CardDisputeListParams.Status.In.USER_SUBMISSION_REQUIRED) + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("created_at.after", "2019-12-27T18:11:19.117Z") + .put("created_at.before", "2019-12-27T18:11:19.117Z") + .put("created_at.on_or_after", "2019-12-27T18:11:19.117Z") + .put("created_at.on_or_before", "2019-12-27T18:11:19.117Z") + .put("cursor", "cursor") + .put("idempotency_key", "x") + .put("limit", "1") + .put("status.in", listOf("user_submission_required").joinToString(",")) + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = CardDisputeListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeRetrieveParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeRetrieveParamsTest.kt new file mode 100644 index 000000000..e0aceffb3 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeRetrieveParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardDisputeRetrieveParamsTest { + + @Test + fun create() { + CardDisputeRetrieveParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .build() + } + + @Test + fun pathParams() { + val params = + CardDisputeRetrieveParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .build() + + assertThat(params._pathParam(0)).isEqualTo("card_dispute_h9sc95nbl1cgltpp7men") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeSubmitUserSubmissionParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeSubmitUserSubmissionParamsTest.kt new file mode 100644 index 000000000..168e4d71b --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeSubmitUserSubmissionParamsTest.kt @@ -0,0 +1,2488 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.increase.api.core.JsonValue +import java.time.LocalDate +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardDisputeSubmitUserSubmissionParamsTest { + + @Test + fun create() { + CardDisputeSubmitUserSubmissionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeSubmitUserSubmissionParams.Network.VISA) + .amount(1L) + .addAttachmentFile( + CardDisputeSubmitUserSubmissionParams.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .visa( + CardDisputeSubmitUserSubmissionParams.Visa.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Category + .MERCHANT_PREARBITRATION_DECLINE + ) + .chargeback( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Category + .AUTHORIZATION + ) + .authorization( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Authorization + .builder() + .accountStatus( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt(LocalDate.parse("2019-12-27")) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Fraud + .builder() + .fraudType( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Fraud + .FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .builder() + .errorReason( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .merchantPrearbitrationDecline( + CardDisputeSubmitUserSubmissionParams.Visa.MerchantPrearbitrationDecline + .builder() + .reason( + "The pre-arbitration received from the merchantdoes not explain how they obtained permission to charge the card." + ) + .build() + ) + .userPrearbitration( + CardDisputeSubmitUserSubmissionParams.Visa.UserPrearbitration.builder() + .reason("x") + .categoryChange( + CardDisputeSubmitUserSubmissionParams.Visa.UserPrearbitration + .CategoryChange + .builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa + .UserPrearbitration + .CategoryChange + .Category + .AUTHORIZATION + ) + .reason("x") + .build() + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + CardDisputeSubmitUserSubmissionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeSubmitUserSubmissionParams.Network.VISA) + .build() + + assertThat(params._pathParam(0)).isEqualTo("card_dispute_h9sc95nbl1cgltpp7men") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + CardDisputeSubmitUserSubmissionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeSubmitUserSubmissionParams.Network.VISA) + .amount(1L) + .addAttachmentFile( + CardDisputeSubmitUserSubmissionParams.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .visa( + CardDisputeSubmitUserSubmissionParams.Visa.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Category + .MERCHANT_PREARBITRATION_DECLINE + ) + .chargeback( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Category + .AUTHORIZATION + ) + .authorization( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Authorization + .builder() + .accountStatus( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Fraud + .builder() + .fraudType( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Fraud + .FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .builder() + .errorReason( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .merchantPrearbitrationDecline( + CardDisputeSubmitUserSubmissionParams.Visa.MerchantPrearbitrationDecline + .builder() + .reason( + "The pre-arbitration received from the merchantdoes not explain how they obtained permission to charge the card." + ) + .build() + ) + .userPrearbitration( + CardDisputeSubmitUserSubmissionParams.Visa.UserPrearbitration.builder() + .reason("x") + .categoryChange( + CardDisputeSubmitUserSubmissionParams.Visa.UserPrearbitration + .CategoryChange + .builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa + .UserPrearbitration + .CategoryChange + .Category + .AUTHORIZATION + ) + .reason("x") + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.network()).isEqualTo(CardDisputeSubmitUserSubmissionParams.Network.VISA) + assertThat(body.amount()).contains(1L) + assertThat(body.attachmentFiles().getOrNull()) + .containsExactly( + CardDisputeSubmitUserSubmissionParams.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + assertThat(body.visa()) + .contains( + CardDisputeSubmitUserSubmissionParams.Visa.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Category + .MERCHANT_PREARBITRATION_DECLINE + ) + .chargeback( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Category + .AUTHORIZATION + ) + .authorization( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Authorization + .builder() + .accountStatus( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt(LocalDate.parse("2019-12-27")) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Fraud + .builder() + .fraudType( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Fraud + .FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .builder() + .errorReason( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .merchantPrearbitrationDecline( + CardDisputeSubmitUserSubmissionParams.Visa.MerchantPrearbitrationDecline + .builder() + .reason( + "The pre-arbitration received from the merchantdoes not explain how they obtained permission to charge the card." + ) + .build() + ) + .userPrearbitration( + CardDisputeSubmitUserSubmissionParams.Visa.UserPrearbitration.builder() + .reason("x") + .categoryChange( + CardDisputeSubmitUserSubmissionParams.Visa.UserPrearbitration + .CategoryChange + .builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa + .UserPrearbitration + .CategoryChange + .Category + .AUTHORIZATION + ) + .reason("x") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CardDisputeSubmitUserSubmissionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeSubmitUserSubmissionParams.Network.VISA) + .build() + + val body = params._body() + + assertThat(body.network()).isEqualTo(CardDisputeSubmitUserSubmissionParams.Network.VISA) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeTest.kt new file mode 100644 index 000000000..9c1e82b54 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeTest.kt @@ -0,0 +1,3296 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.increase.api.core.JsonValue +import com.increase.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 CardDisputeTest { + + @Test + fun create() { + val cardDispute = + CardDispute.builder() + .id("card_dispute_h9sc95nbl1cgltpp7men") + .amount(1000L) + .cardId("card_oubs0hwk5rn6knuecxg2") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .idempotencyKey(null) + .loss( + CardDispute.Loss.builder() + .lostAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .reason(CardDispute.Loss.Reason.USER_WITHDRAWN) + .build() + ) + .network(CardDispute.Network.VISA) + .status(CardDispute.Status.PENDING_RESPONSE) + .type(CardDispute.Type.CARD_DISPUTE) + .userSubmissionRequiredBy(null) + .visa( + CardDispute.Visa.builder() + .addNetworkEvent( + CardDispute.Visa.NetworkEvent.builder() + .addAttachmentFile( + CardDispute.Visa.NetworkEvent.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category( + CardDispute.Visa.NetworkEvent.Category.CHARGEBACK_ACCEPTED + ) + .chargebackAccepted(JsonValue.from(mapOf())) + .chargebackSubmitted(JsonValue.from(mapOf())) + .chargebackTimedOut(JsonValue.from(mapOf())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeFinancialTransactionId("dispute_financial_transaction_id") + .merchantPrearbitrationDeclineSubmitted( + JsonValue.from(mapOf()) + ) + .merchantPrearbitrationReceived( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .compellingEvidence( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .builder() + .category( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .Category + .MERCHANDISE_USE + ) + .explanation(null) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .delayedChargeTransaction( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .DelayedChargeTransaction + .builder() + .explanation(null) + .build() + ) + .evidenceOfImprint( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .EvidenceOfImprint + .builder() + .explanation(null) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .priorUndisputedNonFraudTransactions( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .PriorUndisputedNonFraudTransactions + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .Reason + .CARDHOLDER_NO_LONGER_DISPUTES + ) + .build() + ) + .merchantPrearbitrationTimedOut( + JsonValue.from(mapOf()) + ) + .represented( + CardDispute.Visa.NetworkEvent.Represented.builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent.Represented + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent.Represented + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent.Represented.InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .proofOfCashDisbursement( + CardDispute.Visa.NetworkEvent.Represented + .ProofOfCashDisbursement + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented.Reason + .INVALID_DISPUTE + ) + .reversalIssued( + CardDispute.Visa.NetworkEvent.Represented.ReversalIssued + .builder() + .explanation( + "The merchant has issued a reversal for the transaction prior to the dispute being filed." + ) + .build() + ) + .build() + ) + .representmentTimedOut(JsonValue.from(mapOf())) + .userPrearbitrationAccepted(JsonValue.from(mapOf())) + .userPrearbitrationDeclined(JsonValue.from(mapOf())) + .userPrearbitrationSubmitted(JsonValue.from(mapOf())) + .userPrearbitrationTimedOut(JsonValue.from(mapOf())) + .userWithdrawalSubmitted(JsonValue.from(mapOf())) + .build() + ) + .requiredUserSubmissionCategory(null) + .addUserSubmission( + CardDispute.Visa.UserSubmission.builder() + .acceptedAt(null) + .amount(1000L) + .addAttachmentFile( + CardDispute.Visa.UserSubmission.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category(CardDispute.Visa.UserSubmission.Category.CHARGEBACK) + .chargeback( + CardDispute.Visa.UserSubmission.Chargeback.builder() + .authorization( + CardDispute.Visa.UserSubmission.Chargeback.Authorization + .builder() + .accountStatus( + CardDispute.Visa.UserSubmission.Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .category( + CardDispute.Visa.UserSubmission.Chargeback.Category + .FRAUD + ) + .consumerCanceledMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("application_name") + .callCenterPhoneNumber( + "call_center_phone_number" + ) + .emailAddress("email_address") + .inPersonAddress("in_person_address") + .mailingAddress("mailing_address") + .textPhoneNumber("text_phone_number") + .build() + ) + .otherFormOfPaymentExplanation( + "other_form_of_payment_explanation" + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerCanceledServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .guaranteedReservation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .other(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .serviceType( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("counterfeit_explanation") + .dispositionExplanation("disposition_explanation") + .orderExplanation("order_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .orderAndIssueExplanation( + "order_and_issue_explanation" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .notReturned(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .delayed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("explanation") + .notReturned( + JsonValue.from(mapOf()) + ) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("agreed_location") + .build() + ) + .deliveryIssue( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .consumerNonReceiptOfCash(null) + .consumerOriginalCreditTransactionNotAccepted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("explanation") + .reason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .cardholderPaidToHaveWorkRedone( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .restaurantFoodRelated( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .fraud( + CardDispute.Visa.UserSubmission.Chargeback.Fraud + .builder() + .fraudType( + CardDispute.Visa.UserSubmission.Chargeback.Fraud + .FraudType + .LOST + ) + .build() + ) + .processingError( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .builder() + .duplicateTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("other_transaction_id") + .build() + ) + .errorReason( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .incorrectAmount( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .paidByOtherMeans( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("other_transaction_id") + .build() + ) + .build() + ) + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .furtherInformationRequestedAt(null) + .furtherInformationRequestedReason(null) + .merchantPrearbitrationDecline( + CardDispute.Visa.UserSubmission.MerchantPrearbitrationDecline + .builder() + .reason( + "I do not believe the explanation given by the merchant is valid." + ) + .build() + ) + .status(CardDispute.Visa.UserSubmission.Status.PENDING_REVIEWING) + .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .userPrearbitration( + CardDispute.Visa.UserSubmission.UserPrearbitration.builder() + .categoryChange( + CardDispute.Visa.UserSubmission.UserPrearbitration + .CategoryChange + .builder() + .category( + CardDispute.Visa.UserSubmission + .UserPrearbitration + .CategoryChange + .Category + .FRAUD + ) + .reason("Based on the response from the merchant.") + .build() + ) + .reason( + "I disagree with the explanation given by the merchant." + ) + .build() + ) + .build() + ) + .build() + ) + .win( + CardDispute.Win.builder() + .wonAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .build() + ) + .build() + + assertThat(cardDispute.id()).isEqualTo("card_dispute_h9sc95nbl1cgltpp7men") + assertThat(cardDispute.amount()).isEqualTo(1000L) + assertThat(cardDispute.cardId()).isEqualTo("card_oubs0hwk5rn6knuecxg2") + assertThat(cardDispute.createdAt()).isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + assertThat(cardDispute.disputedTransactionId()).isEqualTo("transaction_uyrp7fld2ium70oa7oi") + assertThat(cardDispute.idempotencyKey()).isEmpty + assertThat(cardDispute.loss()) + .contains( + CardDispute.Loss.builder() + .lostAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .reason(CardDispute.Loss.Reason.USER_WITHDRAWN) + .build() + ) + assertThat(cardDispute.network()).isEqualTo(CardDispute.Network.VISA) + assertThat(cardDispute.status()).isEqualTo(CardDispute.Status.PENDING_RESPONSE) + assertThat(cardDispute.type()).isEqualTo(CardDispute.Type.CARD_DISPUTE) + assertThat(cardDispute.userSubmissionRequiredBy()).isEmpty + assertThat(cardDispute.visa()) + .contains( + CardDispute.Visa.builder() + .addNetworkEvent( + CardDispute.Visa.NetworkEvent.builder() + .addAttachmentFile( + CardDispute.Visa.NetworkEvent.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category(CardDispute.Visa.NetworkEvent.Category.CHARGEBACK_ACCEPTED) + .chargebackAccepted(JsonValue.from(mapOf())) + .chargebackSubmitted(JsonValue.from(mapOf())) + .chargebackTimedOut(JsonValue.from(mapOf())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeFinancialTransactionId("dispute_financial_transaction_id") + .merchantPrearbitrationDeclineSubmitted( + JsonValue.from(mapOf()) + ) + .merchantPrearbitrationReceived( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .compellingEvidence( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .CompellingEvidence + .builder() + .category( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .Category + .MERCHANDISE_USE + ) + .explanation(null) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .delayedChargeTransaction( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .DelayedChargeTransaction + .builder() + .explanation(null) + .build() + ) + .evidenceOfImprint( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .EvidenceOfImprint + .builder() + .explanation(null) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .priorUndisputedNonFraudTransactions( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .PriorUndisputedNonFraudTransactions + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .Reason + .CARDHOLDER_NO_LONGER_DISPUTES + ) + .build() + ) + .merchantPrearbitrationTimedOut(JsonValue.from(mapOf())) + .represented( + CardDispute.Visa.NetworkEvent.Represented.builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent.Represented + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent.Represented + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent.Represented.InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .proofOfCashDisbursement( + CardDispute.Visa.NetworkEvent.Represented + .ProofOfCashDisbursement + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented.Reason + .INVALID_DISPUTE + ) + .reversalIssued( + CardDispute.Visa.NetworkEvent.Represented.ReversalIssued + .builder() + .explanation( + "The merchant has issued a reversal for the transaction prior to the dispute being filed." + ) + .build() + ) + .build() + ) + .representmentTimedOut(JsonValue.from(mapOf())) + .userPrearbitrationAccepted(JsonValue.from(mapOf())) + .userPrearbitrationDeclined(JsonValue.from(mapOf())) + .userPrearbitrationSubmitted(JsonValue.from(mapOf())) + .userPrearbitrationTimedOut(JsonValue.from(mapOf())) + .userWithdrawalSubmitted(JsonValue.from(mapOf())) + .build() + ) + .requiredUserSubmissionCategory(null) + .addUserSubmission( + CardDispute.Visa.UserSubmission.builder() + .acceptedAt(null) + .amount(1000L) + .addAttachmentFile( + CardDispute.Visa.UserSubmission.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category(CardDispute.Visa.UserSubmission.Category.CHARGEBACK) + .chargeback( + CardDispute.Visa.UserSubmission.Chargeback.builder() + .authorization( + CardDispute.Visa.UserSubmission.Chargeback.Authorization + .builder() + .accountStatus( + CardDispute.Visa.UserSubmission.Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .category( + CardDispute.Visa.UserSubmission.Chargeback.Category.FRAUD + ) + .consumerCanceledMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("application_name") + .callCenterPhoneNumber( + "call_center_phone_number" + ) + .emailAddress("email_address") + .inPersonAddress("in_person_address") + .mailingAddress("mailing_address") + .textPhoneNumber("text_phone_number") + .build() + ) + .otherFormOfPaymentExplanation( + "other_form_of_payment_explanation" + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerCanceledServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .guaranteedReservation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .other(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .serviceType( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("counterfeit_explanation") + .dispositionExplanation("disposition_explanation") + .orderExplanation("order_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .orderAndIssueExplanation("order_and_issue_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .notReturned(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .delayed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("explanation") + .notReturned( + JsonValue.from(mapOf()) + ) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("agreed_location") + .build() + ) + .deliveryIssue( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation(JsonValue.from(mapOf())) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .consumerNonReceiptOfCash(null) + .consumerOriginalCreditTransactionNotAccepted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("explanation") + .reason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .cardholderPaidToHaveWorkRedone( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .restaurantFoodRelated( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation(JsonValue.from(mapOf())) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .fraud( + CardDispute.Visa.UserSubmission.Chargeback.Fraud.builder() + .fraudType( + CardDispute.Visa.UserSubmission.Chargeback.Fraud + .FraudType + .LOST + ) + .build() + ) + .processingError( + CardDispute.Visa.UserSubmission.Chargeback.ProcessingError + .builder() + .duplicateTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("other_transaction_id") + .build() + ) + .errorReason( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .incorrectAmount( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .paidByOtherMeans( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("other_transaction_id") + .build() + ) + .build() + ) + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .furtherInformationRequestedAt(null) + .furtherInformationRequestedReason(null) + .merchantPrearbitrationDecline( + CardDispute.Visa.UserSubmission.MerchantPrearbitrationDecline + .builder() + .reason( + "I do not believe the explanation given by the merchant is valid." + ) + .build() + ) + .status(CardDispute.Visa.UserSubmission.Status.PENDING_REVIEWING) + .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .userPrearbitration( + CardDispute.Visa.UserSubmission.UserPrearbitration.builder() + .categoryChange( + CardDispute.Visa.UserSubmission.UserPrearbitration + .CategoryChange + .builder() + .category( + CardDispute.Visa.UserSubmission.UserPrearbitration + .CategoryChange + .Category + .FRAUD + ) + .reason("Based on the response from the merchant.") + .build() + ) + .reason( + "I disagree with the explanation given by the merchant." + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(cardDispute.win()) + .contains( + CardDispute.Win.builder() + .wonAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val cardDispute = + CardDispute.builder() + .id("card_dispute_h9sc95nbl1cgltpp7men") + .amount(1000L) + .cardId("card_oubs0hwk5rn6knuecxg2") + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .idempotencyKey(null) + .loss( + CardDispute.Loss.builder() + .lostAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .reason(CardDispute.Loss.Reason.USER_WITHDRAWN) + .build() + ) + .network(CardDispute.Network.VISA) + .status(CardDispute.Status.PENDING_RESPONSE) + .type(CardDispute.Type.CARD_DISPUTE) + .userSubmissionRequiredBy(null) + .visa( + CardDispute.Visa.builder() + .addNetworkEvent( + CardDispute.Visa.NetworkEvent.builder() + .addAttachmentFile( + CardDispute.Visa.NetworkEvent.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category( + CardDispute.Visa.NetworkEvent.Category.CHARGEBACK_ACCEPTED + ) + .chargebackAccepted(JsonValue.from(mapOf())) + .chargebackSubmitted(JsonValue.from(mapOf())) + .chargebackTimedOut(JsonValue.from(mapOf())) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .disputeFinancialTransactionId("dispute_financial_transaction_id") + .merchantPrearbitrationDeclineSubmitted( + JsonValue.from(mapOf()) + ) + .merchantPrearbitrationReceived( + CardDispute.Visa.NetworkEvent.MerchantPrearbitrationReceived + .builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .compellingEvidence( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .builder() + .category( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CompellingEvidence + .Category + .MERCHANDISE_USE + ) + .explanation(null) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .delayedChargeTransaction( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .DelayedChargeTransaction + .builder() + .explanation(null) + .build() + ) + .evidenceOfImprint( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .EvidenceOfImprint + .builder() + .explanation(null) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .priorUndisputedNonFraudTransactions( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .PriorUndisputedNonFraudTransactions + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent + .MerchantPrearbitrationReceived + .Reason + .CARDHOLDER_NO_LONGER_DISPUTES + ) + .build() + ) + .merchantPrearbitrationTimedOut( + JsonValue.from(mapOf()) + ) + .represented( + CardDispute.Visa.NetworkEvent.Represented.builder() + .cardholderNoLongerDisputes( + CardDispute.Visa.NetworkEvent.Represented + .CardholderNoLongerDisputes + .builder() + .explanation( + "See the attached email where the cardholder confirmed that they no longer dispute the transaction." + ) + .build() + ) + .creditOrReversalProcessed( + CardDispute.Visa.NetworkEvent.Represented + .CreditOrReversalProcessed + .builder() + .amount(4900L) + .currency("USD") + .explanation( + "The user did not provide the required documentation." + ) + .processedAt(LocalDate.parse("2020-01-31")) + .build() + ) + .invalidDispute( + CardDispute.Visa.NetworkEvent.Represented.InvalidDispute + .builder() + .explanation( + "The user did not provide the required documentation." + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented + .InvalidDispute + .Reason + .OTHER + ) + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenReceived( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenReceived + .builder() + .blockchainTransactionHash( + "0x1234567890123456789012345678901234567890" + ) + .destinationWalletAddress( + "0x1234567890123456789012345678901234567890" + ) + .priorApprovedTransactions( + "0x1234567890123456789012345678901234567890" + ) + .build() + ) + .proofOfCashDisbursement( + CardDispute.Visa.NetworkEvent.Represented + .ProofOfCashDisbursement + .builder() + .explanation(null) + .build() + ) + .reason( + CardDispute.Visa.NetworkEvent.Represented.Reason + .INVALID_DISPUTE + ) + .reversalIssued( + CardDispute.Visa.NetworkEvent.Represented.ReversalIssued + .builder() + .explanation( + "The merchant has issued a reversal for the transaction prior to the dispute being filed." + ) + .build() + ) + .build() + ) + .representmentTimedOut(JsonValue.from(mapOf())) + .userPrearbitrationAccepted(JsonValue.from(mapOf())) + .userPrearbitrationDeclined(JsonValue.from(mapOf())) + .userPrearbitrationSubmitted(JsonValue.from(mapOf())) + .userPrearbitrationTimedOut(JsonValue.from(mapOf())) + .userWithdrawalSubmitted(JsonValue.from(mapOf())) + .build() + ) + .requiredUserSubmissionCategory(null) + .addUserSubmission( + CardDispute.Visa.UserSubmission.builder() + .acceptedAt(null) + .amount(1000L) + .addAttachmentFile( + CardDispute.Visa.UserSubmission.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .category(CardDispute.Visa.UserSubmission.Category.CHARGEBACK) + .chargeback( + CardDispute.Visa.UserSubmission.Chargeback.builder() + .authorization( + CardDispute.Visa.UserSubmission.Chargeback.Authorization + .builder() + .accountStatus( + CardDispute.Visa.UserSubmission.Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .category( + CardDispute.Visa.UserSubmission.Chargeback.Category + .FRAUD + ) + .consumerCanceledMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("application_name") + .callCenterPhoneNumber( + "call_center_phone_number" + ) + .emailAddress("email_address") + .inPersonAddress("in_person_address") + .mailingAddress("mailing_address") + .textPhoneNumber("text_phone_number") + .build() + ) + .otherFormOfPaymentExplanation( + "other_form_of_payment_explanation" + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .consumerCanceledServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("reason") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .guaranteedReservation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .other(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .serviceType( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("counterfeit_explanation") + .dispositionExplanation("disposition_explanation") + .orderExplanation("order_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .orderAndIssueExplanation( + "order_and_issue_explanation" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .notReturned(JsonValue.from(mapOf())) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .delayed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("explanation") + .notReturned( + JsonValue.from(mapOf()) + ) + .returnAttempted( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("agreed_location") + .build() + ) + .deliveryIssue( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .consumerNonReceiptOfCash(null) + .consumerOriginalCreditTransactionNotAccepted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("explanation") + .reason( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("attempt_explanation") + .attemptReason( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition( + "merchandise_disposition" + ) + .build() + ) + .returnOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .returned( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("other_explanation") + .returnMethod( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .trackingNumber("tracking_number") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .cardholderPaidToHaveWorkRedone( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .ongoingNegotiations( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("explanation") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .purchaseInfoAndQualityIssue( + "purchase_info_and_quality_issue" + ) + .restaurantFoodRelated( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesMisrepresentation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation( + "misrepresentation_explanation" + ) + .purchaseExplanation("purchase_explanation") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDispute.Visa.UserSubmission + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .cardholderCancellationPriorToExpectedReceipt( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("reason") + .build() + ) + .lastExpectedReceiptAt( + LocalDate.parse("2019-12-27") + ) + .merchantCancellation( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .noCancellation( + JsonValue.from(mapOf()) + ) + .purchaseInfoAndExplanation( + "purchase_info_and_explanation" + ) + .build() + ) + .fraud( + CardDispute.Visa.UserSubmission.Chargeback.Fraud + .builder() + .fraudType( + CardDispute.Visa.UserSubmission.Chargeback.Fraud + .FraudType + .LOST + ) + .build() + ) + .processingError( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .builder() + .duplicateTransaction( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("other_transaction_id") + .build() + ) + .errorReason( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .incorrectAmount( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .merchantResolutionAttempted( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .paidByOtherMeans( + CardDispute.Visa.UserSubmission.Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDispute.Visa.UserSubmission + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("other_transaction_id") + .build() + ) + .build() + ) + .build() + ) + .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .furtherInformationRequestedAt(null) + .furtherInformationRequestedReason(null) + .merchantPrearbitrationDecline( + CardDispute.Visa.UserSubmission.MerchantPrearbitrationDecline + .builder() + .reason( + "I do not believe the explanation given by the merchant is valid." + ) + .build() + ) + .status(CardDispute.Visa.UserSubmission.Status.PENDING_REVIEWING) + .updatedAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .userPrearbitration( + CardDispute.Visa.UserSubmission.UserPrearbitration.builder() + .categoryChange( + CardDispute.Visa.UserSubmission.UserPrearbitration + .CategoryChange + .builder() + .category( + CardDispute.Visa.UserSubmission + .UserPrearbitration + .CategoryChange + .Category + .FRAUD + ) + .reason("Based on the response from the merchant.") + .build() + ) + .reason( + "I disagree with the explanation given by the merchant." + ) + .build() + ) + .build() + ) + .build() + ) + .win( + CardDispute.Win.builder() + .wonAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) + .build() + ) + .build() + + val roundtrippedCardDispute = + jsonMapper.readValue( + jsonMapper.writeValueAsString(cardDispute), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCardDispute).isEqualTo(cardDispute) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeWithdrawParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeWithdrawParamsTest.kt new file mode 100644 index 000000000..3b15d88a8 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeWithdrawParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.carddisputes + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardDisputeWithdrawParamsTest { + + @Test + fun create() { + CardDisputeWithdrawParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .build() + } + + @Test + fun pathParams() { + val params = + CardDisputeWithdrawParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .build() + + assertThat(params._pathParam(0)).isEqualTo("card_dispute_h9sc95nbl1cgltpp7men") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/carddisputes/CardDisputeActionParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/carddisputes/CardDisputeActionParamsTest.kt new file mode 100644 index 000000000..736fbc976 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/carddisputes/CardDisputeActionParamsTest.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.carddisputes + +import com.increase.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardDisputeActionParamsTest { + + @Test + fun create() { + CardDisputeActionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeActionParams.Network.VISA) + .visa( + CardDisputeActionParams.Visa.builder() + .action(CardDisputeActionParams.Visa.Action.ACCEPT_USER_SUBMISSION) + .acceptChargeback(JsonValue.from(mapOf())) + .acceptUserSubmission(JsonValue.from(mapOf())) + .declineUserPrearbitration(JsonValue.from(mapOf())) + .receiveMerchantPrearbitration(JsonValue.from(mapOf())) + .represent(JsonValue.from(mapOf())) + .requestFurtherInformation( + CardDisputeActionParams.Visa.RequestFurtherInformation.builder() + .reason("x") + .build() + ) + .timeOutChargeback(JsonValue.from(mapOf())) + .timeOutMerchantPrearbitration(JsonValue.from(mapOf())) + .timeOutRepresentment(JsonValue.from(mapOf())) + .timeOutUserPrearbitration(JsonValue.from(mapOf())) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + CardDisputeActionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeActionParams.Network.VISA) + .build() + + assertThat(params._pathParam(0)).isEqualTo("card_dispute_h9sc95nbl1cgltpp7men") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + CardDisputeActionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeActionParams.Network.VISA) + .visa( + CardDisputeActionParams.Visa.builder() + .action(CardDisputeActionParams.Visa.Action.ACCEPT_USER_SUBMISSION) + .acceptChargeback(JsonValue.from(mapOf())) + .acceptUserSubmission(JsonValue.from(mapOf())) + .declineUserPrearbitration(JsonValue.from(mapOf())) + .receiveMerchantPrearbitration(JsonValue.from(mapOf())) + .represent(JsonValue.from(mapOf())) + .requestFurtherInformation( + CardDisputeActionParams.Visa.RequestFurtherInformation.builder() + .reason("x") + .build() + ) + .timeOutChargeback(JsonValue.from(mapOf())) + .timeOutMerchantPrearbitration(JsonValue.from(mapOf())) + .timeOutRepresentment(JsonValue.from(mapOf())) + .timeOutUserPrearbitration(JsonValue.from(mapOf())) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.network()).isEqualTo(CardDisputeActionParams.Network.VISA) + assertThat(body.visa()) + .contains( + CardDisputeActionParams.Visa.builder() + .action(CardDisputeActionParams.Visa.Action.ACCEPT_USER_SUBMISSION) + .acceptChargeback(JsonValue.from(mapOf())) + .acceptUserSubmission(JsonValue.from(mapOf())) + .declineUserPrearbitration(JsonValue.from(mapOf())) + .receiveMerchantPrearbitration(JsonValue.from(mapOf())) + .represent(JsonValue.from(mapOf())) + .requestFurtherInformation( + CardDisputeActionParams.Visa.RequestFurtherInformation.builder() + .reason("x") + .build() + ) + .timeOutChargeback(JsonValue.from(mapOf())) + .timeOutMerchantPrearbitration(JsonValue.from(mapOf())) + .timeOutRepresentment(JsonValue.from(mapOf())) + .timeOutUserPrearbitration(JsonValue.from(mapOf())) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CardDisputeActionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeActionParams.Network.VISA) + .build() + + val body = params._body() + + assertThat(body.network()).isEqualTo(CardDisputeActionParams.Network.VISA) + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardDisputeServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardDisputeServiceAsyncTest.kt new file mode 100644 index 000000000..e1f0433b0 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/CardDisputeServiceAsyncTest.kt @@ -0,0 +1,1666 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import com.increase.api.core.JsonValue +import com.increase.api.models.carddisputes.CardDisputeCreateParams +import com.increase.api.models.carddisputes.CardDisputeSubmitUserSubmissionParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardDisputeServiceAsyncTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeServiceAsync = client.cardDisputes() + + val cardDisputeFuture = + cardDisputeServiceAsync.create( + CardDisputeCreateParams.builder() + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .network(CardDisputeCreateParams.Network.VISA) + .amount(100L) + .addAttachmentFile( + CardDisputeCreateParams.AttachmentFile.builder().fileId("file_id").build() + ) + .visa( + CardDisputeCreateParams.Visa.builder() + .category(CardDisputeCreateParams.Visa.Category.FRAUD) + .authorization( + CardDisputeCreateParams.Visa.Authorization.builder() + .accountStatus( + CardDisputeCreateParams.Visa.Authorization.AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeCreateParams.Visa + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDisputeCreateParams.Visa + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeCreateParams.Visa + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt(LocalDate.parse("2019-12-27")) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeCreateParams.Visa.ConsumerCanceledServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeCreateParams.Visa + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeCreateParams.Visa.ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeCreateParams.Visa.ConsumerCreditNotProcessed.builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeCreateParams.Visa + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeCreateParams.Visa + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise.builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeCreateParams.Visa.ConsumerQualityServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived.builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeCreateParams.Visa.Fraud.builder() + .fraudType( + CardDisputeCreateParams.Visa.Fraud.FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeCreateParams.Visa.ProcessingError.builder() + .errorReason( + CardDisputeCreateParams.Visa.ProcessingError.ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeCreateParams.Visa.ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeCreateParams.Visa.ProcessingError.IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeCreateParams.Visa.ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeCreateParams.Visa.ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .build() + ) + + val cardDispute = cardDisputeFuture.get() + cardDispute.validate() + } + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeServiceAsync = client.cardDisputes() + + val cardDisputeFuture = + cardDisputeServiceAsync.retrieve("card_dispute_h9sc95nbl1cgltpp7men") + + val cardDispute = cardDisputeFuture.get() + cardDispute.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeServiceAsync = client.cardDisputes() + + val pageFuture = cardDisputeServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Test + fun submitUserSubmission() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeServiceAsync = client.cardDisputes() + + val cardDisputeFuture = + cardDisputeServiceAsync.submitUserSubmission( + CardDisputeSubmitUserSubmissionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeSubmitUserSubmissionParams.Network.VISA) + .amount(1L) + .addAttachmentFile( + CardDisputeSubmitUserSubmissionParams.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .visa( + CardDisputeSubmitUserSubmissionParams.Visa.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Category + .MERCHANT_PREARBITRATION_DECLINE + ) + .chargeback( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Category + .AUTHORIZATION + ) + .authorization( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Authorization + .builder() + .accountStatus( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Fraud + .builder() + .fraudType( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .Fraud + .FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .builder() + .errorReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .merchantPrearbitrationDecline( + CardDisputeSubmitUserSubmissionParams.Visa + .MerchantPrearbitrationDecline + .builder() + .reason( + "The pre-arbitration received from the merchantdoes not explain how they obtained permission to charge the card." + ) + .build() + ) + .userPrearbitration( + CardDisputeSubmitUserSubmissionParams.Visa.UserPrearbitration + .builder() + .reason("x") + .categoryChange( + CardDisputeSubmitUserSubmissionParams.Visa + .UserPrearbitration + .CategoryChange + .builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa + .UserPrearbitration + .CategoryChange + .Category + .AUTHORIZATION + ) + .reason("x") + .build() + ) + .build() + ) + .build() + ) + .build() + ) + + val cardDispute = cardDisputeFuture.get() + cardDispute.validate() + } + + @Test + fun withdraw() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeServiceAsync = client.cardDisputes() + + val cardDisputeFuture = + cardDisputeServiceAsync.withdraw("card_dispute_h9sc95nbl1cgltpp7men") + + val cardDispute = cardDisputeFuture.get() + cardDispute.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsyncTest.kt new file mode 100644 index 000000000..b24041d51 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardDisputeServiceAsyncTest.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import com.increase.api.core.JsonValue +import com.increase.api.models.simulations.carddisputes.CardDisputeActionParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardDisputeServiceAsyncTest { + + @Test + fun action() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeServiceAsync = client.simulations().cardDisputes() + + val cardDisputeFuture = + cardDisputeServiceAsync.action( + CardDisputeActionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeActionParams.Network.VISA) + .visa( + CardDisputeActionParams.Visa.builder() + .action(CardDisputeActionParams.Visa.Action.ACCEPT_USER_SUBMISSION) + .acceptChargeback(JsonValue.from(mapOf())) + .acceptUserSubmission(JsonValue.from(mapOf())) + .declineUserPrearbitration(JsonValue.from(mapOf())) + .receiveMerchantPrearbitration(JsonValue.from(mapOf())) + .represent(JsonValue.from(mapOf())) + .requestFurtherInformation( + CardDisputeActionParams.Visa.RequestFurtherInformation.builder() + .reason("x") + .build() + ) + .timeOutChargeback(JsonValue.from(mapOf())) + .timeOutMerchantPrearbitration(JsonValue.from(mapOf())) + .timeOutRepresentment(JsonValue.from(mapOf())) + .timeOutUserPrearbitration(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + + val cardDispute = cardDisputeFuture.get() + cardDispute.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardDisputeServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardDisputeServiceTest.kt new file mode 100644 index 000000000..fdb0b5fb7 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/CardDisputeServiceTest.kt @@ -0,0 +1,1659 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClient +import com.increase.api.core.JsonValue +import com.increase.api.models.carddisputes.CardDisputeCreateParams +import com.increase.api.models.carddisputes.CardDisputeSubmitUserSubmissionParams +import java.time.LocalDate +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardDisputeServiceTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeService = client.cardDisputes() + + val cardDispute = + cardDisputeService.create( + CardDisputeCreateParams.builder() + .disputedTransactionId("transaction_uyrp7fld2ium70oa7oi") + .network(CardDisputeCreateParams.Network.VISA) + .amount(100L) + .addAttachmentFile( + CardDisputeCreateParams.AttachmentFile.builder().fileId("file_id").build() + ) + .visa( + CardDisputeCreateParams.Visa.builder() + .category(CardDisputeCreateParams.Visa.Category.FRAUD) + .authorization( + CardDisputeCreateParams.Visa.Authorization.builder() + .accountStatus( + CardDisputeCreateParams.Visa.Authorization.AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise.builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeCreateParams.Visa + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerCanceledMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeCreateParams.Visa.ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDisputeCreateParams.Visa + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeCreateParams.Visa + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt(LocalDate.parse("2019-12-27")) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeCreateParams.Visa.ConsumerCanceledServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeCreateParams.Visa + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeCreateParams.Visa.ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeCreateParams.Visa + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeCreateParams.Visa.ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeCreateParams.Visa.ConsumerCreditNotProcessed.builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeCreateParams.Visa.ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returned( + CardDisputeCreateParams.Visa + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeCreateParams.Visa + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeCreateParams.Visa + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise.builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeCreateParams.Visa + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeCreateParams.Visa.ConsumerQualityMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeCreateParams.Visa + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt(LocalDate.parse("2019-12-27")) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeCreateParams.Visa.ConsumerQualityServices.builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt(LocalDate.parse("2019-12-27")) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeCreateParams.Visa.ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeCreateParams.Visa.ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeCreateParams.Visa + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived.builder() + .cancellationOutcome( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeCreateParams.Visa.ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeCreateParams.Visa.Fraud.builder() + .fraudType( + CardDisputeCreateParams.Visa.Fraud.FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeCreateParams.Visa.ProcessingError.builder() + .errorReason( + CardDisputeCreateParams.Visa.ProcessingError.ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeCreateParams.Visa.ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeCreateParams.Visa.ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeCreateParams.Visa.ProcessingError.IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeCreateParams.Visa.ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeCreateParams.Visa.ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .build() + ) + + cardDispute.validate() + } + + @Test + fun retrieve() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeService = client.cardDisputes() + + val cardDispute = cardDisputeService.retrieve("card_dispute_h9sc95nbl1cgltpp7men") + + cardDispute.validate() + } + + @Test + fun list() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeService = client.cardDisputes() + + val page = cardDisputeService.list() + + page.response().validate() + } + + @Test + fun submitUserSubmission() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeService = client.cardDisputes() + + val cardDispute = + cardDisputeService.submitUserSubmission( + CardDisputeSubmitUserSubmissionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeSubmitUserSubmissionParams.Network.VISA) + .amount(1L) + .addAttachmentFile( + CardDisputeSubmitUserSubmissionParams.AttachmentFile.builder() + .fileId("file_id") + .build() + ) + .visa( + CardDisputeSubmitUserSubmissionParams.Visa.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Category + .MERCHANT_PREARBITRATION_DECLINE + ) + .chargeback( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Category + .AUTHORIZATION + ) + .authorization( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .Authorization + .builder() + .accountStatus( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .Authorization + .AccountStatus + .ACCOUNT_CLOSED + ) + .build() + ) + .consumerCanceledMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .receivedOrExpectedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .canceledPriorToShipDate( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CanceledPriorToShipDate + .CANCELED_PRIOR_TO_SHIP_DATE + ) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerCanceledRecurringTransaction( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledRecurringTransaction + .builder() + .cancellationTarget( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledRecurringTransaction + .CancellationTarget + .ACCOUNT + ) + .merchantContactMethods( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledRecurringTransaction + .MerchantContactMethods + .builder() + .applicationName("x") + .callCenterPhoneNumber("x") + .emailAddress("x") + .inPersonAddress("x") + .mailingAddress("x") + .textPhoneNumber("x") + .build() + ) + .transactionOrAccountCanceledAt( + LocalDate.parse("2019-12-27") + ) + .otherFormOfPaymentExplanation("x") + .build() + ) + .consumerCanceledServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCanceledServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .cancellationPolicyProvided( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .CardholderCancellation + .CancellationPolicyProvided + .NOT_PROVIDED + ) + .reason("x") + .build() + ) + .contractedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseExplanation("x") + .serviceType( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .ServiceType + .GUARANTEED_RESERVATION + ) + .guaranteedReservation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .builder() + .explanation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerCanceledServices + .GuaranteedReservation + .Explanation + .CARDHOLDER_CANCELED_PRIOR_TO_SERVICE + ) + .build() + ) + .other(JsonValue.from(mapOf())) + .timeshare(JsonValue.from(mapOf())) + .build() + ) + .consumerCounterfeitMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCounterfeitMerchandise + .builder() + .counterfeitExplanation("x") + .dispositionExplanation("x") + .orderExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerCreditNotProcessed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerCreditNotProcessed + .builder() + .canceledOrReturnedAt(LocalDate.parse("2019-12-27")) + .creditExpectedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerDamagedOrDefectiveMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .orderAndIssueExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerDamagedOrDefectiveMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseMisrepresentation + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseMisrepresentation + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotAsDescribed + .builder() + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnOutcome + .RETURNED + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotAsDescribed + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerMerchandiseNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerMerchandiseNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .deliveryIssue( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .DeliveryIssue + .DELAYED + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .delayed( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .builder() + .explanation("x") + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned( + JsonValue.from(mapOf()) + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .ReturnAttempted + .builder() + .attemptedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .Delayed + .Returned + .builder() + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .returnedAt( + LocalDate.parse("2019-12-27") + ) + .build() + ) + .build() + ) + .deliveredToWrongLocation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .DeliveredToWrongLocation + .builder() + .agreedLocation("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerMerchandiseNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .consumerNonReceiptOfCash(JsonValue.from(mapOf())) + .consumerOriginalCreditTransactionNotAccepted( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .builder() + .explanation("x") + .reason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerOriginalCreditTransactionNotAccepted + .Reason + .PROHIBITED_BY_LOCAL_LAWS_OR_REGULATION + ) + .build() + ) + .consumerQualityMerchandise( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityMerchandise + .builder() + .expectedAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndQualityIssue("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .returnOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnOutcome + .NOT_RETURNED + ) + .notReturned(JsonValue.from(mapOf())) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .returnAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .builder() + .attemptExplanation("x") + .attemptReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .ReturnAttempted + .AttemptReason + .MERCHANT_NOT_RESPONDING + ) + .attemptedAt(LocalDate.parse("2019-12-27")) + .merchandiseDisposition("x") + .build() + ) + .returned( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .Returned + .builder() + .returnMethod( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityMerchandise + .Returned + .ReturnMethod + .DHL + ) + .returnedAt(LocalDate.parse("2019-12-27")) + .merchantReceivedReturnAt( + LocalDate.parse("2019-12-27") + ) + .otherExplanation("x") + .trackingNumber("x") + .build() + ) + .build() + ) + .consumerQualityServices( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerQualityServices + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .nonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .NonFiatCurrencyOrNonFungibleTokenRelatedAndNotMatchingDescription + .NOT_RELATED + ) + .purchaseInfoAndQualityIssue("x") + .servicesReceivedAt(LocalDate.parse("2019-12-27")) + .cardholderPaidToHaveWorkRedone( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .CardholderPaidToHaveWorkRedone + .DID_NOT_PAY_TO_HAVE_WORK_REDONE + ) + .ongoingNegotiations( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .OngoingNegotiations + .builder() + .explanation("x") + .issuerFirstNotifiedAt( + LocalDate.parse("2019-12-27") + ) + .startedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .restaurantFoodRelated( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerQualityServices + .RestaurantFoodRelated + .NOT_RELATED + ) + .build() + ) + .consumerServicesMisrepresentation( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesMisrepresentation + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesMisrepresentation + .MerchantResolutionAttempted + .ATTEMPTED + ) + .misrepresentationExplanation("x") + .purchaseExplanation("x") + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotAsDescribed( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotAsDescribed + .builder() + .cardholderCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .builder() + .acceptedByMerchant( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .CardholderCancellation + .AcceptedByMerchant + .ACCEPTED + ) + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotAsDescribed + .MerchantResolutionAttempted + .ATTEMPTED + ) + .receivedAt(LocalDate.parse("2019-12-27")) + .build() + ) + .consumerServicesNotReceived( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ConsumerServicesNotReceived + .builder() + .cancellationOutcome( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotReceived + .CancellationOutcome + .CARDHOLDER_CANCELLATION_PRIOR_TO_EXPECTED_RECEIPT + ) + .lastExpectedReceiptAt(LocalDate.parse("2019-12-27")) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotReceived + .MerchantResolutionAttempted + .ATTEMPTED + ) + .purchaseInfoAndExplanation("x") + .cardholderCancellationPriorToExpectedReceipt( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotReceived + .CardholderCancellationPriorToExpectedReceipt + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .reason("x") + .build() + ) + .merchantCancellation( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ConsumerServicesNotReceived + .MerchantCancellation + .builder() + .canceledAt(LocalDate.parse("2019-12-27")) + .build() + ) + .noCancellation(JsonValue.from(mapOf())) + .build() + ) + .fraud( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback.Fraud + .builder() + .fraudType( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .Fraud + .FraudType + .ACCOUNT_OR_CREDENTIALS_TAKEOVER + ) + .build() + ) + .processingError( + CardDisputeSubmitUserSubmissionParams.Visa.Chargeback + .ProcessingError + .builder() + .errorReason( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .ErrorReason + .DUPLICATE_TRANSACTION + ) + .merchantResolutionAttempted( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .MerchantResolutionAttempted + .ATTEMPTED + ) + .duplicateTransaction( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .DuplicateTransaction + .builder() + .otherTransactionId("x") + .build() + ) + .incorrectAmount( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .IncorrectAmount + .builder() + .expectedAmount(0L) + .build() + ) + .paidByOtherMeans( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .PaidByOtherMeans + .builder() + .otherFormOfPaymentEvidence( + CardDisputeSubmitUserSubmissionParams.Visa + .Chargeback + .ProcessingError + .PaidByOtherMeans + .OtherFormOfPaymentEvidence + .CANCELED_CHECK + ) + .otherTransactionId("x") + .build() + ) + .build() + ) + .build() + ) + .merchantPrearbitrationDecline( + CardDisputeSubmitUserSubmissionParams.Visa + .MerchantPrearbitrationDecline + .builder() + .reason( + "The pre-arbitration received from the merchantdoes not explain how they obtained permission to charge the card." + ) + .build() + ) + .userPrearbitration( + CardDisputeSubmitUserSubmissionParams.Visa.UserPrearbitration + .builder() + .reason("x") + .categoryChange( + CardDisputeSubmitUserSubmissionParams.Visa + .UserPrearbitration + .CategoryChange + .builder() + .category( + CardDisputeSubmitUserSubmissionParams.Visa + .UserPrearbitration + .CategoryChange + .Category + .AUTHORIZATION + ) + .reason("x") + .build() + ) + .build() + ) + .build() + ) + .build() + ) + + cardDispute.validate() + } + + @Test + fun withdraw() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeService = client.cardDisputes() + + val cardDispute = cardDisputeService.withdraw("card_dispute_h9sc95nbl1cgltpp7men") + + cardDispute.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardDisputeServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardDisputeServiceTest.kt new file mode 100644 index 000000000..bd0b3101d --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardDisputeServiceTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClient +import com.increase.api.core.JsonValue +import com.increase.api.models.simulations.carddisputes.CardDisputeActionParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardDisputeServiceTest { + + @Test + fun action() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardDisputeService = client.simulations().cardDisputes() + + val cardDispute = + cardDisputeService.action( + CardDisputeActionParams.builder() + .cardDisputeId("card_dispute_h9sc95nbl1cgltpp7men") + .network(CardDisputeActionParams.Network.VISA) + .visa( + CardDisputeActionParams.Visa.builder() + .action(CardDisputeActionParams.Visa.Action.ACCEPT_USER_SUBMISSION) + .acceptChargeback(JsonValue.from(mapOf())) + .acceptUserSubmission(JsonValue.from(mapOf())) + .declineUserPrearbitration(JsonValue.from(mapOf())) + .receiveMerchantPrearbitration(JsonValue.from(mapOf())) + .represent(JsonValue.from(mapOf())) + .requestFurtherInformation( + CardDisputeActionParams.Visa.RequestFurtherInformation.builder() + .reason("x") + .build() + ) + .timeOutChargeback(JsonValue.from(mapOf())) + .timeOutMerchantPrearbitration(JsonValue.from(mapOf())) + .timeOutRepresentment(JsonValue.from(mapOf())) + .timeOutUserPrearbitration(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + + cardDispute.validate() + } +} diff --git a/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt b/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt index 3e72bd6f1..5ac6a9ae2 100644 --- a/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt +++ b/increase-java-proguard-test/src/test/kotlin/com/increase/api/proguard/ProGuardCompatibilityTest.kt @@ -55,6 +55,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.cards()).isNotNull() assertThat(client.cardPayments()).isNotNull() assertThat(client.cardPurchaseSupplements()).isNotNull() + assertThat(client.cardDisputes()).isNotNull() assertThat(client.physicalCards()).isNotNull() assertThat(client.digitalCardProfiles()).isNotNull() assertThat(client.physicalCardProfiles()).isNotNull() From 443e6d78698488c070a1346ff26655ff63f9ef9e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:19:54 +0000 Subject: [PATCH 2/5] feat(api): api update --- .stats.yml | 4 ++-- .../checkdeposits/CheckDepositListPageResponseTest.kt | 6 +++--- .../increase/api/models/checkdeposits/CheckDepositTest.kt | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 9aa42589f..d7372b091 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 220 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-dc0a89abaae59dd7fc23cc5463a412d79b5c8c042eb144b05e97823d11a76b2b.yml -openapi_spec_hash: 24ce07f273cf90d08b3fa22958316846 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-98f523253259ea28925f73c666fb578f233689655d6154790eba581eafed00c6.yml +openapi_spec_hash: 3e360f4ec207a4bceae1816dff0d768a config_hash: f0b80170c2ea09811aeae3f1e94bc422 diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/checkdeposits/CheckDepositListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/checkdeposits/CheckDepositListPageResponseTest.kt index 9e5afb086..8c9c45213 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/checkdeposits/CheckDepositListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/checkdeposits/CheckDepositListPageResponseTest.kt @@ -19,7 +19,7 @@ internal class CheckDepositListPageResponseTest { .id("check_deposit_f06n9gpg7sxn8t19lfc1") .accountId("account_in71c4amph0vgo2qllky") .amount(1000L) - .backImageFileId(null) + .backImageFileId("file_26khfk98mzfz90a11oqx") .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .depositAcceptance( CheckDeposit.DepositAcceptance.builder() @@ -95,7 +95,7 @@ internal class CheckDepositListPageResponseTest { .id("check_deposit_f06n9gpg7sxn8t19lfc1") .accountId("account_in71c4amph0vgo2qllky") .amount(1000L) - .backImageFileId(null) + .backImageFileId("file_26khfk98mzfz90a11oqx") .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .depositAcceptance( CheckDeposit.DepositAcceptance.builder() @@ -173,7 +173,7 @@ internal class CheckDepositListPageResponseTest { .id("check_deposit_f06n9gpg7sxn8t19lfc1") .accountId("account_in71c4amph0vgo2qllky") .amount(1000L) - .backImageFileId(null) + .backImageFileId("file_26khfk98mzfz90a11oqx") .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .depositAcceptance( CheckDeposit.DepositAcceptance.builder() diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/checkdeposits/CheckDepositTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/checkdeposits/CheckDepositTest.kt index a51ca0af9..7790928bf 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/checkdeposits/CheckDepositTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/checkdeposits/CheckDepositTest.kt @@ -17,7 +17,7 @@ internal class CheckDepositTest { .id("check_deposit_f06n9gpg7sxn8t19lfc1") .accountId("account_in71c4amph0vgo2qllky") .amount(1000L) - .backImageFileId(null) + .backImageFileId("file_26khfk98mzfz90a11oqx") .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .depositAcceptance( CheckDeposit.DepositAcceptance.builder() @@ -83,7 +83,7 @@ internal class CheckDepositTest { assertThat(checkDeposit.id()).isEqualTo("check_deposit_f06n9gpg7sxn8t19lfc1") assertThat(checkDeposit.accountId()).isEqualTo("account_in71c4amph0vgo2qllky") assertThat(checkDeposit.amount()).isEqualTo(1000L) - assertThat(checkDeposit.backImageFileId()).isEmpty + assertThat(checkDeposit.backImageFileId()).contains("file_26khfk98mzfz90a11oqx") assertThat(checkDeposit.createdAt()).isEqualTo(OffsetDateTime.parse("2020-01-31T23:59:59Z")) assertThat(checkDeposit.depositAcceptance()) .contains( @@ -159,7 +159,7 @@ internal class CheckDepositTest { .id("check_deposit_f06n9gpg7sxn8t19lfc1") .accountId("account_in71c4amph0vgo2qllky") .amount(1000L) - .backImageFileId(null) + .backImageFileId("file_26khfk98mzfz90a11oqx") .createdAt(OffsetDateTime.parse("2020-01-31T23:59:59Z")) .depositAcceptance( CheckDeposit.DepositAcceptance.builder() From 1b2b27b41fe9d1d2a00b1524e1ee6cc08809571a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 20:41:36 +0000 Subject: [PATCH 3/5] feat(api): api update --- .stats.yml | 4 +- .../api/models/cardpayments/CardPayment.kt | 60 +++++++++++++++++-- .../CardPaymentListPageResponseTest.kt | 3 + .../models/cardpayments/CardPaymentTest.kt | 3 + 4 files changed, 63 insertions(+), 7 deletions(-) diff --git a/.stats.yml b/.stats.yml index d7372b091..6d6e5b784 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 220 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-98f523253259ea28925f73c666fb578f233689655d6154790eba581eafed00c6.yml -openapi_spec_hash: 3e360f4ec207a4bceae1816dff0d768a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-fcc4e952b005ab1fd26ae67fe0cac46a57699299c92e00680d4d0f6be51d7936.yml +openapi_spec_hash: f1a7326721f814625c7d5484956afded config_hash: f0b80170c2ea09811aeae3f1e94bc422 diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpayments/CardPayment.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpayments/CardPayment.kt index 675901dd1..691012030 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/cardpayments/CardPayment.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/cardpayments/CardPayment.kt @@ -56567,6 +56567,7 @@ private constructor( private val authorizedAmount: JsonField, private val fuelConfirmedAmount: JsonField, private val incrementedAmount: JsonField, + private val refundedAmount: JsonField, private val reversedAmount: JsonField, private val settledAmount: JsonField, private val additionalProperties: MutableMap, @@ -56583,6 +56584,9 @@ private constructor( @JsonProperty("incremented_amount") @ExcludeMissing incrementedAmount: JsonField = JsonMissing.of(), + @JsonProperty("refunded_amount") + @ExcludeMissing + refundedAmount: JsonField = JsonMissing.of(), @JsonProperty("reversed_amount") @ExcludeMissing reversedAmount: JsonField = JsonMissing.of(), @@ -56593,6 +56597,7 @@ private constructor( authorizedAmount, fuelConfirmedAmount, incrementedAmount, + refundedAmount, reversedAmount, settledAmount, mutableMapOf(), @@ -56625,6 +56630,15 @@ private constructor( */ fun incrementedAmount(): Long = incrementedAmount.getRequired("incremented_amount") + /** + * The total refunded amount in the minor unit of the transaction's currency. For dollars, + * for example, this is cents. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun refundedAmount(): Long = refundedAmount.getRequired("refunded_amount") + /** * The total reversed amount in the minor unit of the transaction's currency. For dollars, * for example, this is cents. @@ -56635,8 +56649,8 @@ private constructor( fun reversedAmount(): Long = reversedAmount.getRequired("reversed_amount") /** - * The total settled or refunded amount in the minor unit of the transaction's currency. For - * dollars, for example, this is cents. + * The total settled amount in the minor unit of the transaction's currency. For dollars, + * for example, this is cents. * * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -56673,6 +56687,16 @@ private constructor( @ExcludeMissing fun _incrementedAmount(): JsonField = incrementedAmount + /** + * Returns the raw JSON value of [refundedAmount]. + * + * Unlike [refundedAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("refunded_amount") + @ExcludeMissing + fun _refundedAmount(): JsonField = refundedAmount + /** * Returns the raw JSON value of [reversedAmount]. * @@ -56715,6 +56739,7 @@ private constructor( * .authorizedAmount() * .fuelConfirmedAmount() * .incrementedAmount() + * .refundedAmount() * .reversedAmount() * .settledAmount() * ``` @@ -56728,6 +56753,7 @@ private constructor( private var authorizedAmount: JsonField? = null private var fuelConfirmedAmount: JsonField? = null private var incrementedAmount: JsonField? = null + private var refundedAmount: JsonField? = null private var reversedAmount: JsonField? = null private var settledAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -56737,6 +56763,7 @@ private constructor( authorizedAmount = state.authorizedAmount fuelConfirmedAmount = state.fuelConfirmedAmount incrementedAmount = state.incrementedAmount + refundedAmount = state.refundedAmount reversedAmount = state.reversedAmount settledAmount = state.settledAmount additionalProperties = state.additionalProperties.toMutableMap() @@ -56796,6 +56823,23 @@ private constructor( this.incrementedAmount = incrementedAmount } + /** + * The total refunded amount in the minor unit of the transaction's currency. For + * dollars, for example, this is cents. + */ + fun refundedAmount(refundedAmount: Long) = refundedAmount(JsonField.of(refundedAmount)) + + /** + * Sets [Builder.refundedAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.refundedAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun refundedAmount(refundedAmount: JsonField) = apply { + this.refundedAmount = refundedAmount + } + /** * The total reversed amount in the minor unit of the transaction's currency. For * dollars, for example, this is cents. @@ -56814,8 +56858,8 @@ private constructor( } /** - * The total settled or refunded amount in the minor unit of the transaction's currency. - * For dollars, for example, this is cents. + * The total settled amount in the minor unit of the transaction's currency. For + * dollars, for example, this is cents. */ fun settledAmount(settledAmount: Long) = settledAmount(JsonField.of(settledAmount)) @@ -56859,6 +56903,7 @@ private constructor( * .authorizedAmount() * .fuelConfirmedAmount() * .incrementedAmount() + * .refundedAmount() * .reversedAmount() * .settledAmount() * ``` @@ -56870,6 +56915,7 @@ private constructor( checkRequired("authorizedAmount", authorizedAmount), checkRequired("fuelConfirmedAmount", fuelConfirmedAmount), checkRequired("incrementedAmount", incrementedAmount), + checkRequired("refundedAmount", refundedAmount), checkRequired("reversedAmount", reversedAmount), checkRequired("settledAmount", settledAmount), additionalProperties.toMutableMap(), @@ -56886,6 +56932,7 @@ private constructor( authorizedAmount() fuelConfirmedAmount() incrementedAmount() + refundedAmount() reversedAmount() settledAmount() validated = true @@ -56910,6 +56957,7 @@ private constructor( (if (authorizedAmount.asKnown().isPresent) 1 else 0) + (if (fuelConfirmedAmount.asKnown().isPresent) 1 else 0) + (if (incrementedAmount.asKnown().isPresent) 1 else 0) + + (if (refundedAmount.asKnown().isPresent) 1 else 0) + (if (reversedAmount.asKnown().isPresent) 1 else 0) + (if (settledAmount.asKnown().isPresent) 1 else 0) @@ -56922,6 +56970,7 @@ private constructor( authorizedAmount == other.authorizedAmount && fuelConfirmedAmount == other.fuelConfirmedAmount && incrementedAmount == other.incrementedAmount && + refundedAmount == other.refundedAmount && reversedAmount == other.reversedAmount && settledAmount == other.settledAmount && additionalProperties == other.additionalProperties @@ -56932,6 +56981,7 @@ private constructor( authorizedAmount, fuelConfirmedAmount, incrementedAmount, + refundedAmount, reversedAmount, settledAmount, additionalProperties, @@ -56941,7 +56991,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "State{authorizedAmount=$authorizedAmount, fuelConfirmedAmount=$fuelConfirmedAmount, incrementedAmount=$incrementedAmount, reversedAmount=$reversedAmount, settledAmount=$settledAmount, additionalProperties=$additionalProperties}" + "State{authorizedAmount=$authorizedAmount, fuelConfirmedAmount=$fuelConfirmedAmount, incrementedAmount=$incrementedAmount, refundedAmount=$refundedAmount, reversedAmount=$reversedAmount, settledAmount=$settledAmount, additionalProperties=$additionalProperties}" } /** diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpayments/CardPaymentListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpayments/CardPaymentListPageResponseTest.kt index 0cbe42bb0..87e857cc4 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpayments/CardPaymentListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpayments/CardPaymentListPageResponseTest.kt @@ -5865,6 +5865,7 @@ internal class CardPaymentListPageResponseTest { .authorizedAmount(100L) .fuelConfirmedAmount(0L) .incrementedAmount(20L) + .refundedAmount(0L) .reversedAmount(20L) .settledAmount(100L) .build() @@ -11429,6 +11430,7 @@ internal class CardPaymentListPageResponseTest { .authorizedAmount(100L) .fuelConfirmedAmount(0L) .incrementedAmount(20L) + .refundedAmount(0L) .reversedAmount(20L) .settledAmount(100L) .build() @@ -17293,6 +17295,7 @@ internal class CardPaymentListPageResponseTest { .authorizedAmount(100L) .fuelConfirmedAmount(0L) .incrementedAmount(20L) + .refundedAmount(0L) .reversedAmount(20L) .settledAmount(100L) .build() diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpayments/CardPaymentTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpayments/CardPaymentTest.kt index 7622f6a45..e2bf426bb 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/cardpayments/CardPaymentTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/cardpayments/CardPaymentTest.kt @@ -5187,6 +5187,7 @@ internal class CardPaymentTest { .authorizedAmount(100L) .fuelConfirmedAmount(0L) .incrementedAmount(20L) + .refundedAmount(0L) .reversedAmount(20L) .settledAmount(100L) .build() @@ -9829,6 +9830,7 @@ internal class CardPaymentTest { .authorizedAmount(100L) .fuelConfirmedAmount(0L) .incrementedAmount(20L) + .refundedAmount(0L) .reversedAmount(20L) .settledAmount(100L) .build() @@ -15012,6 +15014,7 @@ internal class CardPaymentTest { .authorizedAmount(100L) .fuelConfirmedAmount(0L) .incrementedAmount(20L) + .refundedAmount(0L) .reversedAmount(20L) .settledAmount(100L) .build() From ca24660b0a5bf5c580d77e5a04be7498aaa0dd40 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 6 Oct 2025 15:13:58 +0000 Subject: [PATCH 4/5] fix(client): handle some Dispute objects as empty rather than unknown --- .stats.yml | 4 +- .../api/models/carddisputes/CardDispute.kt | 373 +++++++++++++++++- .../CardDisputeListPageResponseTest.kt | 42 +- .../models/carddisputes/CardDisputeTest.kt | 42 +- 4 files changed, 430 insertions(+), 31 deletions(-) diff --git a/.stats.yml b/.stats.yml index 6d6e5b784..238098d13 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 220 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-fcc4e952b005ab1fd26ae67fe0cac46a57699299c92e00680d4d0f6be51d7936.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-9e8783129ea725992844a51e7d6f6a639cae93753228cef7262eccb2e4bae58d.yml openapi_spec_hash: f1a7326721f814625c7d5484956afded -config_hash: f0b80170c2ea09811aeae3f1e94bc422 +config_hash: 4489d6e123ed885f5cb74fe619668e4b diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDispute.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDispute.kt index 46bde6b2e..d8633d825 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDispute.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/carddisputes/CardDispute.kt @@ -6452,7 +6452,8 @@ private constructor( private val cardholderNoLongerDisputes: JsonField, private val creditOrReversalProcessed: JsonField, private val invalidDispute: JsonField, - private val nonFiatCurrencyOrNonFungibleTokenAsDescribed: JsonValue, + private val nonFiatCurrencyOrNonFungibleTokenAsDescribed: + JsonField, private val nonFiatCurrencyOrNonFungibleTokenReceived: JsonField, private val proofOfCashDisbursement: JsonField, @@ -6476,7 +6477,9 @@ private constructor( invalidDispute: JsonField = JsonMissing.of(), @JsonProperty("non_fiat_currency_or_non_fungible_token_as_described") @ExcludeMissing - nonFiatCurrencyOrNonFungibleTokenAsDescribed: JsonValue = JsonMissing.of(), + nonFiatCurrencyOrNonFungibleTokenAsDescribed: + JsonField = + JsonMissing.of(), @JsonProperty("non_fiat_currency_or_non_fungible_token_received") @ExcludeMissing nonFiatCurrencyOrNonFungibleTokenReceived: @@ -6535,11 +6538,15 @@ private constructor( /** * Non-fiat currency or non-fungible token as described details. Present if and only * if `reason` is `non_fiat_currency_or_non_fungible_token_as_described`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("non_fiat_currency_or_non_fungible_token_as_described") - @ExcludeMissing - fun _nonFiatCurrencyOrNonFungibleTokenAsDescribed(): JsonValue = - nonFiatCurrencyOrNonFungibleTokenAsDescribed + fun nonFiatCurrencyOrNonFungibleTokenAsDescribed(): + Optional = + nonFiatCurrencyOrNonFungibleTokenAsDescribed.getOptional( + "non_fiat_currency_or_non_fungible_token_as_described" + ) /** * Non-fiat currency or non-fungible token received details. Present if and only if @@ -6615,6 +6622,18 @@ private constructor( @ExcludeMissing fun _invalidDispute(): JsonField = invalidDispute + /** + * Returns the raw JSON value of [nonFiatCurrencyOrNonFungibleTokenAsDescribed]. + * + * Unlike [nonFiatCurrencyOrNonFungibleTokenAsDescribed], this method doesn't throw + * if the JSON field has an unexpected type. + */ + @JsonProperty("non_fiat_currency_or_non_fungible_token_as_described") + @ExcludeMissing + fun _nonFiatCurrencyOrNonFungibleTokenAsDescribed(): + JsonField = + nonFiatCurrencyOrNonFungibleTokenAsDescribed + /** * Returns the raw JSON value of [nonFiatCurrencyOrNonFungibleTokenReceived]. * @@ -6696,7 +6715,9 @@ private constructor( private var creditOrReversalProcessed: JsonField? = null private var invalidDispute: JsonField? = null - private var nonFiatCurrencyOrNonFungibleTokenAsDescribed: JsonValue? = null + private var nonFiatCurrencyOrNonFungibleTokenAsDescribed: + JsonField? = + null private var nonFiatCurrencyOrNonFungibleTokenReceived: JsonField? = null @@ -6805,7 +6826,38 @@ private constructor( * only if `reason` is `non_fiat_currency_or_non_fungible_token_as_described`. */ fun nonFiatCurrencyOrNonFungibleTokenAsDescribed( - nonFiatCurrencyOrNonFungibleTokenAsDescribed: JsonValue + nonFiatCurrencyOrNonFungibleTokenAsDescribed: + NonFiatCurrencyOrNonFungibleTokenAsDescribed? + ) = + nonFiatCurrencyOrNonFungibleTokenAsDescribed( + JsonField.ofNullable(nonFiatCurrencyOrNonFungibleTokenAsDescribed) + ) + + /** + * Alias for calling [Builder.nonFiatCurrencyOrNonFungibleTokenAsDescribed] with + * `nonFiatCurrencyOrNonFungibleTokenAsDescribed.orElse(null)`. + */ + fun nonFiatCurrencyOrNonFungibleTokenAsDescribed( + nonFiatCurrencyOrNonFungibleTokenAsDescribed: + Optional + ) = + nonFiatCurrencyOrNonFungibleTokenAsDescribed( + nonFiatCurrencyOrNonFungibleTokenAsDescribed.getOrNull() + ) + + /** + * Sets [Builder.nonFiatCurrencyOrNonFungibleTokenAsDescribed] to an arbitrary + * JSON value. + * + * You should usually call + * [Builder.nonFiatCurrencyOrNonFungibleTokenAsDescribed] with a well-typed + * [NonFiatCurrencyOrNonFungibleTokenAsDescribed] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun nonFiatCurrencyOrNonFungibleTokenAsDescribed( + nonFiatCurrencyOrNonFungibleTokenAsDescribed: + JsonField ) = apply { this.nonFiatCurrencyOrNonFungibleTokenAsDescribed = nonFiatCurrencyOrNonFungibleTokenAsDescribed @@ -6986,6 +7038,7 @@ private constructor( cardholderNoLongerDisputes().ifPresent { it.validate() } creditOrReversalProcessed().ifPresent { it.validate() } invalidDispute().ifPresent { it.validate() } + nonFiatCurrencyOrNonFungibleTokenAsDescribed().ifPresent { it.validate() } nonFiatCurrencyOrNonFungibleTokenReceived().ifPresent { it.validate() } proofOfCashDisbursement().ifPresent { it.validate() } reason().validate() @@ -7012,6 +7065,10 @@ private constructor( (cardholderNoLongerDisputes.asKnown().getOrNull()?.validity() ?: 0) + (creditOrReversalProcessed.asKnown().getOrNull()?.validity() ?: 0) + (invalidDispute.asKnown().getOrNull()?.validity() ?: 0) + + (nonFiatCurrencyOrNonFungibleTokenAsDescribed + .asKnown() + .getOrNull() + ?.validity() ?: 0) + (nonFiatCurrencyOrNonFungibleTokenReceived.asKnown().getOrNull()?.validity() ?: 0) + (proofOfCashDisbursement.asKnown().getOrNull()?.validity() ?: 0) + @@ -8353,6 +8410,132 @@ private constructor( "InvalidDispute{explanation=$explanation, reason=$reason, additionalProperties=$additionalProperties}" } + /** + * Non-fiat currency or non-fungible token as described details. Present if and only + * if `reason` is `non_fiat_currency_or_non_fungible_token_as_described`. + */ + class NonFiatCurrencyOrNonFungibleTokenAsDescribed + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val additionalProperties: MutableMap + ) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 + * [NonFiatCurrencyOrNonFungibleTokenAsDescribed]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NonFiatCurrencyOrNonFungibleTokenAsDescribed]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + nonFiatCurrencyOrNonFungibleTokenAsDescribed: + NonFiatCurrencyOrNonFungibleTokenAsDescribed + ) = apply { + additionalProperties = + nonFiatCurrencyOrNonFungibleTokenAsDescribed.additionalProperties + .toMutableMap() + } + + 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 + * [NonFiatCurrencyOrNonFungibleTokenAsDescribed]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NonFiatCurrencyOrNonFungibleTokenAsDescribed = + NonFiatCurrencyOrNonFungibleTokenAsDescribed( + additionalProperties.toMutableMap() + ) + } + + private var validated: Boolean = false + + fun validate(): NonFiatCurrencyOrNonFungibleTokenAsDescribed = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NonFiatCurrencyOrNonFungibleTokenAsDescribed && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NonFiatCurrencyOrNonFungibleTokenAsDescribed{additionalProperties=$additionalProperties}" + } + /** * Non-fiat currency or non-fungible token received details. Present if and only if * `reason` is `non_fiat_currency_or_non_fungible_token_received`. @@ -10658,7 +10841,7 @@ private constructor( JsonField, private val consumerMerchandiseNotReceived: JsonField, - private val consumerNonReceiptOfCash: JsonValue, + private val consumerNonReceiptOfCash: JsonField, private val consumerOriginalCreditTransactionNotAccepted: JsonField, private val consumerQualityMerchandise: JsonField, @@ -10723,7 +10906,8 @@ private constructor( JsonMissing.of(), @JsonProperty("consumer_non_receipt_of_cash") @ExcludeMissing - consumerNonReceiptOfCash: JsonValue = JsonMissing.of(), + consumerNonReceiptOfCash: JsonField = + JsonMissing.of(), @JsonProperty("consumer_original_credit_transaction_not_accepted") @ExcludeMissing consumerOriginalCreditTransactionNotAccepted: @@ -10902,10 +11086,12 @@ private constructor( /** * Non-receipt of cash. Present if and only if `category` is * `consumer_non_receipt_of_cash`. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). */ - @JsonProperty("consumer_non_receipt_of_cash") - @ExcludeMissing - fun _consumerNonReceiptOfCash(): JsonValue = consumerNonReceiptOfCash + fun consumerNonReceiptOfCash(): Optional = + consumerNonReceiptOfCash.getOptional("consumer_non_receipt_of_cash") /** * Original Credit Transaction (OCT) not accepted. Present if and only if `category` @@ -11112,6 +11298,17 @@ private constructor( fun _consumerMerchandiseNotReceived(): JsonField = consumerMerchandiseNotReceived + /** + * Returns the raw JSON value of [consumerNonReceiptOfCash]. + * + * Unlike [consumerNonReceiptOfCash], this method doesn't throw if the JSON field + * has an unexpected type. + */ + @JsonProperty("consumer_non_receipt_of_cash") + @ExcludeMissing + fun _consumerNonReceiptOfCash(): JsonField = + consumerNonReceiptOfCash + /** * Returns the raw JSON value of [consumerOriginalCreditTransactionNotAccepted]. * @@ -11271,7 +11468,8 @@ private constructor( private var consumerMerchandiseNotReceived: JsonField? = null - private var consumerNonReceiptOfCash: JsonValue? = null + private var consumerNonReceiptOfCash: JsonField? = + null private var consumerOriginalCreditTransactionNotAccepted: JsonField? = null @@ -11670,9 +11868,28 @@ private constructor( * Non-receipt of cash. Present if and only if `category` is * `consumer_non_receipt_of_cash`. */ - fun consumerNonReceiptOfCash(consumerNonReceiptOfCash: JsonValue) = apply { - this.consumerNonReceiptOfCash = consumerNonReceiptOfCash - } + fun consumerNonReceiptOfCash( + consumerNonReceiptOfCash: ConsumerNonReceiptOfCash? + ) = consumerNonReceiptOfCash(JsonField.ofNullable(consumerNonReceiptOfCash)) + + /** + * Alias for calling [Builder.consumerNonReceiptOfCash] with + * `consumerNonReceiptOfCash.orElse(null)`. + */ + fun consumerNonReceiptOfCash( + consumerNonReceiptOfCash: Optional + ) = consumerNonReceiptOfCash(consumerNonReceiptOfCash.getOrNull()) + + /** + * Sets [Builder.consumerNonReceiptOfCash] to an arbitrary JSON value. + * + * You should usually call [Builder.consumerNonReceiptOfCash] with a well-typed + * [ConsumerNonReceiptOfCash] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun consumerNonReceiptOfCash( + consumerNonReceiptOfCash: JsonField + ) = apply { this.consumerNonReceiptOfCash = consumerNonReceiptOfCash } /** * Original Credit Transaction (OCT) not accepted. Present if and only if @@ -12041,6 +12258,7 @@ private constructor( consumerMerchandiseMisrepresentation().ifPresent { it.validate() } consumerMerchandiseNotAsDescribed().ifPresent { it.validate() } consumerMerchandiseNotReceived().ifPresent { it.validate() } + consumerNonReceiptOfCash().ifPresent { it.validate() } consumerOriginalCreditTransactionNotAccepted().ifPresent { it.validate() } consumerQualityMerchandise().ifPresent { it.validate() } consumerQualityServices().ifPresent { it.validate() } @@ -12082,6 +12300,7 @@ private constructor( ?: 0) + (consumerMerchandiseNotAsDescribed.asKnown().getOrNull()?.validity() ?: 0) + (consumerMerchandiseNotReceived.asKnown().getOrNull()?.validity() ?: 0) + + (consumerNonReceiptOfCash.asKnown().getOrNull()?.validity() ?: 0) + (consumerOriginalCreditTransactionNotAccepted .asKnown() .getOrNull() @@ -26917,6 +27136,126 @@ private constructor( "ConsumerMerchandiseNotReceived{cancellationOutcome=$cancellationOutcome, cardholderCancellationPriorToExpectedReceipt=$cardholderCancellationPriorToExpectedReceipt, delayed=$delayed, deliveredToWrongLocation=$deliveredToWrongLocation, deliveryIssue=$deliveryIssue, lastExpectedReceiptAt=$lastExpectedReceiptAt, merchantCancellation=$merchantCancellation, merchantResolutionAttempted=$merchantResolutionAttempted, noCancellation=$noCancellation, purchaseInfoAndExplanation=$purchaseInfoAndExplanation, additionalProperties=$additionalProperties}" } + /** + * Non-receipt of cash. Present if and only if `category` is + * `consumer_non_receipt_of_cash`. + */ + class ConsumerNonReceiptOfCash + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val additionalProperties: MutableMap + ) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 + * [ConsumerNonReceiptOfCash]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConsumerNonReceiptOfCash]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(consumerNonReceiptOfCash: ConsumerNonReceiptOfCash) = + apply { + additionalProperties = + consumerNonReceiptOfCash.additionalProperties.toMutableMap() + } + + 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 [ConsumerNonReceiptOfCash]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ConsumerNonReceiptOfCash = + ConsumerNonReceiptOfCash(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ConsumerNonReceiptOfCash = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ConsumerNonReceiptOfCash && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConsumerNonReceiptOfCash{additionalProperties=$additionalProperties}" + } + /** * Original Credit Transaction (OCT) not accepted. Present if and only if `category` * is `consumer_original_credit_transaction_not_accepted`. diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponseTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponseTest.kt index a83b17476..72ac6295e 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponseTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeListPageResponseTest.kt @@ -206,7 +206,12 @@ internal class CardDisputeListPageResponseTest { ) .build() ) - .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenAsDescribed + .builder() + .build() + ) .nonFiatCurrencyOrNonFungibleTokenReceived( CardDispute.Visa.NetworkEvent.Represented .NonFiatCurrencyOrNonFungibleTokenReceived @@ -880,7 +885,12 @@ internal class CardDisputeListPageResponseTest { ) .build() ) - .consumerNonReceiptOfCash(null) + .consumerNonReceiptOfCash( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerNonReceiptOfCash + .builder() + .build() + ) .consumerOriginalCreditTransactionNotAccepted( CardDispute.Visa.UserSubmission.Chargeback .ConsumerOriginalCreditTransactionNotAccepted @@ -1497,7 +1507,12 @@ internal class CardDisputeListPageResponseTest { ) .build() ) - .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenAsDescribed + .builder() + .build() + ) .nonFiatCurrencyOrNonFungibleTokenReceived( CardDispute.Visa.NetworkEvent.Represented .NonFiatCurrencyOrNonFungibleTokenReceived @@ -2117,7 +2132,12 @@ internal class CardDisputeListPageResponseTest { ) .build() ) - .consumerNonReceiptOfCash(null) + .consumerNonReceiptOfCash( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerNonReceiptOfCash + .builder() + .build() + ) .consumerOriginalCreditTransactionNotAccepted( CardDispute.Visa.UserSubmission.Chargeback .ConsumerOriginalCreditTransactionNotAccepted @@ -2712,7 +2732,12 @@ internal class CardDisputeListPageResponseTest { ) .build() ) - .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenAsDescribed + .builder() + .build() + ) .nonFiatCurrencyOrNonFungibleTokenReceived( CardDispute.Visa.NetworkEvent.Represented .NonFiatCurrencyOrNonFungibleTokenReceived @@ -3386,7 +3411,12 @@ internal class CardDisputeListPageResponseTest { ) .build() ) - .consumerNonReceiptOfCash(null) + .consumerNonReceiptOfCash( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerNonReceiptOfCash + .builder() + .build() + ) .consumerOriginalCreditTransactionNotAccepted( CardDispute.Visa.UserSubmission.Chargeback .ConsumerOriginalCreditTransactionNotAccepted diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeTest.kt index 9c1e82b54..560738723 100644 --- a/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeTest.kt +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/carddisputes/CardDisputeTest.kt @@ -198,7 +198,12 @@ internal class CardDisputeTest { ) .build() ) - .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenAsDescribed + .builder() + .build() + ) .nonFiatCurrencyOrNonFungibleTokenReceived( CardDispute.Visa.NetworkEvent.Represented .NonFiatCurrencyOrNonFungibleTokenReceived @@ -756,7 +761,12 @@ internal class CardDisputeTest { ) .build() ) - .consumerNonReceiptOfCash(null) + .consumerNonReceiptOfCash( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerNonReceiptOfCash + .builder() + .build() + ) .consumerOriginalCreditTransactionNotAccepted( CardDispute.Visa.UserSubmission.Chargeback .ConsumerOriginalCreditTransactionNotAccepted @@ -1290,7 +1300,12 @@ internal class CardDisputeTest { ) .build() ) - .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenAsDescribed + .builder() + .build() + ) .nonFiatCurrencyOrNonFungibleTokenReceived( CardDispute.Visa.NetworkEvent.Represented .NonFiatCurrencyOrNonFungibleTokenReceived @@ -1826,7 +1841,12 @@ internal class CardDisputeTest { ) .build() ) - .consumerNonReceiptOfCash(null) + .consumerNonReceiptOfCash( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerNonReceiptOfCash + .builder() + .build() + ) .consumerOriginalCreditTransactionNotAccepted( CardDispute.Visa.UserSubmission.Chargeback .ConsumerOriginalCreditTransactionNotAccepted @@ -2364,7 +2384,12 @@ internal class CardDisputeTest { ) .build() ) - .nonFiatCurrencyOrNonFungibleTokenAsDescribed(null) + .nonFiatCurrencyOrNonFungibleTokenAsDescribed( + CardDispute.Visa.NetworkEvent.Represented + .NonFiatCurrencyOrNonFungibleTokenAsDescribed + .builder() + .build() + ) .nonFiatCurrencyOrNonFungibleTokenReceived( CardDispute.Visa.NetworkEvent.Represented .NonFiatCurrencyOrNonFungibleTokenReceived @@ -2922,7 +2947,12 @@ internal class CardDisputeTest { ) .build() ) - .consumerNonReceiptOfCash(null) + .consumerNonReceiptOfCash( + CardDispute.Visa.UserSubmission.Chargeback + .ConsumerNonReceiptOfCash + .builder() + .build() + ) .consumerOriginalCreditTransactionNotAccepted( CardDispute.Visa.UserSubmission.Chargeback .ConsumerOriginalCreditTransactionNotAccepted From d018be814874eecbb449b65e43d1ad6bd6547d6f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 6 Oct 2025 15:14:30 +0000 Subject: [PATCH 5/5] release: 0.347.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 15 +++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6dc64191e..cb4cd84d3 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.346.0" + ".": "0.347.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ebcd85e7..129577b90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## 0.347.0 (2025-10-06) + +Full Changelog: [v0.346.0...v0.347.0](https://github.com/Increase/increase-java/compare/v0.346.0...v0.347.0) + +### Features + +* **api:** api update ([1b2b27b](https://github.com/Increase/increase-java/commit/1b2b27b41fe9d1d2a00b1524e1ee6cc08809571a)) +* **api:** api update ([443e6d7](https://github.com/Increase/increase-java/commit/443e6d78698488c070a1346ff26655ff63f9ef9e)) +* **api:** api update ([7b3da9f](https://github.com/Increase/increase-java/commit/7b3da9f438112a023cb85f7b0296c4fb633c40bd)) + + +### Bug Fixes + +* **client:** handle some Dispute objects as empty rather than unknown ([ca24660](https://github.com/Increase/increase-java/commit/ca24660b0a5bf5c580d77e5a04be7498aaa0dd40)) + ## 0.346.0 (2025-10-01) Full Changelog: [v0.345.0...v0.346.0](https://github.com/Increase/increase-java/compare/v0.345.0...v0.346.0) diff --git a/README.md b/README.md index 5f91573fd..4829dd052 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.346.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.346.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.346.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.347.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.347.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.347.0) @@ -13,7 +13,7 @@ The Increase Java SDK is similar to the Increase Kotlin SDK but with minor diffe -The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.346.0). +The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.347.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [increase.com](https://increase.com/d ### Gradle ```kotlin -implementation("com.increase.api:increase-java:0.346.0") +implementation("com.increase.api:increase-java:0.347.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.346.0") com.increase.api increase-java - 0.346.0 + 0.347.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 410c6ea48..3e6cc96e1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.346.0" // x-release-please-version + version = "0.347.0" // x-release-please-version } subprojects {